Re: [PATCH v2] lib/list_sort: introduce list_sort_nonatomic() and clean up scheduling workarounds
From: Richard Weinberger
Date: Wed Mar 18 2026 - 06:12:27 EST
----- Ursprüngliche Mail -----
> Von: "Christoph Hellwig" <hch@xxxxxxxxxxxxx>
>> This change leaves the generic list_sort() completely free of
>> scheduling hacks, simplifies UBIFS's callbacks, and ensures that legacy
>> long-list sorting workloads remain safe from soft lockups on
>> non-preemptible kernels.
>
> As said before we really should not add the extra nonatomic API
> and just do the right thing, and drop the cond_resched in ubifs
> in a prep patch.
I think you are right. After inspecting UBIFS's usage of list_sort()
I feel more confident that we can remove the calls to cond_resched()
from the compare functions.
The compare functions are rather cheap, they don't do (blocking)
MTD io.
In the GC case each list contains at most as many UBIFS nodes you can
stuff into a single LEB.
The replay case is a little different, the replay list can contain
elements from multiple LEBs. But the UBIFS journal is limited to
a few LEBs, so the list is likely always at most a few thousand
elements long.
So, we always talk about calling the compare functions a few thousand
times, not millions times.
Thanks,
//richard