Re: [PATCH v2 0/8] mm/page_owner: Add PID/TGID/COMM and cgroup filtering

From: Vlastimil Babka (SUSE)

Date: Fri Sep 04 2026 - 04:27:15 EST


On 9/3/26 06:18, Zhen Ni wrote:
> This patch series adds process and memory cgroup filtering support to
> page_owner. Following the previous series that introduced print_mode and
> NUMA node filters:
> https://lore.kernel.org/linux-mm/20260707115411.1714314-1-zhen.ni@xxxxxxxxxxxx/
>
> This series adds filtering capabilities to page_owner, allowing users to
> filter output by specific processes and memory cgroups. Users can now
> filter page_owner output by PID, TGID, COMM (with wildcard support), and
> memory cgroup path. This makes page_owner debugging more focused and
> efficient for tracking memory allocations in specific contexts.

I wonder about the usefulness of all the new filters. In my experience
page_owner is useful to find a kernel memory leak code, and for that the
stacktraces are most useful. Dealing with things like pid/tgid/comm/cgroups
sounds more like your aim is to profile and optimize particular userspace to
use less kernel memory? In that case, isn't it rather the area of memory
allocation profiling (or maybe tracing with bpf), not page_owner?

Moreover, tracing or bpf can already do such kind of filtering and AFAIK
ftrace filters for tracepoints are nice and generic, while this is adding a
bunch of custom parsing and filtering. So that makes me somewhat sceptical.

> Targeted filtering provides significant performance benefits on large memory
> servers by reducing both execution time and output size. By filtering at the
> kernel level before reading, only relevant page allocations are processed,
> dramatically reducing the amount of data that needs to be handled in userspace.
>
> This series extends page_owner filtering capabilities with:
> - PID filtering
> - TGID filtering
> - COMM filtering with wildcard support
> - Cgroup (memcg) filtering for containerized environments
>
> The series is organized as follows:
>
> Patches 1-3: Add PID, TGID, and COMM filtering support to page_owner
> - Support filtering by process ID
> - Support filtering by thread group ID
> - Support filtering by command name with wildcards
>
> Patch 4: Refactor memcg handling to prepare for cgroup filter support
> Patch 5: Add memory cgroup filtering support
>
> Patches 6-7: Update page_owner_filter tool with corresponding features
>
> Patch 8: Update documentation
>
> These filters are particularly useful for:
> - Debugging memory leaks in specific processes
> - Analyzing memory usage in containerized environments
> - Isolating allocations from specific services or applications
>