Re: [PATCH 1/3] slab, block: generalize bvec_alloc_gfp

Christoph Hellwig
2025-10-24T09:05:40Z

On Fri, Oct 24, 2025 at 10:38:20AM +0200, Vlastimil Babka wrote:
> On 10/23/25 10:08, Christoph Hellwig wrote:
> > bvec_alloc_gfp is useful for any place that tries to kmalloc first and
> > then fall back to a mempool. Rename it and move it to blk.h to prepare
>
> I wonder if such fall backs are necessary because IIRC mempools try to
> allocate from the underlying provider (i.e. kmalloc caches first), and only
> give out the reserves when that fails. Is it done for less overhead or
> something?

That's the mempool behavior, yes. But the bvec allocator only has a
mempool for the largest possible allocation, while usually trying
smaller allocations instead.

>
> > for using it to allocate the default integrity buffer.
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> That says blk.h but you move it to slab.h? Assuming you intended slab.h.

Yes. I initially had it in blk.h, but it felt more general.

> However gfp flags are not slab only so it should be rather
> include/linux/gfp.h - added maintainers of that to Cc.

Ok.

> We do have gfp_nested_mask() there which is quite similar but not exactly.
> Maybe a canonical macro not for nested, but for opportunistic allocations
> (if a one size fits all solution can be found) would be useful too, as
> people indeed reinvent those manually in various places with subtle differences.

That's exactly what I've been trying to avoid indeed.