Re: [PATCH v3 2/2] mm, slab: simplify returning slab in __refill_objects_node()

From: Vlastimil Babka (SUSE)

Date: Mon May 25 2026 - 03:16:29 EST


On 5/25/26 08:47, Hao Li wrote:
> On Fri, May 22, 2026 at 04:23:21PM +0200, Vlastimil Babka (SUSE) wrote:
>> When we return slabs to the partial list because we didn't fully refill
>> from them, we observe the min_partial limit when the returned slab is
>> empty, and discard it when over the limit. But it's unlikely for the
>> limit to be reached while we were refilling, and the worst outcome is to
>> have temporarily more free slabs on the list than necessary.
>
> Just wondering if the empty slabs temporarily exceed the limit and then some
> objects get allocated from them, would this lead to more fragmented slabs in
> the node partial list?

I think since we're adding the slabs to tail and refill from head, it
shouldn't happen that easily. Fragmenting is possible in general due to bad
luck, I doubt this change could make it noticeably worse.

>> So just
>> drop that code and simplify the function.
>>
>> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
>> ---
>> mm/slub.c | 10 ----------
>> 1 file changed, 10 deletions(-)
>>
>> diff --git a/mm/slub.c b/mm/slub.c
>> index 5816fcfc7a90..074d57c0390b 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -7196,21 +7196,11 @@ __refill_objects_node(struct kmem_cache *s, void **p, gfp_t gfp, unsigned int mi
>>
>> list_for_each_entry_safe(slab, slab2, &pc.slabs, slab_list) {
>>
>> - if (unlikely(!slab->inuse && n->nr_partial >= s->min_partial))
>> - continue;
>> -
>> list_del(&slab->slab_list);
>> add_partial(n, slab, ADD_TO_TAIL);
>> }
>>
>> spin_unlock_irqrestore(&n->list_lock, flags);
>> -
>> - /* any slabs left are completely free and for discard */
>> - list_for_each_entry_safe(slab, slab2, &pc.slabs, slab_list) {
>> -
>> - list_del(&slab->slab_list);
>> - discard_slab(s, slab);
>> - }
>> }
>>
>> return refilled;
>>
>> --
>> 2.54.0
>>
>