Re: [PATCH v1 1/2] tools/mm: slabinfo: fix inverted numeric sorting
From: Harry Yoo
Date: Wed Dec 02 2026 - 13:24:35 EST
On Wed, Nov 18, 2026 at 02:03:16PM +0800, Xuewen Wang wrote:
> From: Xuewen Wang <wangxuewen@xxxxxxxxxx>
>
> The numeric branches of sort_slabs() return either zero or one for
> unequal keys. Negating these values for -i never yields a positive
> result, so the sort does not swap entries with different numeric keys.
> For example, partial-slab counts 30, 10, 20 remain in that order
> with -P -i instead of being sorted as 10, 20, 30.
>
> Return a positive or negative result for unequal numeric keys so that
> the existing inversion works for size, activity, loss and partial-slab
> sorting. Preserve the alphabetic tie break for equal keys and avoid
> subtracting unsigned counters.
>
> Fixes: c09d87517298 ("slub: add slabinfo tool")
> Signed-off-by: Xuewen Wang <wangxuewen@xxxxxxxxxx>
> ---
Looks good to me,
Acked-by: Harry Yoo (Meta) <harry@xxxxxxxxxx>
--
Cheers,
Harry / Hyeonggon