Re: [PATCH v11 3/4] tools/mm: add page_owner_filter userspace tool

From: zhen.ni

Date: Mon Jun 29 2026 - 04:51:34 EST




在 2026/6/25 12:50, Andrew Morton 写道:
On Thu, 25 Jun 2026 12:31:00 +0800 Zhen Ni <zhen.ni@xxxxxxxxxxxx> wrote:

Add a userspace filtering tool for page_owner that supports per-fd
filtering with print_mode and NUMA node filters.

Could this functionality have been built into page_owner_sort.c, or
does that not make any sense?



Hi,

I've considered the possibility of merging the two tools. They serve
different purposes:

- page_owner_sort: a post-processing tool for sorting/aggregating
already-captured page_owner dumps

- page_owner_filter: a real-time filtering tool

They function like two stages in a pipeline. While there may be
opportunities to share some parsing/formatting code between the two
tools in the future, a direct merge doesn't make sense.

I believe that as page_owner_filter's functionality expands,
it could potentially replace most of page_owner_sort's features.

Looking at page_owner_sort's current interface:

Usage: ./page_owner_sort [OPTIONS] <input> <output>
-a Sort by memory allocation time.
-m Sort by total memory.
-n Sort by task command name.
-p Sort by pid.
-P Sort by tgid.
-s Sort by the stacktrace.
-t Sort by number of times record is seen (default).

--pid <pidlist> Select by pid.
--tgid <tgidlist> Select by tgid.
--name <cmdlist> Select by command name.
--cull <rules> Cull by user-defined rules.
--sort <order> Specify sort order.

For example:
- Sorting by task command name (-n), PID (-p), TGID (-P), or stacktrace
(-s) seems less useful in practice — users typically care about specific processes rather than sorted lists.
- Sorting by total memory (-m) or occurrence count (-t) overlaps with
/sys/kernel/debug/page_owner_stacks functionality, which is more efficient.
- Filtering options (--pid, --tgid, --name, --cull) could potentially be
implemented in page_owner_filter as well.


Thanks,
Zhen