Repository navigation
Phase 3 (part 4): move the kernel-only debug stream code to src/kernel/debug - #11461
Merged
Merged
Conversation
debug_stream_text_msg.c exports ds_msg() and assert_print() with EXPORT_SYMBOL(), but does not include rtos/symbol.h. On PTL the header comes in through other includes; on TGL it does not, so a TGL build with app/debug_stream_overlay.conf fails. Include it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
debug_stream_slot.c is kernel-only: it sets up the debug stream slot in the ADSP debug window at boot, writes the records to it under per-core spinlocks, and holds both halves of the debug_stream_slot_send_record() system call. The debug stream clients only reach it through the system call. Move it to src/kernel/debug/debug_stream, built under the same option, and update the system call table of the user-space README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
debug_stream_thread_info.c is kernel-only: it starts a kernel thread per core at boot, which walks the Zephyr threads of its core and reports their CPU use and stack use through the debug stream. Move it to src/kernel/debug/debug_stream, built under the same option. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…rc/kernel/debug debug_stream_text_msg.c mixes ds_msg() and ds_vamsg(), which format a text record and send it through the debug_stream_slot_send_record() system call, so they can be called in user mode, with the exception dump hook, which runs in the fatal error handler. Move the kernel part to src/kernel/debug/debug_stream/debug_stream_text_msg-kernel.c: - the per-core exception dump state, the dump and drain hooks and their registration with arch_exception_set_dump_hook() at boot; - assert_print(), which shares the per-core exception dump state. debug_stream_text_msg.c keeps ds_msg() and ds_vamsg() and the log module. The kernel part is built with the same option. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add a "Runs in:" banner to the debug stream README: the text message clients can run in user threads and use the slot system call, and the slot, the thread info client and the exception dump hook are in src/kernel/debug/debug_stream. debug_stream was the last directory without a banner, so drop the note about such directories from the user-space README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the debug-stream kernel/user-space separation.
No open issues 🎉
What changed in this PR
Advances the kernel/user-space partition in #11306 by moving privileged debug-stream code into src/kernel/debug/debug_stream, while keeping syscall-based text-message clients in the user-safe directory.
Changes:
- Relocates slot management and thread reporting, and separates exception handling from user-safe text-message functions.
- Updates build wiring under the existing configuration options and adds the missing symbol header to fix the TGL debug-stream build.
- Documents the debug-stream execution boundary and updates the syscall implementation path.
| File | Description |
|---|---|
src/kernel/debug/debug_stream/debug_stream_thread_info.c |
Relocates kernel thread reporting. |
src/kernel/debug/debug_stream/debug_stream_text_msg-kernel.c |
Houses exception hooks, assertion printing, and shared per-core state. |
src/kernel/debug/debug_stream/debug_stream_slot.c |
Relocates slot management and syscall implementation. |
src/kernel/debug/debug_stream/CMakeLists.txt |
Adds conditional builds for kernel debug-stream sources. |
src/kernel/debug/CMakeLists.txt |
Includes the debug-stream subdirectory. |
src/include/sof/userspace/README.md |
Updates the syscall path and removes the missing-banner note. |
src/debug/debug_stream/README.md |
Documents user-safe clients and kernel counterparts. |
src/debug/debug_stream/debug_stream_text_msg.c |
Retains text-message clients and adds the symbol header. |
src/debug/debug_stream/CMakeLists.txt |
Keeps only the user-safe text-message source. |
Review effort: Balanced
lgirdwood
marked this pull request as ready for review
November 15, 2026 15:23
lgirdwood
requested review from
dbaluta,
kv2019i,
lbetlej,
mmaka1 and
plbossart
as code owners
November 15, 2026 15:23
PR 11461: test resultsRun date: 2026-11-16 10:10 UTC Tested commit: 02fc4d7741689b84e105de1773bf8b52b3d94629 |
Member
Author
|
unrelated CI failures. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 3 of #11306 (kernel / user-space partition), fourth part: the remaining check of the Phase 3 list, "
zephyr/lib/alloc.c,vregion.c,debug_stream_slot.c: check that the z_impl/z_vrfy code is kernel-only". It moves the kernel-only debug stream code intosrc/kernel/debug/debug_stream.The check
zephyr/lib/alloc.c,zephyr/lib/vregion.c: these are kernel code, and stay where they are.z_impl_functions (sof_heap_alloc()/sof_heap_free(), thevregion_*()syscalls) are only reached through the syscalls or from kernel code.z_vrfy_halves are inzephyr/syscall/alloc.candzephyr/syscall/vregion.c.sof_sys_user_heap_get(),sof_sys_heap_get()andvregion_mem_info(). These are pure address computations, so they are safe to call, but they live in kernel files.rmalloc(),rzalloc(),rballoc_align()andrfree(), used by about 30 files in the user-space directories (most of them insrc/audio). These only work in kernel mode, so those paths must not run in user threads.src/debug/debug_stream/debug_stream_slot.c: this has both halves of thedebug_stream_slot_send_record()syscall, in a user-space directory. Its callers only use the syscall. So, with the debug stream's other kernel-only code, it moves tosrc/kernel/debug/debug_stream.Patches
rtos/symbol.hindebug_stream_text_msg.c: it usesEXPORT_SYMBOL()without including the header. A TGL build withapp/debug_stream_overlay.conffails without this; on PTL the header comes in through other includes.debug_stream_slot.c: the debug window slot setup, the per-core spinlocks and both halves of the syscall.debug_stream_thread_info.c: it starts a kernel thread per core that walks the Zephyr threads and reports their CPU and stack use.debug_stream_text_msg.c:ds_msg()andds_vamsg(), which send through the syscall and can run in user threads, stay. The exception dump hook, which runs in the fatal error handler, andassert_print(), which shares its per-core state, go todebug_stream_text_msg-kernel.c.The debug stream Kconfig stays where it is: it still configures the user part in
src/debug/debug_stream. The kernel files are built under the same options as before.Functional change
None, apart from the TGL build fix in the first patch.
app/debug_stream_overlay.conf: PTL, PTL withll_userspace_overlay.conf, and TGL. For these, the per-function disassembly of the images is unchanged at every commit. Only the PTL kernel-object hash table moves, which is layout.debug_stream_text_msg.care present, unchanged, in one of the two halves.Testing
Builds: tgl, tgl-h, mtl, lnl, ptl, wcl, nvl, imx8, imx8x, imx8m, imx8m_cm7, imx8ulp, imx95 and qemu_xtensa, and the extra CI configurations:
CONFIG_SOF_USERSPACE_PROXY=n;os_linux_overlay.conf;llext_relocatable.conf.Plus the three debug stream builds above.
Comparisons: objects, LLEXT modules and firmware images (sections, symbols,
SYS_INIT()order), and the per-function disassembly.Signing: rimage runs for every Intel platform, and the generated configs are unchanged.
Cadence xt-clang (RI-2022.10): MTL, PTL and NVL compile.
ZTest: the unit tests pass, run as in CI (18 of 18 configurations).
Host: the host library and the cmocka unit tests build and pass for all nine defconfigs and the library config.
All of the above was run on e9b5dd8 (current main).
🤖 Generated with Claude Code