Skip to content

zephyr: lib: log per-allocation heap stats at debug level - #11525

Merged
lgirdwood merged 1 commit into
thesofproject:mainfrom
lgirdwood:zephyr/heap-alloc-log-dbg
Nov 23, 2026
Merged

lgirdwood merged 1 commit into
thesofproject:mainfrom
lgirdwood:zephyr/heap-alloc-log-dbg

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

With CONFIG_SYS_HEAP_RUNTIME_STATS=y every heap and vregion allocation logs the heap usage at info level. The early init allocations alone fill the 4 kB mtrace log slot before the host starts reading it. The FW ABI banner, logged after them, is then lost, and sof-test check-sof-logger.sh fails with "Initial FW ABI banner not found". Whether the banner survives depends on how many allocations a platform does before it, so the failure is intermittent and platform dependent. It reproduces on WCL.

This moves the per-allocation statistics to debug level:

  • zephyr/lib/alloc.c: the two heap allocated: ... stats lines (L3 heap and normal heap) and rbealloc: new ptr
  • zephyr/lib/vregion.c: lifetime alloc of ... and interim alloc of ...

Allocation failures are still logged as errors. vpage and vregion creation, which happen once per pipeline or region, stay at info level.

Tested on WCL (GCC build), reloading the driver and then reading mtrace as check-sof-logger does:

FW ABI banner boot log lines messages dropped
main not found 35 yes
this PR found (2/2) 20 none

🤖 Generated with Claude Code

With CONFIG_SYS_HEAP_RUNTIME_STATS every heap and vregion allocation
logs the heap usage at info level. These messages are only useful when
debugging memory use, but they are the bulk of the boot log: the early
init allocations alone fill the 4kB mtrace log slot, before the host
starts reading it, so the FW ABI banner, that is logged after them, is
lost and the sof-test check-sof-logger test fails to find it.

Log the per-allocation heap and vregion statistics and the rbrealloc
result at debug level. Allocation failures are still logged as errors
and vpage and vregion creation stays at info level.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@intel-sofci

Copy link
Copy Markdown

PR 11525: test results

Run date: 2026-11-23 13:45 UTC

Tested commit: 99a665e1490d61d4aa3119709e96ba9ebfe9efb5

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

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ack. This was intended to be used with "-d" debug overlay originally. But with introduction of CONFIG_SOF_TELEMETRY_MEMORY , CONFIG_SYS_HEAP_RUNTIME_STATS is now default.

@lgirdwood
lgirdwood merged commit 90fe874 into thesofproject:main Nov 23, 2026
45 of 46 checks passed
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