Skip to content

debug: debug_stream: log per-core utilization from idle thread load#10658

Open
kv2019i wants to merge 1 commit intothesofproject:mainfrom
kv2019i:202603-cpu-load
Open

debug: debug_stream: log per-core utilization from idle thread load#10658
kv2019i wants to merge 1 commit intothesofproject:mainfrom
kv2019i:202603-cpu-load

Conversation

@kv2019i
Copy link
Copy Markdown
Collaborator

@kv2019i kv2019i commented Mar 27, 2026

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.

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>
@kv2019i kv2019i requested review from jsarha and lyakh March 27, 2026 11:32
@kv2019i kv2019i requested a review from lgirdwood as a code owner March 27, 2026 11:32
Copilot AI review requested due to automatic review settings March 27, 2026 11:32
@kv2019i
Copy link
Copy Markdown
Collaborator Author

kv2019i commented Mar 27, 2026

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).

[150365.397958] <inf> copier: copier_comp_trigger: comp:0 0x6 No dai copier found, start/end offset is not calculated
[150365.397986] <wrn> host_comp: host_get_copy_bytes_normal: comp:0 0x6 no bytes to copy, available samples: 0, free_samples: 192
[150367.376058] <inf> thread_info: thread_info_cb: core 0 utilization 16%
[150369.377140] <inf> thread_info: thread_info_cb: core 0 utilization 15%
[150371.378221] <inf> thread_info: thread_info_cb: core 0 utilization 15%

Available when building SOF with "-o app/debug_stream_overlay.conf" and CONFIG_SOF_DEBUG_STREAM_THREAD_INFO=y

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_INF line for threads whose name starts with "idle", reporting utilization as 100% - idle_thread_cpu%.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +229 to +231
if (name && strncmp(name, "idle", 4) == 0)
LOG_INF("core %u utilization %u%%", ud->core,
100U - tinfo->cpu_usage * 100U / 255);
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, can you respond to copilot. Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants