Commit e1c43503 authored by Kuan-Wei Chiu's avatar Kuan-Wei Chiu Committed by Vlastimil Babka
Browse files

mm/slub: Fix cmp_loc_by_count() to return 0 when counts are equal



The comparison function cmp_loc_by_count() used for sorting stack trace
locations in debugfs currently returns -1 if a->count > b->count and 1
otherwise. This breaks the antisymmetry property required by sort(),
because when two counts are equal, both cmp(a, b) and cmp(b, a) return
1.

This can lead to undefined or incorrect ordering results. Fix it by
updating the comparison logic to explicitly handle the case when counts
are equal, and use cmp_int() to ensure the comparison function adheres
to the required mathematical properties of antisymmetry.

Fixes: 553c0369 ("mm/slub: sort debugfs output by frequency of stack traces")
Reviewed-by: default avatarJoshua Hahn <joshua.hahnjy@gmail.com>
Signed-off-by: default avatarKuan-Wei Chiu <visitorckw@gmail.com>
Reviewed-by: default avatarHarry Yoo <harry.yoo@oracle.com>
Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
parent 850470a8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment