-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: kernel: metairq: Ensure meta-IRQ can preempt a cooperative thread #84509
base: main
Are you sure you want to change the base?
tests: kernel: metairq: Ensure meta-IRQ can preempt a cooperative thread #84509
Conversation
The intention of the test is to have a meta-IRQ preempt a cooperative thread, then ensure the same cooperative thread is resumed back to instead of a higher priority thread. Thus, the test needs to assert that the lower priority cooperative thread is not yet complete when it makes the higher priority thread ready to run. This change reveals bugs like zephyrproject-rtos#80574, where the meta-IRQ is unable to preempt a cooperative thread. Signed-off-by: Kalle Kietäväinen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No complaints about the extra test assert, but tests/kernel/sched/preempt is supposed to be covering all these cases already. Do we know why that is passing for the affected (cortex-m only, right?) platforms?
@@ -113,6 +115,8 @@ void coop_thread1(void *p1, void *p2, void *p3) | |||
cnt2 = coop_cnt2; | |||
zassert_equal(cnt2, LOOP_CNT, "Unexpected cnt2 at end: %d", cnt2); | |||
|
|||
printk("thread1 end\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug code? Do we need this in the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily. As the cooperative thread already printed when it ended, I added these for the other two threads. It also makes the failure case more clear in the logs, I think:
Running TESTSUITE suite_preempt_metairq
===================================================================
START - test_preempt_metairq
thread1 take sem
thread2 take sem
metairq start
give sem2
thread2 got sem
thread2 loop iteration 0
thread2 loop iteration 1
thread2 loop iteration 2
thread2 loop iteration 3
thread2 end
Assertion failed at WEST_TOPDIR/zephyr/tests/kernel/sched/metairq/src/main.c:80: metairq_thread: (coop_cnt2 equal to LOOP_CNT)
thread2 wasn't preempted
FAIL - test_preempt_metairq in 0.065 seconds
The intention of the test is to have a meta-IRQ preempt a cooperative thread, then ensure the same cooperative thread is resumed back to instead of a higher priority thread. Thus, the test needs to assert that the lower priority cooperative thread is not yet complete when it makes the higher priority thread ready to run.
This change reveals bugs like #80574, where the meta-IRQ is unable to preempt a cooperative thread.
Important
This improves existing test case to reveal #80574, but doesn't fix the issue. The meta-IRQ test should start failing on Cortex-M with this.