]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/page_owner: add debugfs file 'show_handles'
authorMauricio Faria de Oliveira <mfo@igalia.com>
Wed, 1 Oct 2025 17:56:09 +0000 (14:56 -0300)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 22 Oct 2025 01:51:24 +0000 (18:51 -0700)
Add the flag STACK_PRINT_FLAG_HANDLE to print a stack's handle number from
stackdepot, and add the file 'show_handles' to show just handles and their
number of pages.

This is similar to 'show_stacks', with handles instead of stack traces.

Link: https://lkml.kernel.org/r/20251001175611.575861-4-mfo@igalia.com
Signed-off-by: Mauricio Faria de Oliveira <mfo@igalia.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/page_owner.c

index 2f6f99d60ba7eaad5fa90140785bd9fc73acfb14..fe788f07b57875af96f805f5ac139384264304d4 100644 (file)
@@ -47,6 +47,7 @@ static DEFINE_SPINLOCK(stack_list_lock);
 
 #define STACK_PRINT_FLAG_STACK         0x1
 #define STACK_PRINT_FLAG_PAGES         0x2
+#define STACK_PRINT_FLAG_HANDLE                0x4
 
 struct stack_print_ctx {
        struct stack *stack;
@@ -924,6 +925,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 (ctx->flags & STACK_PRINT_FLAG_HANDLE)
+               seq_printf(m, "handle: %d\n", stack_record->handle.handle);
        if (ctx->flags & STACK_PRINT_FLAG_PAGES)
                seq_printf(m, "nr_base_pages: %d\n\n", nr_base_pages);
 
@@ -995,6 +998,10 @@ static int __init pageowner_init(void)
                            (void *)(STACK_PRINT_FLAG_STACK |
                                     STACK_PRINT_FLAG_PAGES),
                            &page_owner_stack_operations);
+       debugfs_create_file("show_handles", 0400, dir,
+                           (void *)(STACK_PRINT_FLAG_HANDLE |
+                                    STACK_PRINT_FLAG_PAGES),
+                           &page_owner_stack_operations);
        debugfs_create_file("count_threshold", 0600, dir, NULL,
                            &proc_page_owner_threshold);