[RFC] mm/page_owner: Use per-CPU temporal storage for saving stack trace
From: Kanishka Solanki
Date: Fri Oct 16 2026 - 16:52:52 EST
Hi,
I am looking into resolving the following TODO comment in mm/page_owner.c:
/*
* TODO: teach PAGE_OWNER_STACK_DEPTH (__dump_page_owner and save_stack)
* to use off stack temporal storage
*/
Currently, save_stack() allocates a local array on the thread stack to temporarily hold instruction pointers before passing them to Stack Depot:
unsigned long entries[PAGE_OWNER_STACK_DEPTH];
Keeping this array on the kernel thread stack risks stack exhaustion.
To move this scratchpad off the thread stack, I am considering using a per-CPU buffer, similar to how kernel/trace/trace.c manages ftrace_stacks:
struct page_owner_stack {
unsigned long entries[PAGE_OWNER_STACK_DEPTH];
};
static DEFINE_PER_CPU(struct page_owner_stack, page_owner_stacks);
Is a per-CPU scratchpad the preferred design for this off stack storage in page_owner?
Thanks,
Kanishka