From mboxrd@z Thu Jan 1 00:00:00 1970 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: 8bit X-HM-Tid: 0a9d9c1fa9ff0229kunm7c3615e318e5ad X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJQjdXWS1ZQUlXWQ8JGhUIEh9ZQVkaSU1NVhhIQk1DTEtNTRgaHVYVFAkWGhdVGRETFh oSFyQUDg9ZV1kYEgtZQVlJT0tCQUMaSUtBHh1MQRpOGU9BQ0NKS0FDHUxPQUMYSU1BSVlXWRYaDx IVHRRZQVlPS0hVSktJT09PSFVKS0tVSkJLS1kG 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, 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