From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-m49240.qiye.163.com (mail-m49240.qiye.163.com [45.254.49.240]) (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 7180F314A86 for ; Fri, 17 Apr 2026 15:52:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.240 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776441129; cv=none; b=OyMnapsRbn0qk13kc6AVmeUB0LoLdrtMiPXxwYWgawJmma74jklWc+pc+F5rWdl1h66Iu0glvx6MJXLrsf4M70PLWmDj/CBZjBMD2mjv0VcNrIFZb+IMPLA1VYSN/0zOKas7WC+ItQOLAl4qHi7Tf6MfyqznaZPxUyUAkwn4P4g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776441129; c=relaxed/simple; bh=dvHaGJSRiMMwyhJonSOYJdW6FENn9rMu1dgJHQU8uvk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=RNQKV2Xhfqxk+HyjX4Lzjp/L9JU+W7sVFzZ4wjm2szTNrtjyi16J0Bzk8zJv671lkSF4Zdf0eqeZmi12QQsHgZZfqXjPTJv3ZhlsY5g96ByyIUDwiZ8nPTxBeRp6EnNw5QNQQdxDE5owbJ9XSRN7fQG/GIeb93nNb2kBRjQmV1g= 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.240 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 190e229f4; Fri, 17 Apr 2026 23:46:47 +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 0/3] mm/page_owner: add filter infrastructure for compact mode and NUMA filtering Date: Fri, 17 Apr 2026 23:46:35 +0800 Message-Id: <20260417154638.22370-1-zhen.ni@easystack.cn> X-Mailer: git-send-email 2.20.1 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: 0a9d9c1f8ede0229kunm7c3615e318e598 X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJQjdXWS1ZQUlXWQ8JGhUIEh9ZQVkaGkMYVkJJGEpNSRkaT0oeGFYVFAkWGhdVGRETFh oSFyQUDg9ZV1kYEgtZQVlJT0tCQUMaSUtBHh1MQRpOGU9BQ0NKS0FDHUxPQUMYSU1BSVlXWRYaDx IVHRRZQVlPS0hVSktJT09PS1VKS0tVS1kG This patch series introduces filtering capabilities to the page_owner feature to address storage and performance challenges in production environments. Problem Statement ================= In production environments with large memory configurations (e.g., 250GB+), collecting page_owner information often results in files ranging from several gigabytes to over 10GB. This creates significant challenges: 1. Storage pressure on production systems 2. Difficulty transferring large files from production environments 3. Post-processing overhead with tools/mm/page_owner_sort.c The primary contributor to file size is redundant stack trace information. While the kernel already deduplicates stacks via stackdepot, page_owner retrieves and stores full stack traces for each page, only to deduplicate them again during post-processing. Additionally, in NUMA-aware environments (e.g., DPDK-based cloud deployments where QEMU processes are bound to specific NUMA nodes), OOM events are often node-specific rather than system-wide. Currently, page_owner cannot filter by NUMA node, forcing users to collect and analyze data for all nodes. Solution ======== This patch series introduces a flexible filter infrastructure with two initial filters: 1. **Compact Mode Filter**: Outputs only stack handles instead of full stack traces. The handle-to-stack mapping can be retrieved from the existing show_stacks_handles interface. This dramatically reduces output size while preserving all allocation metadata. 2. **NUMA Node Filter**: Allows filtering pages by specific NUMA node ID, enabling targeted analysis of memory issues in NUMA-aware deployments. Implementation ============== The series is structured as follows: - Patch 1: Add filter infrastructure (data structures and debugfs directory) - Patch 2: Implement compact mode filter - Patch 3: Implement NUMA node filter Usage Example ============= Enable compact mode and filter for NUMA node 2: # cd /sys/kernel/debug/page_owner_filter/ # echo 1 > compact # echo 2 > nid # cat /sys/kernel/debug/page_owner > page_owner_0417.txt Sample compact mode output: Page allocated via order 0, mask 0x0(), pid 0, tgid 0 (swapper), ts 0 ns PFN 0x80000 type Unmovable Block 1024 type Unmovable Flags 0x23fffe0000000000(node=2|zone=0|lastcpupid=0x1ffff) handle: 1048577 Page allocated via order 0, mask 0x252000(__GFP_NOWARN| __GFP_NORETRY|__GFP_COMP|__GFP_THISNODE), pid 0, tgid 0 (swapper), ts 0 ns PFN 0x80002 type Unmovable Block 1024 type Unmovable Flags 0x23fffe0000000200(workingset|node=2|zone=0|lastcpupid=0x1ffff) handle: 1048577 Future Enhancements ================== The filter infrastructure is designed to be extensible. Potential future filters could include: - PID/TGID filtering - Time range filtering (allocation timestamp windows) - GFP flag filtering - Migration type filtering Testing ======= Tested on a system with multiple NUMA nodes. Verified that: - Filters work independently and in combination - Compact mode output correlates correctly with show_stacks_handles - Default behavior (filters disabled) remains unchanged Signed-off-by: Zhen Ni --- Zhen Ni (3): mm/page_owner: add filter infrastructure mm/page_owner: add compact mode filter mm/page_owner: add NUMA node filter mm/page_owner.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) -- 2.20.1