Re: [PATCH v2] mm/slub: skip freelist construction for whole-slab bulk refill

From: Hao Li

Date: Thu Apr 02 2026 - 05:10:09 EST


On Wed, Apr 01, 2026 at 09:56:49PM +0800, hu.shengming@xxxxxxxxxx wrote:
[...]
> > > +static inline bool bulk_refill_consumes_whole_slab(struct kmem_cache *s,
> > > + unsigned int count)
> > > +{
> > > + return count >= oo_objects(s->oo);
> >
> > It seems using s->oo here may be a bit too strict. In allocate_slab(), the
> > object count can fall back to s->min, so using s->objects might be more
> > reasonable (If I understand correctly...).
> >
>
> Good point. I do not see s->objects in current linux-next; did you mean
> slab->objects?
>
> oo_objects(s->oo) is the preferred-layout object count, while the actual
> object count of a newly allocated slab is only known after allocate_slab(),
> via slab->objects, since allocation can fall back to s->min.
>
> So I used oo_objects(s->oo) because this check happens before slab
> allocation. It is conservative, but safe.

Oh, right.. sorry, I misread that. Please ignore this point..