Re: [PATCH 3/9] mempool: add mempool_{alloc,free}_bulk

Christoph Hellwig
2025-11-07T12:06:43Z

On Thu, Nov 06, 2025 at 07:52:07PM -0800, Eric Biggers wrote:
> > +int mempool_alloc_bulk_noprof(struct mempool *pool, void **elem,
> > + unsigned int count, gfp_t gfp_mask, unsigned long caller_ip)
>
> What exactly is the behavior on partial failures? Is the return value 0
> or is it -ENOMEM, and is the array restored to its original state or
> might some elements have been allocated?

Right now it frees everything. But as per the discussion with Vlastimil
I'll move to not allowing non-blocking allocations for multiple elements,
at which point the failure case just can't happen and that is sorted out.

> > +}
> > EXPORT_SYMBOL(mempool_alloc_noprof);
>
> How much overhead does this add to mempool_alloc(), which will continue
> to be the common case? I wonder if it would be worthwhile to
> force-inline the bulk allocation function into it, so that it will get
> generate about the same code as before.

It's about 10 extra instructions looking at my profiles. So I don't
think it matters, but if the maintainers prefer force inlining I
can do that.