From: Ye Liu <ye.liu@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Ye Liu <liuye@kylinos.cn>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] tools/mm/page_owner_sort: fix --sort option being silently ignored
Date: Wed, 22 Jul 2026 10:37:24 +0800 [thread overview]
Message-ID: <20260722023726.600200-2-ye.liu@linux.dev> (raw)
In-Reply-To: <20260722023726.600200-1-ye.liu@linux.dev>
From: Ye Liu <liuye@kylinos.cn>
When --sort is used without any short option (-a, -m, -p, etc.),
compare_flag remains COMP_NO_FLAG. The switch (compare_flag) then
falls through to the COMP_NUM case and calls set_single_cmp(), which
unconditionally overwrites the sort conditions that parse_sort_args()
already configured. This makes --sort silently ineffective unless a
short option is also supplied.
Split COMP_NO_FLAG out of the COMP_NUM fallthrough so that --sort is
respected when no short option is present.
Reproduction:
# Before fix: ascending order (ignored --sort=-pid)
./page_owner_sort --sort=-pid input.txt output.txt
# After fix: descending order as expected
Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
tools/mm/page_owner_sort.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c
index 35d3d254941c..3c86c8d0618c 100644
--- a/tools/mm/page_owner_sort.c
+++ b/tools/mm/page_owner_sort.c
@@ -821,6 +821,10 @@ int main(int argc, char **argv)
set_single_cmp(compare_stacktrace, SORT_ASC);
break;
case COMP_NO_FLAG:
+ if (sc.size > 0)
+ break;
+ set_single_cmp(compare_num, SORT_DESC);
+ break;
case COMP_NUM:
set_single_cmp(compare_num, SORT_DESC);
break;
--
2.25.1
next prev parent reply other threads:[~2026-07-22 2:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 2:37 [PATCH 0/3] tools/mm/page_owner_sort: fix --sort, add module filter, improve usage Ye Liu
2026-07-22 2:37 ` Ye Liu [this message]
2026-07-22 2:37 ` [PATCH 2/3] tools/mm/page_owner_sort: add module name sort/cull/filter support Ye Liu
2026-07-22 2:37 ` [PATCH 3/3] tools/mm/page_owner_sort: show available sort keys in usage text Ye Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260722023726.600200-2-ye.liu@linux.dev \
--to=ye.liu@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liuye@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox