Skip to contentSkip to conversation

tools/mm/page_owner_sort: fix slab allocator labelling

PATCH New Yifan Feng 1 participant 1 message Nov 17 Memory management

lore
Share & tools
lore

Yifan Feng

author
#0 lore raw

PATCH 1/1 tools/mm/page_owner_sort: fix slab allocator labelling

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")

---
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(-)
tools/mm/page_owner_sort.c +2 -1
index 6c2ac5d9dc4b..453da5ba85c5 100644
@@ -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

Signature · 1 line
2.39.3 (Apple Git-146)