[PATCH 3/3] tools/mm/page_owner_sort: show available sort keys in usage text

From: Ye Liu

Date: Tue Jul 21 2026 - 22:40:12 EST


From: Ye Liu <liuye@xxxxxxxxxx>

The --sort option accepts abbreviated or complete key names, but the
usage text never listed them. Users had to read the source or the
documentation to discover valid keys.

List all available keys (full form and abbreviation) with a brief
description and examples directly in the --sort help section.

Signed-off-by: Ye Liu <liuye@xxxxxxxxxx>
---
tools/mm/page_owner_sort.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c
index 22e1761468d4..7a1bc054d295 100644
--- a/tools/mm/page_owner_sort.c
+++ b/tools/mm/page_owner_sort.c
@@ -762,6 +762,15 @@ static void usage(void)
"\t\t\targument in the form of a comma-separated list with some\n"
"\t\t\tcommon fields predefined (pid, tgid, comm, stacktrace, allocator, module)\n"
"--sort <order>\t\tSpecify sort order as: [+|-]key[,[+|-]key[,...]]\n"
+ "\t\t\tAvailable keys:\n"
+ "\t\t\t pid(p), tgid(tg), name(n), stacktrace(st),\n"
+ "\t\t\t txt(T), alloc_ts(at), allocator(ator), module(mod)\n"
+ "\t\t\tThe \"+\" is optional since default direction is\n"
+ "\t\t\tincreasing numerical or lexicographic order.\n"
+ "\t\t\tMixed use of abbreviated and complete-form is allowed.\n"
+ "\t\t\tExamples:\n"
+ "\t\t\t --sort=n,+pid,-tgid\n"
+ "\t\t\t --sort=mod,at\n"
);
}

--
2.25.1