]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tools/mm/page_owner_sort: fix timestamp comparison for stable sorting
authorKaushlendra Kumar <kaushlendra.kumar@intel.com>
Tue, 9 Dec 2025 04:45:52 +0000 (10:15 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Jan 2026 09:17:11 +0000 (10:17 +0100)
commit4df537e2478d2a694a6936ef48d38f90e798282a
tree4232db78005569163e7e2262035340ffa3f38076
parent54e9bd5025a071058965e12d34caea1a1229e143
tools/mm/page_owner_sort: fix timestamp comparison for stable sorting

commit 7013803444dd3bbbe28fd3360c084cec3057c554 upstream.

The ternary operator in compare_ts() returns 1 when timestamps are equal,
causing unstable sorting behavior. Replace with explicit three-way
comparison that returns 0 for equal timestamps, ensuring stable qsort
ordering and consistent output.

Link: https://lkml.kernel.org/r/20251209044552.3396468-1-kaushlendra.kumar@intel.com
Fixes: 8f9c447e2e2b ("tools/vm/page_owner_sort.c: support sorting pid and time")
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Cc: Chongxi Zhao <zhaochongxi2019@email.szu.edu.cn>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/mm/page_owner_sort.c