tools/mm/page_owner_sort: Fix timestamp comparison for stable sorting
PATCH 1/1 tools/mm/page_owner_sort: Fix timestamp comparison for stable sorting
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.
Signed-off-by Kaushlendra Kumar <[email protected]>
--- tools/mm/page_owner_sort.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/mm/page_owner_sort.c +5 -1
@@ -183,7 +183,11 @@ static int compare_ts(const void *p1, const void *p2) {const struct block_list *l1 = p1, *l2 = p2; -return l1->ts_nsec < l2->ts_nsec ?-1 :1 ; +if (l1->ts_nsec < l2->ts_nsec) +return -1 ; +if (l1->ts_nsec > l2->ts_nsec) +return 1 ; +return 0 ; }static int compare_cull_condition (const void *p1,const void *p2)
Signature · 1 line
2.34.1