Skip to content

telemetry: enable telemetry with user-space LL - #11578

Open
kv2019i wants to merge 6 commits into
thesofproject:mainfrom
kv2019i:202612-telemetry-userspace-ll
Open

kv2019i wants to merge 6 commits into
thesofproject:mainfrom
kv2019i:202612-telemetry-userspace-ll

Conversation

@kv2019i

@kv2019i kv2019i commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

On PTL and the other targets that use app/ll_userspace_overlay.conf, telemetry is disabled because CONFIG_SOF_TELEMETRY depends on !SOF_USERSPACE_LL. This series makes the core telemetry user-space compatible and enables it. That brings back DSP core load reporting in the MW2 telemetry slot, and the TEL2 memory, vregion and thread sections.

The component performance measurements, the I/O performance counters and the TEL2 pipeline and gateway sections are still not user-space compatible. For now they depend on !SOF_USERSPACE_LL.

The thread info client runs in a kernel thread on each core and reads
the stack of every thread of the core to measure its high-water mark.
For a user-mode thread this leaves kernel-ring DTLB entries for its
stack. Its window handlers then fault on them and the core hangs,
without an exception record.

With CONFIG_SOF_USERSPACE_LL on PTL this hangs core 2 when the first
pipeline is created on it, depending on timing: the IPC user thread of
core 2 does not reply ("IPC user: sem error -11") and core 2 then fails
to power down ("core 2 did not enter idle state"). Enabling the TEL2
telemetry sections made it reproducible with sof-ptl-nocodec capture
on hw:0,2.

