Re: [PATCH] tracing: add ACCOUNT flag for allocations from marked slab caches

Vasily Averin
2022-05-17T03:32:34Z

On 5/16/22 22:10, Shakeel Butt wrote:
> On Mon, May 16, 2022 at 11:53 AM Vasily Averin <vvs@openvz.org> wrote:

>> +++ b/mm/slab.c
>> @@ -3492,6 +3492,9 @@ void *__kmem_cache_alloc_lru(struct kmem_cache *cachep, struct list_lru *lru,
>
> What about kmem_cache_alloc_node()?

Thank you for the hint, I was inaccurate and missed *_node.

>> {
>> void *ret = slab_alloc(cachep, lru, flags, cachep->object_size, _RET_IP_);
>>
>> + if (cachep->flags & SLAB_ACCOUNT)
>
> Should this 'if' be unlikely() or should we trace cachep->flags
> explicitly to avoid this branch altogether?

In general output of cachep->flags can be useful, but at the moment
I am only interested in SLAB_ACCOUNT flag and in any case I would
prefer to translate it to GFP_ACCOUNT.
So I'm going to use unlikely() in v2 patch version.

>> + flags |= __GFP_ACCOUNT;
>> +
>> trace_kmem_cache_alloc(_RET_IP_, ret,
>> cachep->object_size, cachep->size, flags);
>>

Thank you,
Vasily Averin