Re: [PATCH v3 22/35] mm/slab: enable slab allocation tagging for kmalloc and friends

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 16, 2024 at 05:52:34PM +0100, Vlastimil Babka wrote:
> 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@xxxxxxxxxx>
> > Co-developed-by: Kent Overstreet <kent.overstreet@xxxxxxxxx>
> > Signed-off-by: Kent Overstreet <kent.overstreet@xxxxxxxxx>
> 
> 
> > -}
> > +#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.

I think this is something we want to keep - we'll fix it




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux