linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mauricio Faria de Oliveira <mfo@igalia.com>
To: Michal Hocko <mhocko@suse.com>, Vlastimil Babka <vbabka@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Oscar Salvador <osalvador@suse.de>,
	Suren Baghdasaryan <surenb@google.com>,
	Brendan Jackman <jackmanb@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	kernel-dev@igalia.com
Subject: [PATCH v2 4/5] mm/page_owner: add debugfs file 'show_stacks_handles'
Date: Wed,  1 Oct 2025 14:56:10 -0300	[thread overview]
Message-ID: <20251001175611.575861-5-mfo@igalia.com> (raw)
In-Reply-To: <20251001175611.575861-1-mfo@igalia.com>

Add the file 'show_stacks_handles' to show just stack traces and their
handles, in order to resolve stack traces and handles (i.e., to identify
the stack traces for handles in previous reads from 'show_handles').

All stacks/handles must show up, regardless of their number of pages, that
might have become zero or no longer make 'count_threshold', but made it in
previous reads from 'show_handles' -- and need to be resolved later.

P.S.: now, print the extra newline independently of the number of pages.

Signed-off-by: Mauricio Faria de Oliveira <mfo@igalia.com>
---
 mm/page_owner.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/mm/page_owner.c b/mm/page_owner.c
index 5d488fce0e3d..0e5c7bb3e4e8 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -913,7 +913,8 @@ static int stack_print(struct seq_file *m, void *v)
 
 	nr_base_pages = refcount_read(&stack_record->count) - 1;
 
-	if (nr_base_pages < 1 || nr_base_pages < page_owner_pages_threshold)
+	if (ctx->flags & STACK_PRINT_FLAG_PAGES &&
+	    (nr_base_pages < 1 || nr_base_pages < page_owner_pages_threshold))
 		return 0;
 
 	if (ctx->flags & STACK_PRINT_FLAG_STACK) {
@@ -925,7 +926,8 @@ static int stack_print(struct seq_file *m, void *v)
 	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);
+		seq_printf(m, "nr_base_pages: %d\n", nr_base_pages);
+	seq_putc(m, '\n');
 
 	return 0;
 }
@@ -999,6 +1001,10 @@ static int __init pageowner_init(void)
 			    (void *)(STACK_PRINT_FLAG_HANDLE |
 				     STACK_PRINT_FLAG_PAGES),
 			    &page_owner_stack_operations);
+	debugfs_create_file("show_stacks_handles", 0400, dir,
+			    (void *)(STACK_PRINT_FLAG_STACK |
+				     STACK_PRINT_FLAG_HANDLE),
+			    &page_owner_stack_operations);
 	debugfs_create_file("count_threshold", 0600, dir, NULL,
 			    &proc_page_owner_threshold);
 
-- 
2.48.1



  parent reply	other threads:[~2025-10-01 17:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-01 17:56 [PATCH v2 0/5] mm/page_owner: add debugfs files 'show_handles' and 'show_stacks_handles' Mauricio Faria de Oliveira
2025-10-01 17:56 ` [PATCH v2 1/5] mm/page_owner: introduce struct stack_print_ctx Mauricio Faria de Oliveira
2025-10-09  8:01   ` Oscar Salvador
2025-10-01 17:56 ` [PATCH v2 2/5] mm/page_owner: add struct stack_print_ctx.flags Mauricio Faria de Oliveira
2025-10-09  8:07   ` Oscar Salvador
2025-10-01 17:56 ` [PATCH v2 3/5] mm/page_owner: add debugfs file 'show_handles' Mauricio Faria de Oliveira
2025-10-09  8:37   ` Oscar Salvador
2025-10-01 17:56 ` Mauricio Faria de Oliveira [this message]
2025-10-01 17:56 ` [PATCH v2 5/5] mm/page_owner: update Documentation with 'show_handles' and 'show_stacks_handles' Mauricio Faria de Oliveira
2025-10-09  2:32 ` [PATCH v2 0/5] mm/page_owner: add debugfs files " Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251001175611.575861-5-mfo@igalia.com \
    --to=mfo@igalia.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=jackmanb@google.com \
    --cc=kernel-dev@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=osalvador@suse.de \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox