Commit e1c4350
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: 553c036 ("mm/slub: sort debugfs output by frequency of stack traces")
Reviewed-by: Joshua Hahn <[email protected]>
Signed-off-by: Kuan-Wei Chiu <[email protected]>
Reviewed-by: Harry Yoo <[email protected]>
Signed-off-by: Vlastimil Babka <[email protected]>1 parent 850470a commit e1c4350
1 file changed
Lines changed: 1 addition & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7731 | 7731 | | |
7732 | 7732 | | |
7733 | 7733 | | |
7734 | | - | |
7735 | | - | |
7736 | | - | |
7737 | | - | |
| 7734 | + | |
7738 | 7735 | | |
7739 | 7736 | | |
7740 | 7737 | | |
| |||
0 commit comments