Skip to content

tools/mm/page_owner_sort: fix --sort, add module filter, improve usage

Ye Liu linux-doc linux-mm lkml 3 versions – Applied

Status from this message: [merged mm-stable] tools-mm-page_owner_sort-show-available-sort-keys-in-usage-text.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 1 replyApplied 3/3
  2. v23 patches 3 repliesSuperseded
  3. v13 patches 2 repliesSuperseded

Changes in v3 from the cover letter

- Patch 1: Use fallthrough to COMP_NUM per David's review.
- Link:https://lore.kernel.org/all/[email protected]/

Patches in v3 All 3 applied

#Subject and filesSizeRepliesApplied
1/3tools/mm/page_owner_sort: fix --sort option being silently ignoredtools/mm/page_owner_sort.c+3 -00 repliesApplied
2/3tools/mm/page_owner_sort: add module name sort/cull/filter supportDocumentation/mm/page_owner.rst tools/mm/page_owner_sort.c+110 -200 repliesApplied
3/3tools/mm/page_owner_sort: show available sort keys in usage texttools/mm/page_owner_sort.c+9 -00 repliesApplied

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchDavid Hildenbrand (Arm)
1/3
2/3
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/3] tools/mm/page_owner_sort: fix --sort, add module filter, improve usage

From: Ye Liu <[email protected]>

This series improves the page_owner_sort tool with a bug fix, a new module-name feature, and better usage text.

Patch 1 fixes a long-standing bug where --sort was silently ignored when used without a short option (-a, -m, -p, etc.). The COMP_NO_FLAG case fell through to COMP_NUM and overwrote the sort conditions configured by parse_sort_args().

Patch 2 adds kernel module name support for sort, cull, and filter operations. Page owner stack traces already contain module names in the "function+0xNN/0xNN [module]" format produced by %pS, but page_owner_sort had no way to use them. Records without module frames are assigned "vmlinux".

  # Aggregate page usage per module
  ./page_owner_sort input.txt output.txt --cull=mod

  # Filter to records from xfs module only
  ./page_owner_sort input.txt output.txt --module xfs

  # Sort by module name, then by pid descending
  ./page_owner_sort input.txt output.txt --sort=mod,-pid

Patch 3 lists all available sort keys with abbreviations and examples directly in the --sort help section so users no longer need to read the source to discover valid keys.

Ye Liu (3):
tools/mm/page_owner_sort: fix --sort option being silently ignored tools/mm/page_owner_sort: add module name sort/cull/filter support tools/mm/page_owner_sort: show available sort keys in usage text

 Documentation/mm/page_owner.rst |   8 +-
 tools/mm/page_owner_sort.c      | 134 +++++++++++++++++++++++++++-----
 2 files changed, 122 insertions(+), 20 deletions(-)

---
v3:
- Patch 1: Use fallthrough to COMP_NUM per David's review.
- Link:https://lore.kernel.org/all/[email protected]/
v2:
- Patch 2: use regexec() directly in get_module() instead of search_pattern() to avoid excessive debug spam for the common vmlinux case when debug_on is true
- Patch 2: anchor module regex to stack trace format "+0xNN/0xNN [module]" to prevent false matches on kernel thread comm names like [khugepaged]
- Patch 2: add '-' to regex character class to support modules with hyphens (e.g. aa-bb-cc)
- Link:https://lore.kernel.org/all/[email protected]/

Signature · 1 line
2.25.1