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: context test_kernel_cpu_idle fails on nucleo_f091 board #46641
Comments
--> In this config, the test always pass when CONFIG_SYS_CLOCK_TICKS_PER_SEC<10000 (default value) (for example the test is successful with 9999 !) Else the idle_timer_expiry_function is called 2 times and test reports a failure. Or starting the idle_timer with period of 1 ms will also pass the test : In the _test_kernel_cpu_idle function, variable tms, tms2 are declared as int, but |
Instead of synchronizing on each loop, the tick sync comes only once after the timer init.
|
@danieldegrasse could please have a look |
@FRASTM based off what you have said here, the issue looks like it might be a rounding problem, since changing the wait period or While #41348 likely did cause a regression in the LPTIM driver, given the documentation for sys_clock_set_timeout, which states that the timer driver may make spurious calls to announce progress to the kernel, I believe the test case changes are valid. My best guess based off of what you have said here is that the LPTIM driver is making multiple calls to |
when running this test on the nucleo_f091rc , there is NO lptim but kernel timer. The sys_clock_set_timeout with _ticks = 10 is kernel function from drivers/timer/cortex_m_systick.c and is called at the k_timer_start(&idle_timer, K_MSEC(1), K_NO_WAIT); |
@FRASTM thanks for the clarification, I was not aware this issue was occurring with the systick driver. I've tried to reproduce this issue on an RT1050 and STM32 433RC evaluation kit, and so far have not had any luck. It may be necessary to add tracing code to the systick timer to narrow down what causes this issue. Are there other ST platforms with the same value for |
When the system clock is reduced to 44MHz (or lower) the test is passed.
with nucleo_wl55jc --> timer->timeout = 0 and duration.ticks = 536871272 |
This pb was already reported in the old issue #43663 |
One proposal is to change the next_timeout() function of the kernel/timeout.c to be as close to the elapsed time as possible
|
Does this change fix the issue? At least from the diff you have here, this seems like a logical change |
Yes, |
This test was written to idle for exactly 1ms and wake up with zero error, which is just too tight for some platforms (and worked on emulators where the tick rate is 10x coarser only because 0 == 0!). And it's not clear that it's testing anything we promise in documentation, regardless. Early wakeups are not an error and absolutely not disallowed, yet the test is treating the wakeup like a sleep. Clean it up a bit and relax the tolerance to what we can compute reliably: do all the math in ticks, idle for 10ms (i.e. longer than a host quantum for emulators), and allow 1 tick of slop on either side to permit slightly early wakeups while still verifying that "yes, the idle did idle". Fixes zephyrproject-rtos#46641 Signed-off-by: Andy Ross <andyross@google.com>
See #47112 for an alternative that will hopefully fix the issue by fixing some over-tight assumptions in the test |
This test was written to idle for exactly 1ms and wake up with zero error, which is just too tight for some platforms (and worked on emulators where the tick rate is 10x coarser only because 0 == 0!). And it's not clear that it's testing anything we promise in documentation, regardless. Early wakeups are not an error and absolutely not disallowed, yet the test is treating the wakeup like a sleep. Clean it up a bit and relax the tolerance to what we can compute reliably: do all the math in ticks, idle for 10ms (i.e. longer than a host quantum for emulators), and allow 1 tick of slop on either side to permit slightly early wakeups while still verifying that "yes, the idle did idle". Fixes #46641 Signed-off-by: Andy Ross <andyross@google.com>
Describe the bug
When executing the tests/kernel/context on the nucleo_f091rc board, the test_kernel_cpu_idle fails because the interrupt comes sooner than 1 millsecond which is the timer delay to wakeUp.
Please also mention any information which could help others to understand
the problem you're facing:
Similar to #41347 but the associated PR makes the test fails, in other words, the PR #41348 looks like a regression for this testcase on this board
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Test PASSED
Logs and console output
Environment (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: