Re: [PATCH v6 1/3] mm/page_owner: add print_mode filter

From: Oscar Salvador

Date: Mon May 11 2026 - 04:29:57 EST


On Mon, May 11, 2026 at 11:30:15AM +0800, Zhen Ni wrote:
> Add a print_mode filter to page_owner that allows users to choose between
> printing full stack traces or only stack handles, significantly reducing
> output size for debugging and analysis.
>
> The filter provides a string-based interface under
> /sys/kernel/debug/page_owner_filter/:
> - Reading shows the current mode with [] brackets around active option
> - Writing accepts "full_stack" or "stack_handle" strings
>
> The default full_stack mode maintains backward compatibility with existing
> usage, displaying complete stack traces for each page allocation.
>
> The stack_handle mode dramatically reduces log size by showing only
> the handle number instead of the full stack trace. The mapping from
> handles to actual stack traces can be obtained via the
> show_stacks_handles interface.
>
> Example usage:
> # echo stack_handle > /sys/kernel/debug/page_owner_filter/print_mode
> # cat /sys/kernel/debug/page_owner_filter/print_mode
> full_stack [stack_handle]
> # cat /sys/kernel/debug/page_owner
> Page allocated via order 0, migratetype Unmovable, gfp_mask 0x1100ca,
> pid 1, tgid 1 (systemd), ts 123456789 ns
> PFN 0x1000 type Unmovable Block 1 type Unmovable
> Flags 0x3fffe800000084(referenced|lru|active|private|node=0|zone=1)
> handle: 17432583
> ...
>
> Reviewed-by: SeongJae Park <sj@xxxxxxxxxx>
> Signed-off-by: Zhen Ni <zhen.ni@xxxxxxxxxxxx>

Overall looks good to me, one comment below

Reviewed-by: Oscar Salvador <osalvador@xxxxxxx>

> ---
...
> ---
> mm/page_owner.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 80 insertions(+), 2 deletions(-)
>
> diff --git a/mm/page_owner.c b/mm/page_owner.c
> index 8178e0be557f..27a412c52d41 100644
> --- a/mm/page_owner.c
> +++ b/mm/page_owner.c
> @@ -1,5 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0
> #include <linux/debugfs.h>
> +#include <linux/fs.h>

Why do we need this?


--
Oscar Salvador
SUSE Labs