Re: [PATCH] mm/slab: improve kmem_cache_alloc_bulk

From: Vlastimil Babka (SUSE)

Date: Wed May 27 2026 - 05:39:21 EST


On 5/27/26 09:02, Christoph Hellwig wrote:
> The kmem_cache_alloc_bulk return value is weird. It returns the number
> of allocated objects, but that must always be 0 or the requested number
> based on the implementations and the handling in the callers, but that
> assumption is not actually documented anywhere, which confuses automated
> review tools.
>
> Fix this by returning a bool if the allocation succeeded and adding a
> kerneldoc comment explaining the API.
>
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Would 0 / -ENOMEM be more like what people would expect? I guess both that
and bool are better than the current API.