]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
mempool: add mempool_{alloc,free}_bulk
authorChristoph Hellwig <hch@lst.de>
Thu, 13 Nov 2025 08:39:48 +0000 (09:39 +0100)
committerVlastimil Babka <vbabka@suse.cz>
Sun, 23 Nov 2025 11:30:36 +0000 (12:30 +0100)
commitac529d86ad26d632d3c70b7c5b839282a3294d2f
tree66bacb04d4ae5d159e5dca688461000bd44c463a
parent1742d97df628de55c0df1a0eb6eefb27136ee890
mempool: add mempool_{alloc,free}_bulk

Add a version of the mempool allocator that works for batch allocations
of multiple objects.  Calling mempool_alloc in a loop is not safe because
it could deadlock if multiple threads are performing such an allocation
at the same time.

As an extra benefit the interface is build so that the same array can be
used for alloc_pages_bulk / release_pages so that at least for page
backed mempools the fast path can use a nice batch optimization.

Note that mempool_alloc_bulk does not take a gfp_mask argument as it
must always be able to sleep and doesn't support any non-trivial
modifiers.  NOFO or NOIO constrainst must be set through the scoped API.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20251113084022.1255121-8-hch@lst.de
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
include/linux/mempool.h
mm/mempool.c