Re: [PATCH 3/3] mm/page_owner: add NUMA node filter

Zi Yan
2026-04-17T15:58:20Z

On 17 Apr 2026, at 11:46, Zhen Ni wrote:

> Add NUMA node filtering functionality to page_owner to allow
> filtering pages by specific NUMA node.

Would a NUMA node bitmask be more generally applicable?
For sysfs, input and output can be a list of NUMA nodes that will be printed.

>
> The filter allows users to focus on pages from a specific NUMA node,
> which is useful for NUMA-aware memory allocation analysis and debugging.
> Setting nid to -1 disables filtering (default behavior).
>
> Signed-off-by: Zhen Ni <zhen.ni@easystack.cn>
> ---
> mm/page_owner.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/mm/page_owner.c b/mm/page_owner.c
> index 214b58eef3d8..ebc29f3f516d 100644
> --- a/mm/page_owner.c
> +++ b/mm/page_owner.c
> @@ -726,6 +726,13 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)
> if (unlikely(!page_ext))
> continue;
>
> + if (READ_ONCE(owner_filter.nid) >= 0) {
> + int nid = page_to_nid(page);
> +
> + if (nid != READ_ONCE(owner_filter.nid))
> + goto ext_put_continue;
> + }
> +
> /*
> * Some pages could be missed by concurrent allocation or free,
> * because we don't hold the zone lock.
> @@ -987,6 +994,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_nid_filter_get(void *data, u64 *val)
> +{
> + *val = READ_ONCE(owner_filter.nid);
> + return 0;
> +}
> +
> +static int page_owner_nid_filter_set(void *data, u64 val)
> +{
> + if (val >= MAX_NUMNODES && val != (u64)-1)
> + return -EINVAL;
> + WRITE_ONCE(owner_filter.nid, val);
> + return 0;
> +}
> +
> +DEFINE_SIMPLE_ATTRIBUTE(page_owner_nid_filter_fops,
> + &page_owner_nid_filter_get,
> + &page_owner_nid_filter_set, "%lld");
> +
> static int page_owner_compact_get(void *data, u64 *val)
> {
> *val = READ_ONCE(owner_filter.compact);
> @@ -1018,6 +1043,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("nid", 0600, filter_dir, NULL,
> + &page_owner_nid_filter_fops);
> debugfs_create_file("compact", 0600, filter_dir, NULL,
> &page_owner_compact_fops);
>
> --
> 2.20.1

Best Regards,
Yan, Zi