tests/kernel/smp: Fixup IPI test
This test was written to assume that the only IPI handled would be the one generated by the test, but the scheduler also generates an IPI any time a thread becomes runnable, and there's no way to lock that out in an SMP system where the other CPU is going to be doing its own thing (we can't use "1cpu" because that locks interrupts on the other CPU and obviously this is a test of an interrupt). Change the logic to detect that "at least one IPI was received", which is fine for coverage. Really a better place for a test like this would have been tests/kernel/mp, which is a test of the lower level APIs and runs the other CPU deterministically (i.e. not under the control of the Zephyr scheduler). Also some misc fixes: * Don't busy wait at the start, that's needless. * Sleep instead of busywaiting after sending the IPI, spinning isn't needed here and acts to increase CI load needlessly. * Declare the cross thread signal variable volatile for correctness (though this error seems to have been benign in practice). Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
4d5e67ed13
commit
fdba8be777
1 changed files with 9 additions and 13 deletions
|
@ -498,7 +498,7 @@ void test_get_cpu(void)
|
||||||
|
|
||||||
#ifdef CONFIG_TRACE_SCHED_IPI
|
#ifdef CONFIG_TRACE_SCHED_IPI
|
||||||
/* global variable for testing send IPI */
|
/* global variable for testing send IPI */
|
||||||
static int sched_ipi_has_called = -1;
|
static volatile int sched_ipi_has_called;
|
||||||
|
|
||||||
void z_trace_sched_ipi(void)
|
void z_trace_sched_ipi(void)
|
||||||
{
|
{
|
||||||
|
@ -524,23 +524,19 @@ void test_smp_ipi(void)
|
||||||
{
|
{
|
||||||
TC_PRINT("cpu num=%d", CONFIG_MP_NUM_CPUS);
|
TC_PRINT("cpu num=%d", CONFIG_MP_NUM_CPUS);
|
||||||
|
|
||||||
sched_ipi_has_called = 0;
|
for (int i = 0; i < 3 ; i++) {
|
||||||
|
|
||||||
k_busy_wait(DELAY_US);
|
|
||||||
|
|
||||||
/* It shouldn't enter our IPI interrupt handler at this moment */
|
|
||||||
zassert_true(sched_ipi_has_called == 0, "shouldn't receive IPI,(%d)",
|
|
||||||
sched_ipi_has_called);
|
|
||||||
|
|
||||||
for (int i = 1; i <= 3 ; i++) {
|
|
||||||
/* issue a sched ipi to tell other CPU to run thread */
|
/* issue a sched ipi to tell other CPU to run thread */
|
||||||
|
sched_ipi_has_called = 0;
|
||||||
arch_sched_ipi();
|
arch_sched_ipi();
|
||||||
|
|
||||||
/* do busy wait here until get IPI */
|
/* Need to wait longer than we think, loaded CI
|
||||||
k_busy_wait(DELAY_US);
|
* systems need to wait for host scheduling to run the
|
||||||
|
* other CPU's thread.
|
||||||
|
*/
|
||||||
|
k_msleep(100);
|
||||||
|
|
||||||
/**TESTPOINT: check if enter our IPI interrupt handler */
|
/**TESTPOINT: check if enter our IPI interrupt handler */
|
||||||
zassert_true(sched_ipi_has_called == i,
|
zassert_true(sched_ipi_has_called != 0,
|
||||||
"did not receive IPI.(%d)",
|
"did not receive IPI.(%d)",
|
||||||
sched_ipi_has_called);
|
sched_ipi_has_called);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue