diff --git a/app/perf_overlay.conf b/app/perf_overlay.conf index 0da2a5414399..5c031fe97c59 100644 --- a/app/perf_overlay.conf +++ b/app/perf_overlay.conf @@ -1 +1,2 @@ CONFIG_PERFORMANCE_COUNTERS=y +CONFIG_SYS_HEAP_RUNTIME_STATS=y diff --git a/zephyr/wrapper.c b/zephyr/wrapper.c index 9c9939db2620..af201a7ade5a 100644 --- a/zephyr/wrapper.c +++ b/zephyr/wrapper.c @@ -34,6 +34,10 @@ #include #endif +#if CONFIG_SYS_HEAP_RUNTIME_STATS +#include +#endif + LOG_MODULE_REGISTER(zephyr, CONFIG_SOF_LOG_LEVEL); extern K_KERNEL_STACK_ARRAY_DEFINE(z_interrupt_stacks, CONFIG_MP_NUM_CPUS, @@ -108,11 +112,20 @@ static void *heap_alloc_aligned(struct k_heap *h, size_t min_align, size_t bytes { k_spinlock_key_t key; void *ret; +#if CONFIG_SYS_HEAP_RUNTIME_STATS + struct sys_memory_stats stats; +#endif key = k_spin_lock(&h->lock); ret = sys_heap_aligned_alloc(&h->heap, min_align, bytes); k_spin_unlock(&h->lock, key); +#if CONFIG_SYS_HEAP_RUNTIME_STATS + sys_heap_runtime_stats_get(&h->heap, &stats); + tr_info(&zephyr_tr, "heap allocated: %u free: %u max allocated: %u", + stats.allocated_bytes, stats.free_bytes, stats.max_allocated_bytes); +#endif + return ret; }