k_thread_runtime_stats: peak_cycles rises by ~1–2% across idle boundary on Cortex-M; is 1% tolerance too strict? #103808
Unanswered
minyuan-xue
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
On an ARM Cortex-M board (240 MHz, 10 kHz system tick), running zephyr/tests/kernel/usage/thread_runtime_stats/src/ test_thread_runtime_stats.c, we see peak_cycles occasionally increase by ~6k cycles (≈1–2%) between sample 3 (pre-idle) and 4 (post-idle), causing the assertion with IDLE_EVENT_STATS_PRECISION=1 to fail.
A sample log (cycles):
(stats4.peak - stats3.peak )/stats3.peak ~ 1.3%, which over IDLE_EVENT_STATS_PRECISION=1%
Our understanding:
The increase comes from the non-idle “tail” before actually entering idle (abort/cleanup, sleep enqueue, scheduling/context switch, and possibly an ISR before WFI).
Questions:
Is it realistic to keep peak strictly unchanged with only 1% tolerance on all Cortex-M boards?
Should we relax the tolerance (e.g., 2–3% for ARM, like 3% for QEMU and 7% for RISC-V)?
Or any test suggestions?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions