[PATCH v11 03/13] lib/group_cpus: Add group_mask_cpus_evenly()

Aaron Tomlin atomlin at atomlin.com
Wed Apr 22 10:47:39 PDT 2026


On Mon, Apr 20, 2026 at 03:11:52PM +0200, Marco Crivellari wrote:
> Without it, I guess the kmalloc() in `group_mask_cpus_evenly()` will
> return ZERO_SIZE_PTR:

Hi Marco,

Thank you for reviewing the patch.

You are correct. If numgrps is 0, __do_kmalloc_node() will 
return ZERO_SIZE_PTR.

> Should this check be added or it is not needed? Or maybe rely on `ZERO_OR_NULL_PTR()` ?

 - File: mm/slub.c

    5275 static __always_inline
    5276 void *__do_kmalloc_node(size_t size, kmem_buckets *b, gfp_t flags, int node,   
    5277                         unsigned long caller)
    5278 {  
    5279         struct kmem_cache *s;
    5280         void *ret;
     :
    5289         if (unlikely(!size))
    5290                 return ZERO_SIZE_PTR;
     :
    5298 }

Regarding your suggestion: rather than relying on ZERO_OR_NULL_PTR() after
the fact, I think it is much cleaner to just add the early exit at the very
beginning of the function, exactly as group_cpus_evenly() does. It avoids
the allocator path entirely.


Kind regards,
-- 
Aaron Tomlin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20260422/6ae3dc54/attachment.sig>


More information about the Linux-nvme mailing list