From 99a665e1490d61d4aa3119709e96ba9ebfe9efb5 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 23 Nov 2026 13:00:41 +0000 Subject: [PATCH] zephyr: lib: log per-allocation heap stats at debug level 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 Co-Authored-By: Claude Opus 5.5 --- zephyr/lib/alloc.c | 6 +++--- zephyr/lib/vregion.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/zephyr/lib/alloc.c b/zephyr/lib/alloc.c index d87e621c8d0d..81ed7230c11f 100644 --- a/zephyr/lib/alloc.c +++ b/zephyr/lib/alloc.c @@ -309,7 +309,7 @@ static void *l3_heap_alloc_aligned(struct k_heap *h, size_t min_align, size_t by #if CONFIG_SYS_HEAP_RUNTIME_STATS && CONFIG_IPC_MAJOR_4 sys_heap_runtime_stats_get(&h->heap, &stats); - tr_info(&zephyr_tr, "heap allocated: %u free: %u max allocated: %u", + tr_dbg(&zephyr_tr, "heap allocated: %u free: %u max allocated: %u", stats.allocated_bytes, stats.free_bytes, stats.max_allocated_bytes); #endif @@ -492,7 +492,7 @@ static void *heap_alloc_aligned(struct k_heap *h, size_t min_align, size_t bytes #if CONFIG_SYS_HEAP_RUNTIME_STATS && CONFIG_IPC_MAJOR_4 sys_heap_runtime_stats_get(&h->heap, &stats); - tr_info(&zephyr_tr, "heap allocated: %u free: %u max allocated: %u", + tr_dbg(&zephyr_tr, "heap allocated: %u free: %u max allocated: %u", stats.allocated_bytes, stats.free_bytes, stats.max_allocated_bytes); #endif @@ -737,7 +737,7 @@ void *rbrealloc_align(void *ptr, uint32_t flags, size_t bytes, rfree(ptr); - tr_info(&zephyr_tr, "rbealloc: new ptr %p", new_ptr); + tr_dbg(&zephyr_tr, "rbealloc: new ptr %p", new_ptr); return new_ptr; } diff --git a/zephyr/lib/vregion.c b/zephyr/lib/vregion.c index ad33d25c889e..7239c7644a68 100644 --- a/zephyr/lib/vregion.c +++ b/zephyr/lib/vregion.c @@ -662,7 +662,7 @@ void *z_impl_vregion_alloc_align(struct vregion *vr, #if CONFIG_SYS_HEAP_RUNTIME_STATS if (vr->type == VREGION_MEM_TYPE_LIFETIME) { - LOG_INF("lifetime alloc of %zu, used %zu, free %zu", + LOG_DBG("lifetime alloc of %zu, used %zu, free %zu", size, vr->lifetime.used, vr->lifetime.size - vr->lifetime.used); } else if (vr->type == VREGION_MEM_TYPE_INTERIM) { @@ -670,7 +670,7 @@ void *z_impl_vregion_alloc_align(struct vregion *vr, sys_heap_runtime_stats_get(&vr->interim.heap.heap, &stats); - LOG_INF("interim alloc of %zu, used %u, free %u, max %u", + LOG_DBG("interim alloc of %zu, used %u, free %u, max %u", size, stats.allocated_bytes, stats.free_bytes, stats.max_allocated_bytes); }