From: Zi Yan <ziy@nvidia.com>
To: Zhen Ni <zhen.ni@easystack.cn>
Cc: akpm@linux-foundation.org, vbabka@kernel.org, surenb@google.com,
mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] mm/page_owner: add compact mode filter
Date: Fri, 17 Apr 2026 11:55:47 -0400 [thread overview]
Message-ID: <3F2D1A8D-806F-4BD3-AC41-055CE362B428@nvidia.com> (raw)
In-Reply-To: <20260417154638.22370-3-zhen.ni@easystack.cn>
On 17 Apr 2026, at 11:46, Zhen Ni wrote:
> Add compact mode functionality to reduce page_owner output size by
> printing only the stack handle instead of the full stack trace.
Maybe you could add an enum type for what content is printed.
Something like PAGE_OWNER_PRINT_STACK_HANDLE and PAGE_OWNER_PRINT_FULL_STACK.
Since compact is a very vague name for what the code does.
For the sysfs interface, stack_handle vs full_stack would be used.
>
> Example output:
> Page allocated via order 0, mask 0x42800(GFP_NOWAIT|__GFP_COMP),
> pid 1, tgid 1 (systemd), ts 349667370 ns
> PFN 0xa00a2 type Unmovable Block 1280 type Unmovable
> Flags 0x33fffe0000004124(referenced|lru|active|private|node=3|zone=0|
> lastcpupid=0x1ffff)
> handle: 17432583
> Charged to memcg /
>
> Compact mode significantly reduces output size while preserving all
> other page allocation information, making it easier to analyze large
> volumes of page owner data.The correspondence between handles and stack
> traces can be obtained through the show_stacks_handles interface.
>
> Signed-off-by: Zhen Ni <zhen.ni@easystack.cn>
> ---
> mm/page_owner.c | 29 ++++++++++++++++++++++++++++-
> 1 file changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/mm/page_owner.c b/mm/page_owner.c
> index 6811439bf9e4..214b58eef3d8 100644
> --- a/mm/page_owner.c
> +++ b/mm/page_owner.c
> @@ -585,7 +585,14 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn,
> migratetype_names[pageblock_mt],
> &page->flags);
>
> - ret += stack_depot_snprint(handle, kbuf + ret, count - ret, 0);
> + /* Compact mode: print handle instead of full stack trace */
> + if (READ_ONCE(owner_filter.compact)) {
> + ret += scnprintf(kbuf + ret, count - ret,
> + "handle: %d\n", handle);
> + } else {
> + ret += stack_depot_snprint(handle, kbuf + ret, count - ret, 0);
> + }
> +
> if (ret >= count)
> goto err;
>
> @@ -980,6 +987,24 @@ static int page_owner_threshold_set(void *data, u64 val)
> DEFINE_SIMPLE_ATTRIBUTE(page_owner_threshold_fops, &page_owner_threshold_get,
> &page_owner_threshold_set, "%llu");
>
> +static int page_owner_compact_get(void *data, u64 *val)
> +{
> + *val = READ_ONCE(owner_filter.compact);
> + return 0;
> +}
> +
> +static int page_owner_compact_set(void *data, u64 val)
> +{
> + if (val != 0 && val != 1)
> + return -EINVAL;
> + WRITE_ONCE(owner_filter.compact, val);
> + return 0;
> +}
> +
> +DEFINE_SIMPLE_ATTRIBUTE(page_owner_compact_fops,
> + &page_owner_compact_get,
> + &page_owner_compact_set, "%lld");
> +
>
> static int __init pageowner_init(void)
> {
> @@ -993,6 +1018,8 @@ static int __init pageowner_init(void)
> debugfs_create_file("page_owner", 0400, NULL, NULL, &page_owner_fops);
>
> filter_dir = debugfs_create_dir("page_owner_filter", NULL);
> + debugfs_create_file("compact", 0600, filter_dir, NULL,
> + &page_owner_compact_fops);
>
> dir = debugfs_create_dir("page_owner_stacks", NULL);
> debugfs_create_file("show_stacks", 0400, dir,
> --
> 2.20.1
Best Regards,
Yan, Zi
next prev parent reply other threads:[~2026-04-17 15:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 15:46 [PATCH 0/3] mm/page_owner: add filter infrastructure for compact mode and NUMA filtering Zhen Ni
2026-04-17 15:46 ` [PATCH 1/3] mm/page_owner: add filter infrastructure Zhen Ni
2026-04-17 15:46 ` [PATCH 2/3] mm/page_owner: add compact mode filter Zhen Ni
2026-04-17 15:55 ` Zi Yan [this message]
2026-04-17 15:46 ` [PATCH 3/3] mm/page_owner: add NUMA node filter Zhen Ni
2026-04-17 15:58 ` Zi Yan
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=3F2D1A8D-806F-4BD3-AC41-055CE362B428@nvidia.com \
--to=ziy@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=zhen.ni@easystack.cn \
/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