Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yifan Feng <evanfengff@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@kernel.org>
Cc: David Hildenbrand <david@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	Brendan Jackman <brendan.jackman@linux.dev>,
	Zi Yan <ziy@nvidia.com>, Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Mike Rapoport <rppt@kernel.org>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Yifan Feng <evanfengff@gmail.com>
Subject: [PATCH] tools/mm/page_owner_sort: fix slab allocator labelling
Date: Tue, 17 Nov 2026 13:49:47 -0800	[thread overview]
Message-ID: <20261117214947.13471-1-evanfengff@gmail.com> (raw)

page_owner_sort labels a page as allocated by slab when the page flags
in the "PFN" line contain "slab". Since commit 46df8e73a4a3 ("mm: free
up PG_slab") slab is a page type and is not printed there any more, so
slab pages are reported as allocated by OTHERS.

Also look for the slab page allocation in the stack trace, as is done
for vmalloc. The frame is new_slab(), or allocate_slab() when new_slab()
is inlined, as in the example in Documentation/mm/page_owner.rst. Slab
pages allocated before page_owner is initialised have no stack trace
and are still not labelled.

Fixes: 46df8e73a4a3 ("mm: free up PG_slab")
Signed-off-by: Yifan Feng <evanfengff@gmail.com>
---
Tested on v7.4-rc3 in QEMU: --cull=ator finds 1280 SLAB records, 0 before.
Found and written with the help of an AI coding assistant.

 tools/mm/page_owner_sort.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c
index 6c2ac5d9dc4b..453da5ba85c5 100644
--- a/tools/mm/page_owner_sort.c
+++ b/tools/mm/page_owner_sort.c
@@ -489,7 +489,8 @@ static int get_allocator(const char *buf, const char *migrate_info)
 
 	if (strstr(migrate_info, "CMA"))
 		allocator |= ALLOCATOR_CMA;
-	if (strstr(migrate_info, "slab"))
+	if (strstr(migrate_info, "slab") || strstr(buf, "new_slab") ||
+	    strstr(buf, "allocate_slab"))
 		allocator |= ALLOCATOR_SLAB;
 	tmp = strstr(buf, "__vmalloc_node_range");
 	if (tmp) {

base-commit: 666539eecdf4db623f5e3c3e55cf9f2dfad24aa4
-- 
2.39.3 (Apple Git-146)



                 reply	other threads:[~2026-11-17 21:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261117214947.13471-1-evanfengff@gmail.com \
    --to=evanfengff@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=brendan.jackman@linux.dev \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=willy@infradead.org \
    --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