Skip to content

Commit 5832ea5

Browse files
author
Jyri Sarha
committed
zephyr: shell: Add sof module_heap_usage command
Adds new command to sof sub-command set. The new command, module_heap_usage, prints out all active component ids, their heap memory usage allocated through module API, and configured maximum heap size. NOTE: For the moment there is nothing preventing a module from allocating more memory than the configured maximum. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 7b2e881 commit 5832ea5

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

zephyr/sof_shell.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <rtos/sof.h> /* sof_get() */
99
#include <sof/schedule/ll_schedule_domain.h>
10+
#include <sof/audio/module_adapter/module/generic.h>
1011

1112
#include <zephyr/kernel.h>
1213
#include <zephyr/sys/printk.h>
@@ -41,11 +42,39 @@ static int cmd_sof_test_inject_sched_gap(const struct shell *sh,
4142
return 0;
4243
}
4344

45+
static int cmd_sof_module_heap_usage(const struct shell *sh,
46+
size_t argc, char *argv[])
47+
{
48+
struct ipc *ipc = sof_get()->ipc;
49+
struct list_item *clist, *_clist;
50+
struct ipc_comp_dev *icd;
51+
52+
if (!ipc) {
53+
shell_print(sh, "No IPC");
54+
return 0;
55+
}
56+
57+
list_for_item_safe(clist, _clist, &ipc->comp_list) {
58+
icd = container_of(clist, struct ipc_comp_dev, list);
59+
if (icd->type != COMP_TYPE_COMPONENT)
60+
continue;
61+
62+
shell_print(sh, "comp id 0x%08x\t%8zu bytes\t(%zu max)", icd->id,
63+
module_adapter_heap_usage(comp_mod(icd->cd)),
64+
comp_mod(icd->cd)->priv.cfg.heap_bytes);
65+
}
66+
return 0;
67+
}
68+
4469
SHELL_STATIC_SUBCMD_SET_CREATE(sof_commands,
4570
SHELL_CMD(test_inject_sched_gap, NULL,
4671
"Inject a gap to audio scheduling\n",
4772
cmd_sof_test_inject_sched_gap),
4873

74+
SHELL_CMD(module_heap_usage, NULL,
75+
"Print heap memory usage of each module\n",
76+
cmd_sof_module_heap_usage),
77+
4978
SHELL_SUBCMD_SET_END
5079
);
5180

0 commit comments

Comments
 (0)