Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/include/sof/debug/telemetry/telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ struct sof_tel_thread_info {
int8_t prio;
uint8_t state;
uint8_t cpu_load; /* 0..255 scaled (0..100%) */
uint8_t stack_usage; /* 0..255 scaled high-water mark (0..100%) */
uint8_t stack_usage; /* 0..255 scaled high-water mark (0..100%), 0 if skipped */
uint8_t flags; /* bit0=idle, bit1=user, bit2=dp, bit3=ll */
uint16_t stack_size_chunks; /* stack size in 64-byte chunks */
uint32_t total_exec_kcycles; /* execution_cycles >> 10 */
Expand Down
3 changes: 3 additions & 0 deletions src/kernel/debug/telemetry/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ config SOF_TELEMETRY_THREADS
help
Periodically snapshots per-thread CPU load (%) and stack high-water
mark (%) into MW2 Slot 1 without requiring an extra 4 KB debug_stream slot.
The stack high-water mark of user-mode threads is sampled only with
XTENSA_MMU_FLUSH_AUTOREFILL_DTLBS_ON_SWAP enabled, otherwise it is
reported as 0.

config SOF_TELEMETRY_MODULE_RESOURCES
bool "Per-module heap usage, CPC violation, and I/O telemetry in MW3"
Expand Down
9 changes: 8 additions & 1 deletion src/kernel/debug/telemetry/telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,9 +865,16 @@ static void telemetry_thread_cb(const struct k_thread *cthread, void *user_data)
#ifdef CONFIG_THREAD_STACK_INFO
if (thread->stack_info.size > 0) {
size_t unused = 0;
/*
* Reading a user stack from this kernel thread leaves kernel-ring
* TLB entries that make the window handlers of that thread fault
* and hang the DSP, unless Zephyr flushes them on domain switch.
*/
bool scan = !(ti->flags & SOF_TEL_THD_FLG_USER) ||
IS_ENABLED(CONFIG_XTENSA_MMU_FLUSH_AUTOREFILL_DTLBS_ON_SWAP);

ti->stack_size_chunks = (uint16_t)(thread->stack_info.size >> 6);
if (z_impl_k_thread_stack_space_get(thread, &unused) == 0 &&
if (scan && z_impl_k_thread_stack_space_get(thread, &unused) == 0 &&
unused <= thread->stack_info.size) {
ti->stack_usage = (uint8_t)((255ULL * (thread->stack_info.size - unused)) /
thread->stack_info.size);
Expand Down
Loading