Skip the scan for user-mode threads and report 0, unless
XTENSA_MMU_FLUSH_AUTOREFILL_DTLBS_ON_SWAP is enabled, as telemetry does
since commit 9c6494b ("telemetry: do not scan the stacks of
user-mode threads").

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
telemetry_get_gw_hot() is only used by the DAI and Host gateway
telemetry, so builds without CONFIG_SOF_TELEMETRY_DAIS warn about an
unused function.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
The rolling average and the peaks of the LL tick time in
system_tick_info are only computed with
CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS. Tools such as sof-top
take the DSP core load from avg_utilization, so without the component
performance measurements every core reads as idle.

The systick statistics only use the LL tick times that telemetry
already collects, not the component measurements of
performance_monitor.c. Compute them with CONFIG_SOF_TELEMETRY.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Heap telemetry can remain stale after setup or teardown, while disabling pipeline telemetry prevents idle core-load resets and carries utilization history into the next stream.

2 open issues
What changed in this PR

This PR makes core SOF telemetry compatible with userspace LL scheduling, restoring DSP core-load reporting and TEL2 memory, virtual-region, and thread telemetry on affected targets.

Changes:

  • Adds validated syscalls for LL tick timing and a kernel-side snapshot of user-heap counters.
  • Keeps unsupported component, I/O, pipeline, and gateway telemetry disabled for userspace LL.
  • Avoids unsafe user-stack reads when the required TLB flushing is unavailable.
File Description
zephyr/​lib/​alloc.c Reports LL user-heap telemetry from a kernel-side snapshot.
zephyr/​CMakeLists.txt Registers the telemetry header for syscall generation.
src/​schedule/​zephyr_ll.c Uses telemetry syscalls around LL execution.
src/​kernel/​debug/​telemetry/​telemetry.c Implements tick syscalls, core-load tracking, and heap sampling.
src/​kernel/​debug/​telemetry/​Kconfig Allows core telemetry with userspace LL while restricting unsupported sections.
src/​kernel/​debug/​debug_stream/​debug_stream_thread_info.c Guards user-stack inspection against unsafe TLB behavior.
src/​include/​sof/​debug/​telemetry/​telemetry.h Declares tick syscalls and the heap-snapshot interface.
app/​ll_userspace_overlay.conf Updates comments to distinguish supported telemetry from disabled measurements.

Review effort: Balanced

depends on SOF_TELEMETRY_EXTENDED_WINDOW
# updated from the LL and IPC user threads, and walks user-writable
# pipeline lists
depends on !SOF_USERSPACE_LL

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, thanks. With SOF_TELEMETRY_PIPELINES off under user-space LL, telemetry_notify_ll_task_count() was a stub, so the idle reset of last_time_elapsed/avg_utilization and of the rolling-average queue never ran. Fixed in V2.

Comment on lines +1279 to +1281
if ((ticks & 0x3ff) == 0) {
/* in a system call of the LL user thread with SOF_USERSPACE_LL */
telemetry_sample_ll_user_heap();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. The snapshot was only taken from the LL tick system call, so setup allocations showed up late and teardown frees never did. Fixed in V2.

@intel-sofci

intel-sofci commented Dec 1, 2026 •

Copy link
Copy Markdown

PR 11578: test results

Run date: 2026-12-02 17:02 UTC

Tested commit: f1a1348fc1dccda9f19f8f5509660ed92ec3c49a

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

The LL scheduler calls telemetry_update() after each tick with
timestamps that it takes itself. With CONFIG_SOF_USERSPACE_LL the LL
scheduler runs in the LL user thread, which can neither read the timer
nor write the telemetry window and the telemetry state, nor schedule
the telemetry work. That is why telemetry depends on
!SOF_USERSPACE_LL.

Replace the call with two system calls, telemetry_ll_tick_start() and
telemetry_ll_tick_end(), so that the kernel takes the timestamps and
updates the telemetry. Only the LL user thread may call them. Without
CONFIG_USERSPACE they are direct calls, and telemetry_update() is now
local to telemetry.c.

The LL scheduler also reports its task count with
telemetry_notify_ll_task_count(), from the LL and IPC user threads.
When the last LL task of a core is gone, this resets the systick load
of the core, so that an idle core does not keep showing its last load
and the next stream does not start from its rolling average. Make it a
system call too, and provide it with the extended telemetry window
instead of only with CONFIG_SOF_TELEMETRY_PIPELINES, so that the reset
does not depend on the pipeline section. The pipeline section still
gets the task count when it is enabled.

This adds two system calls per LL tick and core with
CONFIG_SOF_USERSPACE_LL, and one per LL task start and stop.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
The memory telemetry reports the counters that the user-mode allocator
of the LL user heap keeps. They are in LL user memory, and the telemetry
work that reads them runs in a kernel thread. Kernel threads must not
access the memory of user threads: that leaves kernel-ring DTLB
entries, on which the user threads of the same core then fault.

Copy the counters in system calls of the LL and IPC user threads with
CONFIG_SOF_USERSPACE_LL, and report the copy:
- every 1024 LL ticks in telemetry_ll_tick_end(), before scheduling the
  telemetry work,
- when LL tasks start and stop, in telemetry_notify_ll_task_count(),
- after the IPC user thread has handled its commands, which create and
  free most LL resources, with the new telemetry_sync_user() system
  call.

The last two keep the reported usage current while no LL task runs,
e.g. after pipeline setup and teardown.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
The LL scheduler now reports its ticks with system calls, so telemetry
no longer needs the LL scheduler to run in kernel mode. Drop the
dependency of CONFIG_SOF_TELEMETRY on !SOF_USERSPACE_LL. On PTL and the
other targets that use app/ll_userspace_overlay.conf this enables the
systick telemetry and the TEL2 memory, vregion and thread sections in
Memory Window 2, so the DSP core load is reported again.

The other parts are not user-space compatible yet, so make them depend
on !SOF_USERSPACE_LL instead:
- the component performance measurements and the I/O performance
  counters are updated from the LL and IPC user threads,
- the TEL2 pipeline and gateway sections are updated from the LL and
  IPC user threads, and the pipeline section walks the component list
  that user threads can write.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
@kv2019i
kv2019i force-pushed the 202612-telemetry-userspace-ll branch from a7541b6 to f1a1348 Compare December 2, 2026 15:19
@kv2019i

kv2019i commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

V2 pushed:

  • addressing code review comments so far

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.

4 participants