[PATCH v3 06/10] mm/page_owner: Read stack traces with stack_depot_fetch_into()

From: Matt Fleming

Date: Fri Nov 13 2026 - 15:56:03 EST


From: Matt Fleming <mfleming@xxxxxxxxxxxxxx>

stack_print() reads stack_record->entries directly. A later patch
stores compressed frames inside struct stack_record, so rather than
decompressing those frames let's use stack_depot_fetch_into().

Copy the trace with stack_depot_fetch_into() into a stack-local buffer
with PAGE_OWNER_STACK_DEPTH elements, which is the maximum number of
frames page_owner saves.

Signed-off-by: Matt Fleming <mfleming@xxxxxxxxxxxxxx>
---
mm/page_owner.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/page_owner.c b/mm/page_owner.c
index cfc31c92d765..16429e70e00d 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -1068,8 +1068,8 @@ static int stack_print(struct seq_file *m, void *v)
{
int i, nr_base_pages;
struct stack *stack = v;
- unsigned long *entries;
- unsigned long nr_entries;
+ unsigned long entries[PAGE_OWNER_STACK_DEPTH];
+ unsigned int nr_entries;
struct stack_record *stack_record = stack->stack_record;
struct stack_print_ctx *ctx = m->private;

@@ -1083,8 +1083,8 @@ static int stack_print(struct seq_file *m, void *v)
return 0;

if (ctx->flags & STACK_PRINT_FLAG_STACK) {
- nr_entries = stack_record->size;
- entries = stack_record->entries;
+ nr_entries = stack_depot_fetch_into(stack_record->handle.handle,
+ entries, ARRAY_SIZE(entries));
for (i = 0; i < nr_entries; i++)
seq_printf(m, " %pS\n", (void *)entries[i]);
}
--
2.43.0