Re: [RFC PATCH v1 08/15] mm/sl[auo]b: cleanup kmalloc()
From: Hyeonggon Yoo
Date: Fri Apr 22 2022 - 08:46:23 EST
On Thu, Mar 24, 2022 at 06:46:34PM +0100, Vlastimil Babka wrote:
> On 3/8/22 12:41, Hyeonggon Yoo wrote:
> > Now that kmalloc() and kmalloc_node() do same job, make kmalloc()
> > wrapper of kmalloc_node().
> >
> > Remove kmalloc_trace() that is now unused. This patch makes slab
> > allocator use kmalloc_node tracepoints in kmalloc().
> >
> > Signed-off-by: Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx>
>
> Actually there are more things to fix than the commit log.
>
> > +#ifndef CONFIG_SLOB
> > +static __always_inline __alloc_size(1) void *kmalloc_node(size_t size, gfp_t flags, int node)
> > +{
> > + if (__builtin_constant_p(size)) {
> > + unsigned int index;
> > +
> > + if (size > KMALLOC_MAX_CACHE_SIZE)
> > + return kmalloc_large(size, flags);
>
> Should use kmalloc_large_node().
>
> > +
> > + index = kmalloc_index(size);
> > +
> > + if (!index)
> > + return ZERO_SIZE_PTR;
> > +
> > + return kmem_cache_alloc_node_trace(
> > + kmalloc_caches[kmalloc_type(flags)][index],
> > + flags, node, size);
> > + }
> > + return __kmalloc_node(size, flags, node);
> > +}
> > +#else
> > +static __always_inline __alloc_size(1) void *kmalloc_node(size_t size, gfp_t flags, int node)
> > +{
> > + if (__builtin_constant_p(size) && size > KMALLOC_MAX_CACHE_SIZE)
> > + return kmalloc_large(size, flags);
>
> And here.
>
Sorry for the mistake. did it in v2. thanks!
> > +
> > + return __kmalloc_node(size, flags, node);
> > +}
> > +#endif
--
Thanks,
Hyeonggon