diff options
| author | Christoph Hellwig <hch@lst.de> | 2026-05-28 11:34:32 +0200 |
|---|---|---|
| committer | Vlastimil Babka (SUSE) <vbabka@kernel.org> | 2026-05-29 13:55:14 +0200 |
| commit | 90720e61fb7377b4ce1a3315b6382f8acc11d6d2 (patch) | |
| tree | 7fe37b19e06d5c5a67a44a06e4245d14e774a08d /include | |
| parent | 5d6919055dec134de3c40167a490f33c74c12581 (diff) | |
| download | linux-next-history-90720e61fb7377b4ce1a3315b6382f8acc11d6d2.tar.gz | |
mm/slab: improve kmem_cache_alloc_bulk
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@lst.de>
Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com> # skbuff
Link: https://patch.msgid.link/20260528093437.2519248-2-hch@lst.de
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/slab.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index 15a60b501b95b..24b244e63ba93 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -815,8 +815,10 @@ kmem_buckets *kmem_buckets_create(const char *name, slab_flags_t flags, */ void kmem_cache_free_bulk(struct kmem_cache *s, size_t size, void **p); -int kmem_cache_alloc_bulk_noprof(struct kmem_cache *s, gfp_t flags, size_t size, void **p); -#define kmem_cache_alloc_bulk(...) alloc_hooks(kmem_cache_alloc_bulk_noprof(__VA_ARGS__)) +bool kmem_cache_alloc_bulk_noprof(struct kmem_cache *s, gfp_t flags, + size_t size, void **p); +#define kmem_cache_alloc_bulk(...) \ + alloc_hooks(kmem_cache_alloc_bulk_noprof(__VA_ARGS__)) static __always_inline void kfree_bulk(size_t size, void **p) { |
