From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CAB0C433EF for ; Tue, 17 May 2022 16:34:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC24A6B0072; Tue, 17 May 2022 12:34:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C4A266B0073; Tue, 17 May 2022 12:34:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEAAE6B0074; Tue, 17 May 2022 12:34:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9AD5C6B0072 for ; Tue, 17 May 2022 12:34:22 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6E99633E7F for ; Tue, 17 May 2022 16:34:22 +0000 (UTC) X-FDA: 79475782764.29.9D4E967 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by imf15.hostedemail.com (Postfix) with ESMTP id 19AC2A00C6 for ; Tue, 17 May 2022 16:34:05 +0000 (UTC) Date: Tue, 17 May 2022 09:34:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1652805259; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=i+1owZFK8nU0fwHBj/A4cUjEeBNGR4oV2Kr1hZIIDMM=; b=P9cHZGK6MAYhSL1AJypHi6j/SMLqs54Mbv1wNua/gCwihjvji3D2Q1A5gApoiUP4OVsA3+ erf3CLdA4SqVfOzdJlYoEwfPiF/2jK0t3WxqrlrMfaSlkY1pjViuFFQJrClXp0DUpG9Udz WL18SNqzDto73cbQTdDKN6ExUyiobas= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: YoMccU66auLAPEHa@casper.infradead.org, Steven Rostedt , Shakeel Butt , Vlastimil Babka , Matthew Wilcox , kernel@openvz.org, linux-kernel@vger.kernel.org, Ingo Molnar , Andrew Morton , linux-mm@kvack.org, Joonsoo Kim , David Rientjes , Pekka Enberg , Christoph Lameter , Michal Hocko Subject: Re: [PATCH v2] tracing: add ACCOUNT flag for allocations from marked slab caches Message-ID: References: <8ef9de6a-7497-07f7-852c-befcc3843771@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Stat-Signature: 8tq4pinascp6jcf4n3wtohf9jr7u38y7 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 19AC2A00C6 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=P9cHZGK6; spf=pass (imf15.hostedemail.com: domain of roman.gushchin@linux.dev designates 94.23.1.103 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspam-User: X-HE-Tag: 1652805245-524298 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 > > --- > > 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 > > #include > > > > -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.