debug: debug_stream: log per-core utilization from idle thread load#10658
debug: debug_stream: log per-core utilization from idle thread load#10658kv2019i wants to merge 1 commit intothesofproject:mainfrom
Conversation
Keep the per-thread stack and cpu LOG_DBG print and add a separate LOG_INF that fires only for the Zephyr idle thread. The info-level print reports per-core CPU utilization calculated as the inverse of the idle thread load percentage. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
|
This is very convenient debug tool especially when running with DP modules (the existing infra to track LL scheduler load don't provide the full picture anymore). Available when building SOF with "-o app/debug_stream_overlay.conf" and CONFIG_SOF_DEBUG_STREAM_THREAD_INFO=y |
There was a problem hiding this comment.
Pull request overview
This PR enhances debug_stream thread reporting by adding a per-core CPU utilization info log derived from the Zephyr idle thread’s runtime stats, while keeping the existing per-thread debug log output.
Changes:
- Add
<string.h>include (needed for string utilities used in the file). - Emit a
LOG_INFline for threads whose name starts with"idle", reporting utilization as100% - idle_thread_cpu%.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (name && strncmp(name, "idle", 4) == 0) | ||
| LOG_INF("core %u utilization %u%%", ud->core, | ||
| 100U - tinfo->cpu_usage * 100U / 255); |
There was a problem hiding this comment.
The new utilization LOG_INF can print misleading 100% utilization when runtime stats are unavailable (e.g., CONFIG_THREAD_RUNTIME_STATS disabled, ud->stats_valid false, or k_thread_runtime_stats_get() fails and thread_info_cpu_utilization returns 0). Please guard this log on stats availability (and ideally on a distinct “cpu usage valid” result) so 0% idle isn’t conflated with “unknown” idle load.
| if (name && strncmp(name, "idle", 4) == 0) | |
| LOG_INF("core %u utilization %u%%", ud->core, | |
| 100U - tinfo->cpu_usage * 100U / 255); | |
| #ifdef CONFIG_THREAD_RUNTIME_STATS | |
| if (ud->stats_valid && name && strncmp(name, "idle", 4) == 0) { | |
| LOG_INF("core %u utilization %u%%", ud->core, | |
| 100U - tinfo->cpu_usage * 100U / 255); | |
| } | |
| #endif |
lgirdwood
left a comment
There was a problem hiding this comment.
LGTM, can you respond to copilot. Thanks !
Keep the per-thread stack and cpu LOG_DBG print and add a separate LOG_INF that fires only for the Zephyr idle thread. The info-level print reports per-core CPU utilization calculated as the inverse of the idle thread load percentage.