For monitoring the memory usage per stack trace, it is more efficient to use the handle number as unique identifier of a stack trace than to, for example, read/hash all stack traces to uniquely identify them everytime. The handle number is a unique identifier for stack traces in stackdepot. This patch adds the option 'print_handle' to print the handle number of stack traces in 'show_stacks'. Testing: - Without handles (default): # cat /sys/kernel/debug/page_owner_stacks/show_stacks > f1 - With handles (new option): # echo 1 >/sys/kernel/debug/page_owner_stacks/print_handle # cat /sys/kernel/debug/page_owner_stacks/show_stacks > f2 - Same number of lines for 'nr_base_pages' and 'handle': # grep -c '^nr_base_pages:' f1 873 # grep -c '^handle:' f2 873 Signed-off-by: Mauricio Faria de Oliveira --- mm/page_owner.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/page_owner.c b/mm/page_owner.c index c3ca21132c2c..420426749239 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -887,6 +887,7 @@ static void *stack_next(struct seq_file *m, void *v, loff_t *ppos) } static unsigned long page_owner_pages_threshold; +static bool page_owner_print_handle; static int stack_print(struct seq_file *m, void *v) { @@ -908,6 +909,8 @@ static int stack_print(struct seq_file *m, void *v) for (i = 0; i < nr_entries; i++) seq_printf(m, " %pS\n", (void *)entries[i]); + if (page_owner_print_handle) + seq_printf(m, "handle: %d\n", stack_record->handle.handle); seq_printf(m, "nr_base_pages: %d\n\n", nr_base_pages); return 0; @@ -968,6 +971,8 @@ static int __init pageowner_init(void) &page_owner_stack_operations); debugfs_create_file("count_threshold", 0600, dir, NULL, &proc_page_owner_threshold); + debugfs_create_bool("print_handle", 0600, dir, + &page_owner_print_handle); return 0; } -- 2.48.1