[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YoPOhRctb8wwbmY5@carbon>
Date: Tue, 17 May 2022 09:34:13 -0700
From: Roman Gushchin <roman.gushchin@...ux.dev>
To: Hyeonggon Yoo <42.hyeyoo@...il.com>
Cc: YoMccU66auLAPEHa@...per.infradead.org,
Steven Rostedt <rostedt@...dmis.org>,
Shakeel Butt <shakeelb@...gle.com>,
Vlastimil Babka <vbabka@...e.cz>,
Matthew Wilcox <willy@...radead.org>, kernel@...nvz.org,
linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
Joonsoo Kim <iamjoonsoo.kim@....com>,
David Rientjes <rientjes@...gle.com>,
Pekka Enberg <penberg@...nel.org>,
Christoph Lameter <cl@...ux.com>,
Michal Hocko <mhocko@...e.com>
Subject: Re: [PATCH v2] tracing: add ACCOUNT flag for allocations from marked
slab caches
On Tue, May 17, 2022 at 08:59:31PM +0900, Hyeonggon Yoo wrote:
> On Tue, May 17, 2022 at 12:44:14PM +0300, Vasily Averin wrote:
> > dSlab caches marked with SLAB_ACCOUNT force accounting for every
> > allocation from this cache even if __GFP_ACCOUNT flag is not passed.
> > Unfortunately, at the moment this flag is not visible in ftrace output,
> > and this makes it difficult to analyze the accounted allocations.
> >
> > This patch adds the __GFP_ACCOUNT flag for allocations from slab caches
> > marked with SLAB_ACCOUNT to the ftrace output
> > ---
> > v2:
> > 1) handle kmem_cache_alloc_node() too, thanks to Shakeel
> > 2) rework kmem_cache_alloc* tracepoints to use cachep instead
> > of current cachep->*size parameters. Now kmalloc[_node] and
> > kmem_cache_alloc[_node] tracepoints do not use common template
> >
> > NB: kmem_cache_alloc_node tracepoint in SLOB cannot be switched to cachep,
> > therefore it was replaced by kmalloc_node tracepoint.
> > ---
> > VvS: is this acceptable? Maybe I should split this patch?
> >
> > Signed-off-by: Vasily Averin <vvs@...nvz.org>
> > ---
> > include/trace/events/kmem.h | 82 +++++++++++++++++++++++++++----------
> > mm/slab.c | 7 +---
> > mm/slab_common.c | 7 ++--
> > mm/slob.c | 10 ++---
> > mm/slub.c | 6 +--
> > 5 files changed, 71 insertions(+), 41 deletions(-)
> >
> > diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
> > index 71c141804222..3b4f96e4a607 100644
> > --- a/include/trace/events/kmem.h
> > +++ b/include/trace/events/kmem.h
> > @@ -9,7 +9,7 @@
> > #include <linux/tracepoint.h>
> > #include <trace/events/mmflags.h>
> >
> > -DECLARE_EVENT_CLASS(kmem_alloc,
> > +TRACE_EVENT(kmalloc,
> >
> > TP_PROTO(unsigned long call_site,
> > const void *ptr,
> > @@ -43,23 +43,41 @@ DECLARE_EVENT_CLASS(kmem_alloc,
> > show_gfp_flags(__entry->gfp_flags))
> > );
> >
> > -DEFINE_EVENT(kmem_alloc, kmalloc,
> > +TRACE_EVENT(kmem_cache_alloc,
> >
> > - TP_PROTO(unsigned long call_site, const void *ptr,
> > - size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
> > + TP_PROTO(unsigned long call_site,
> > + const void *ptr,
> > + struct kmem_cache *s,
> > + gfp_t gfp_flags),
> >
> > - TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
> > -);
> > + TP_ARGS(call_site, ptr, s, gfp_flags),
> >
> > -DEFINE_EVENT(kmem_alloc, kmem_cache_alloc,
> > + TP_STRUCT__entry(
> > + __field( unsigned long, call_site )
> > + __field( const void *, ptr )
> > + __field( size_t, bytes_req )
> > + __field( size_t, bytes_alloc )
> > + __field( unsigned long, gfp_flags )
> > + ),
> >
> > - TP_PROTO(unsigned long call_site, const void *ptr,
> > - size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
> > + TP_fast_assign(
> > + __entry->call_site = call_site;
> > + __entry->ptr = ptr;
> > + __entry->bytes_req = s->object_size;
> > + __entry->bytes_alloc = s->size;
> > + __entry->gfp_flags = (__force unsigned long)gfp_flags |
> > + (s->flags & SLAB_ACCOUNT ? __GFP_ACCOUNT : 0);
> > + ),
>
> This is a bit of lie. SLAB_ACCOUNT is not a gfp flag.
Alternatively we can add an explicit "accounted" boolean entry,
which will be set to true if the SLAB_ACCOUNT slab cache flag or
the __GFP_ACCOUNT gfp flag is present.
Powered by blists - more mailing lists