Re: [PATCH RFC v2 09/20] slab: remove cpu (partial) slabs usage from allocation paths

From: Vlastimil Babka

Date: Thu Jan 15 2026 - 08:53:38 EST


On 1/14/26 07:07, Hao Li wrote:
>> @@ -4836,68 +4558,31 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
>> if (IS_ENABLED(CONFIG_SLUB_TINY) || kmem_cache_debug(s)) {
>> freelist = alloc_single_from_new_slab(s, slab, orig_size, gfpflags);
>>
>> - if (unlikely(!freelist)) {
>> - /* This could cause an endless loop. Fail instead. */
>> - if (!allow_spin)
>> - return NULL;
>> - goto new_objects;
>> + if (likely(freelist)) {
>> + goto success;
>> }
>> + } else {
>> + alloc_from_new_slab(s, slab, &freelist, 1, allow_spin);
>
> IIUC, when CONFIG_SLUB_DEBUG is enabled, each successful new_slab() call
> should have a matching inc_slabs_node(), since __kmem_cache_shutdown()
> rely on the accounting done by inc_slabs_node(). Here
> alloc_single_from_new_slab() does call inc_slabs_node(), but
> alloc_from_new_slab() doesn't. Could this mismatch cause any issues?

Great spot, thanks a lot! Yes we should do inc_slabs_node() here.

>>
>> - if (s->flags & SLAB_STORE_USER)
>> - set_track(s, freelist, TRACK_ALLOC, addr,
>> - gfpflags & ~(__GFP_DIRECT_RECLAIM));
>> -
>> - return freelist;
>> - }
>> -
>> - /*
>> - * No other reference to the slab yet so we can
>> - * muck around with it freely without cmpxchg
>> - */
>> - freelist = slab->freelist;
>> - slab->freelist = NULL;
>> - slab->inuse = slab->objects;
>> - slab->frozen = 1;
>> -