| Date | Fri, 16 Feb 2024 17:52:34 +0100 | Subject | Re: [PATCH v3 22/35] mm/slab: enable slab allocation tagging for kmalloc and friends | From | Vlastimil Babka <> |
| |
On 2/12/24 22:39, Suren Baghdasaryan wrote: > Redefine kmalloc, krealloc, kzalloc, kcalloc, etc. to record allocations > and deallocations done by these functions. > > Signed-off-by: Suren Baghdasaryan <surenb@google.com> > Co-developed-by: Kent Overstreet <kent.overstreet@linux.dev> > Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
> -} > +#define kvmalloc(_size, _flags) kvmalloc_node(_size, _flags, NUMA_NO_NODE) > +#define kvzalloc(_size, _flags) kvmalloc(_size, _flags|__GFP_ZERO) > > -static inline __alloc_size(1, 2) void *kvmalloc_array(size_t n, size_t size, gfp_t flags)
This has __alloc_size(1, 2)
> -{ > - size_t bytes; > - > - if (unlikely(check_mul_overflow(n, size, &bytes))) > - return NULL; > +#define kvzalloc_node(_size, _flags, _node) kvmalloc_node(_size, _flags|__GFP_ZERO, _node) > > - return kvmalloc(bytes, flags); > -} > +#define kvmalloc_array(_n, _size, _flags) \ > +({ \ > + size_t _bytes; \ > + \ > + !check_mul_overflow(_n, _size, &_bytes) ? kvmalloc(_bytes, _flags) : NULL; \ > +})
But with the calculation now done in a macro, that's gone?
> -static inline __alloc_size(1, 2) void *kvcalloc(size_t n, size_t size, gfp_t flags)
Same here...
> -{ > - return kvmalloc_array(n, size, flags | __GFP_ZERO); > -} > +#define kvcalloc(_n, _size, _flags) kvmalloc_array(_n, _size, _flags|__GFP_ZERO)
.. transitively?
But that's for Kees to review, I'm just not sure if he missed it or it's fine.
|