[PATCH v1 0/2] tools/mm: slabinfo: fix inverted sorting and totals

From: Xuewen Wang

Date: Wed Nov 18 2026 - 01:05:05 EST


From: Xuewen Wang <wangxuewen@xxxxxxxxxx>

This series fixes two independent bugs in slabinfo:

1. Return signed comparison results for unequal numeric sort keys so
that -i correctly reverses size, activity, loss and partial sorting.
2. Keep the per-cache partial-object average instead of overwriting it
with a percentage before printing the PartObjs row.

Validation:

The sorting and totals fixes were additionally verified on live kernels
(v5.10 and v6.6) with root access: "slabinfo -l -S -i" is unsorted before
the sorting fix and ascending after it, with descending output unchanged;
"slabinfo -B -T" reports the PartObjs Average as a percentage (8 and 67)
before the totals fix and as the correct per-cache average
(2362 = 262202/111 and 48867 = 10897410/223) after it. No kernel slab
settings were modified.

Xuewen Wang (2):
tools/mm: slabinfo: fix inverted numeric sorting
tools/mm: slabinfo: preserve the average partial object count

tools/mm/slabinfo.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

--
2.25.1