Re: [PATCH v3] tracing: add 'accounted' entry into output of allocation tracepoints

From: Vasily Averin
Date: Thu May 19 2022 - 07:36:04 EST


On 5/18/22 23:04, Steven Rostedt wrote:
> On Wed, 18 May 2022 09:24:51 +0300
> Vasily Averin <vvs@xxxxxxxxxx> wrote:
>
> FYI, the subject should be something like: mm/tracing:
> Because "tracing:" is reserved for tracing infrastructure updates.

Thank you for noticing.

>> @@ -33,42 +35,46 @@ DECLARE_EVENT_CLASS(kmem_alloc,
>> __entry->bytes_req = bytes_req;
>> __entry->bytes_alloc = bytes_alloc;
>> __entry->gfp_flags = (__force unsigned long)gfp_flags;
>> + __entry->accounted = (gfp_flags & __GFP_ACCOUNT) ||
>> + (s && s->flags & SLAB_ACCOUNT);
>
> Now you could make this even faster in the fast path and save just the
> s->flags.
>
> __entry->sflags = s ? s->flags : 0;
>
>> ),
>>
>> - TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
>> + TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s accounted=%s",
>> (void *)__entry->call_site,
>> __entry->ptr,
>> __entry->bytes_req,
>> __entry->bytes_alloc,
>> - show_gfp_flags(__entry->gfp_flags))
>> + show_gfp_flags(__entry->gfp_flags),
>> + __entry->accounted ? "true" : "false")
>
> And then have: "accounted=%s":
>
> (__entry->gfp_flags & __GFP_ACCOUNT) ||
> (__entry->sflags & SLAB_ACCOUNT) ? "true" : "false"

Unfortunately this returns back sparse warnings about bitwise gfp_t and slab_flags_t casts.
Could you please explain why your variant is faster?

Thank you,
Vasily Averin