Re: [PATCH v3 06/15] mm/slab_common: fold kmalloc_order_trace() into kmalloc_large()

From: Vlastimil Babka
Date: Mon Aug 01 2022 - 09:36:57 EST


On 8/1/22 15:26, Hyeonggon Yoo wrote:
> On Thu, Jul 28, 2022 at 05:23:29PM +0200, Vlastimil Babka wrote:
>> On 7/12/22 15:39, Hyeonggon Yoo wrote:
>> > There is no caller of kmalloc_order_trace() except kmalloc_large().
>> > Fold it into kmalloc_large() and remove kmalloc_order{,_trace}().
>> >
>> > Also add tracepoint in kmalloc_large() that was previously
>> > in kmalloc_order_trace().
>> >
>> > Signed-off-by: Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx>
>> > Reviewed-by: Vlastimil Babka <vbabka@xxxxxxx>
>>
>
> Thank you for review.
>
>> Hmm noticed a small change in how we call trace_kmalloc() which will now
>> include the __GFP_COMP.
>
> Good catch.
>
>> I think we could just call alloc_pages() from
>> kmalloc_large() with flags | __GFP_COMP instead of doing flags |=
>> __GFP_COMP; first.
>
> I'll consider that in next version.
>
>> AFAICS both kasan_kmalloc_large() and kmemleak_alloc()
>> will filter it out anyway.
>
> AFAIK not passing __GFP_COMP to both kasan_kmalloc_large()
> and kmemleak_alloc() will affect their behavior.

You mean "will NOT affect...", right?

> - kasan_kmalloc_large() only checks if flag has __GFP_DIRECT_RECLAIM,
> - kmemleak_alloc() only use it to allocate kmemleak_object from
> slab/pool, which does not require __GFP_COMP.
>
> simply calling
> alloc_pages() with flags | GFP_COMP
> kasan_kmalloc_large() with flags
> kmemleak_alloc() with flags
> trace_kmalloc() with flags
> will be okay.
>
> BTW this is fixed after patch 9.

Ah, right. __kmalloc_large_node_notrace() does the same flags |=
__GFP_COMP; but the tracepoint is outside and unaffected.