From nobody Tue Jun 16 08:55:54 2026 Received: from mail-m49236.qiye.163.com (mail-m49236.qiye.163.com [45.254.49.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFA3428C5B1 for ; Fri, 17 Apr 2026 16:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.236 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776441741; cv=none; b=gAjSvgcR5p0CdQPoDHd4yyr2778OeqP0BOTEjiQxPDwEKvBHVobpmMQgPMl075Bk2496dfema4tgsNAbkvR6rFyJbd7B0S0ZrQ+n8J7lLvXPZcNNeCVFcRGHO2lHuATYGuCH5Wt2Y8unVEj3S0qaJbR7GTP8nndcyTw966D+IQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776441741; c=relaxed/simple; bh=gbICEADcbcSDm8CPygt4LB7CqNyBedGPTa6kFVV9lsY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QfVofk6jovegTnxZ9WayEqQlLPNqEj+Yxog18750yz6jHen7kj63N++SlUnWAcRMz8X2hFT9sDjwdLR5donQPU7jPAulD5Sk4oGqr2kQHgyFE366xfc5ptLrTDWlaI2uovrvg9BmDT4U70EIPRlie5kx6cMu8FwOI4YLnWyaQnQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=easystack.cn; spf=pass smtp.mailfrom=easystack.cn; arc=none smtp.client-ip=45.254.49.236 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=easystack.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=easystack.cn Received: from localhost.localdomain (unknown [IPV6:2409:8a20:ef7:a5b4:8810:8f74:8c26:2]) by smtp.qiye.163.com (Hmail) with ESMTP id 190e229f6; Fri, 17 Apr 2026 23:46:50 +0800 (GMT+08:00) From: Zhen Ni To: akpm@linux-foundation.org, vbabka@kernel.org Cc: surenb@google.com, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhen Ni Subject: [PATCH 1/3] mm/page_owner: add filter infrastructure Date: Fri, 17 Apr 2026 23:46:36 +0800 Message-Id: <20260417154638.22370-2-zhen.ni@easystack.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20260417154638.22370-1-zhen.ni@easystack.cn> References: <20260417154638.22370-1-zhen.ni@easystack.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9d9c1f9a3d0229kunm7c3615e318e59b X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJQjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCQktDVkodGRhNTU0dTEtLTFYVFAkWGhdVGRETFh oSFyQUDg9ZV1kYEgtZQVlJT0tCQUMaSUtBHh1MQRpOGU9BQ0NKS0FDHUxPQUMYSU1BSVlXWRYaDx IVHRRZQVlPS0hVSktJT09PSFVKS0tVSkJLS1kG Content-Type: text/plain; charset="utf-8" Add data structure for page_owner filtering functionality and create debugfs directory for filter controls. This adds: - struct page_owner_filter with compact and nid fields - Static owner_filter instance initialized with default values - page_owner_filter debugfs directory The filter infrastructure will be used to add compact mode and NUMA node filtering capabilities in subsequent commits. Signed-off-by: Zhen Ni --- mm/page_owner.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mm/page_owner.c b/mm/page_owner.c index 8178e0be557f..6811439bf9e4 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -54,6 +54,16 @@ struct stack_print_ctx { u8 flags; }; =20 +struct page_owner_filter { + bool compact; + int nid; +}; + +static struct page_owner_filter owner_filter =3D { + .compact =3D false, + .nid =3D -1, +}; + static bool page_owner_enabled __initdata; DEFINE_STATIC_KEY_FALSE(page_owner_inited); =20 @@ -973,7 +983,7 @@ DEFINE_SIMPLE_ATTRIBUTE(page_owner_threshold_fops, &pag= e_owner_threshold_get, =20 static int __init pageowner_init(void) { - struct dentry *dir; + struct dentry *dir, *filter_dir; =20 if (!static_branch_unlikely(&page_owner_inited)) { pr_info("page_owner is disabled\n"); @@ -981,6 +991,9 @@ static int __init pageowner_init(void) } =20 debugfs_create_file("page_owner", 0400, NULL, NULL, &page_owner_fops); + + filter_dir =3D debugfs_create_dir("page_owner_filter", NULL); + dir =3D debugfs_create_dir("page_owner_stacks", NULL); debugfs_create_file("show_stacks", 0400, dir, (void *)(STACK_PRINT_FLAG_STACK | --=20 2.20.1 From nobody Tue Jun 16 08:55:54 2026 Received: from mail-m49244.qiye.163.com (mail-m49244.qiye.163.com [45.254.49.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED7BE33468C for ; Fri, 17 Apr 2026 15:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.244 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776441132; cv=none; b=BVPso/70P4X2g3BHpMd+u1WKmZEwokyIbTXVvFSDluoCx9T6L1uRXBa1bIC1Dm3DywukW7IHDMU5ix1beCB7SpvsTuB2h+ywbnNM1RwQathsK2HJls6eLdwRq2+nPbzalK5UbqiRYxy6+kUnPY1XOhBM+YdrjOlGBsaAnAWNfUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776441132; c=relaxed/simple; bh=JMgMMWX2dTVeZ32PbyMV7Kygd8OSLepd8Oy70oCiFr4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JPttHSiET/l6HPuAHEBkgKRcOJAu5/ExGffHFCRg5KBMuIpx/gKLl17iSGIdP9yyQHwf+aZy8TxyVDUsEIDXKcac0SRYAEWGlqj2FeZPC6KkTxCZ7gOHj7T9po8W576izPQ6hJUXJ6QtRluu1bxW2Mn5D5Tr4TmWANO+c7+0TkY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=easystack.cn; spf=pass smtp.mailfrom=easystack.cn; arc=none smtp.client-ip=45.254.49.244 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=easystack.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=easystack.cn Received: from localhost.localdomain (unknown [IPV6:2409:8a20:ef7:a5b4:8810:8f74:8c26:2]) by smtp.qiye.163.com (Hmail) with ESMTP id 190e229f9; Fri, 17 Apr 2026 23:46:52 +0800 (GMT+08:00) From: Zhen Ni To: akpm@linux-foundation.org, vbabka@kernel.org Cc: surenb@google.com, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhen Ni Subject: [PATCH 2/3] mm/page_owner: add compact mode filter Date: Fri, 17 Apr 2026 23:46:37 +0800 Message-Id: <20260417154638.22370-3-zhen.ni@easystack.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20260417154638.22370-1-zhen.ni@easystack.cn> References: <20260417154638.22370-1-zhen.ni@easystack.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9d9c1fa39c0229kunm7c3615e318e5a6 X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJQjdXWS1ZQUlXWQ8JGhUIEh9ZQVlDSB4ZVksZSk5KTB9KTB8eH1YVFAkWGhdVGRETFh oSFyQUDg9ZV1kYEgtZQVlJT0tCQUMaSUtBHh1MQRpOGU9BQ0NKS0FDHUxPQUMYSU1BSVlXWRYaDx IVHRRZQVlPS0hVSktJT09PSFVKS0tVSkJLS1kG Content-Type: text/plain; charset="utf-8" Add compact mode functionality to reduce page_owner output size by printing only the stack handle instead of the full stack trace. 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=3D3|zone=3D0| lastcpupid=3D0x1ffff) 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 --- 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, unsig= ned long pfn, migratetype_names[pageblock_mt], &page->flags); =20 - ret +=3D 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 +=3D scnprintf(kbuf + ret, count - ret, + "handle: %d\n", handle); + } else { + ret +=3D stack_depot_snprint(handle, kbuf + ret, count - ret, 0); + } + if (ret >=3D count) goto err; =20 @@ -980,6 +987,24 @@ static int page_owner_threshold_set(void *data, u64 va= l) DEFINE_SIMPLE_ATTRIBUTE(page_owner_threshold_fops, &page_owner_threshold_g= et, &page_owner_threshold_set, "%llu"); =20 +static int page_owner_compact_get(void *data, u64 *val) +{ + *val =3D READ_ONCE(owner_filter.compact); + return 0; +} + +static int page_owner_compact_set(void *data, u64 val) +{ + if (val !=3D 0 && val !=3D 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"); + =20 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); =20 filter_dir =3D debugfs_create_dir("page_owner_filter", NULL); + debugfs_create_file("compact", 0600, filter_dir, NULL, + &page_owner_compact_fops); =20 dir =3D debugfs_create_dir("page_owner_stacks", NULL); debugfs_create_file("show_stacks", 0400, dir, --=20 2.20.1 From nobody Tue Jun 16 08:55:54 2026 Received: from mail-m49204.qiye.163.com (mail-m49204.qiye.163.com [45.254.49.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DA15369219 for ; Fri, 17 Apr 2026 19:16:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.204 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776453376; cv=none; b=Urh8C4JdwMPclAkyMaLNW2pQJS7MOjUVlL5SPZaHC8Z+r1G9OH3+jAQSXGyvwBP7J0vkouZ1hqChufQI6Bxw/xokofNabPEL8FtF/XSNqCFGa0Dvfk1fgwSAg8NjjYVw0Z1NYJMpINwLFKVv53y84dF+ISU0G4UXdGRVvRBFBrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776453376; c=relaxed/simple; bh=E5AuFzF3xfaX8EAL5VpGpFQBLNJWlTaECfBKBoXk3YA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uU6/4LEYCn5d2kDppH1q63PwosRN48nNMFDkoa3aAfmwZaXg4YnohW40qgKOwMYthXNW8PuPKZqEkqRJi+gEn4cf8mFNTwO6ytwycqaL7Sro2n5cYh7UG01dPf+9M39MomH+8icALTLvxnNJjXHKfZeHg+m34xhjr/AEs4tH2p8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=easystack.cn; spf=pass smtp.mailfrom=easystack.cn; arc=none smtp.client-ip=45.254.49.204 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=easystack.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=easystack.cn Received: from localhost.localdomain (unknown [IPV6:2409:8a20:ef7:a5b4:8810:8f74:8c26:2]) by smtp.qiye.163.com (Hmail) with ESMTP id 190e229fb; Fri, 17 Apr 2026 23:46:54 +0800 (GMT+08:00) From: Zhen Ni To: akpm@linux-foundation.org, vbabka@kernel.org Cc: surenb@google.com, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhen Ni Subject: [PATCH 3/3] mm/page_owner: add NUMA node filter Date: Fri, 17 Apr 2026 23:46:38 +0800 Message-Id: <20260417154638.22370-4-zhen.ni@easystack.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20260417154638.22370-1-zhen.ni@easystack.cn> References: <20260417154638.22370-1-zhen.ni@easystack.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9d9c1fa9ff0229kunm7c3615e318e5ad X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJQjdXWS1ZQUlXWQ8JGhUIEh9ZQVkaSU1NVhhIQk1DTEtNTRgaHVYVFAkWGhdVGRETFh oSFyQUDg9ZV1kYEgtZQVlJT0tCQUMaSUtBHh1MQRpOGU9BQ0NKS0FDHUxPQUMYSU1BSVlXWRYaDx IVHRRZQVlPS0hVSktJT09PSFVKS0tVSkJLS1kG Content-Type: text/plain; charset="utf-8" Add NUMA node filtering functionality to page_owner to allow filtering pages by specific NUMA node. 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 --- 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, s= ize_t count, loff_t *ppos) if (unlikely(!page_ext)) continue; =20 + if (READ_ONCE(owner_filter.nid) >=3D 0) { + int nid =3D page_to_nid(page); + + if (nid !=3D 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 va= l) DEFINE_SIMPLE_ATTRIBUTE(page_owner_threshold_fops, &page_owner_threshold_g= et, &page_owner_threshold_set, "%llu"); =20 +static int page_owner_nid_filter_get(void *data, u64 *val) +{ + *val =3D READ_ONCE(owner_filter.nid); + return 0; +} + +static int page_owner_nid_filter_set(void *data, u64 val) +{ + if (val >=3D MAX_NUMNODES && val !=3D (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 =3D 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); =20 filter_dir =3D 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); =20 --=20 2.20.1