Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp130068iob; Tue, 17 May 2022 21:14:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmd5x+JVqKIy1gdjc3QaWUhrd9LNZ/5GQvHZjK1illy4zPAz1mKAC0/eSI8XX8rjg1bUjE X-Received: by 2002:a17:90a:6342:b0:1df:763d:4eca with SMTP id v2-20020a17090a634200b001df763d4ecamr9996153pjs.85.1652847267595; Tue, 17 May 2022 21:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652847267; cv=none; d=google.com; s=arc-20160816; b=Fp/oYipkHGna5GXQ0VOk+6Wp8xwWQeTKrsw7+fQvKSts5qKbFAEkLHEPeERcE8dnUc X4CAJPyMDUUVLho09RVzXAMRTSYQzlEvM89Tm/AHPm/kfx8a9VhdbHGRKko0GMR7ADf+ fVDo4UyGjOQLcqKIuJ6azE09pkBnIm7lofTTUm6Ccagv6PtoM/3N8At/ttju27AAhSQ8 hiPLXlTI+xlLw8DigQPM8J3lE88UEE1aVrm3/3F21a3i2vWgGU7IyoHDQzXal84pX6fi 39/9/SRW4jf+5b3HEt9aEB+CHv3X6totLOArPGO7HfuJV/cQmq9Hz6XHl5DcK218KvYK xYLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=i+1owZFK8nU0fwHBj/A4cUjEeBNGR4oV2Kr1hZIIDMM=; b=jflQ58+e7DaucqD/HNJ7RE5mT3LUg3U0+Ma4MLoXsyI11zCG9qDJPuX7aQyXrpP87t DfBjDA7CStkjQhqU/feB6qT/c9ucQU53msfH3LQmwIyXcgJM0Eun4MzsuStof4AlVKTr qUasBCu0YfNOxeIv3JnNTbrYMMu8D7RWu/N8Sd+zi18INupaogL7FWOILGWU6U/52iaQ kcnnmePpkUcmIhMOI9FKf2U5hxtliwb+Jsj0pgulk0jdc8sdOSgzFGWXUnDGyZSNDJwR dW4Hf9U5dX+sQy8UEZRBBIjGWRLsicKVpqYFr8du+c7tMz/xae5fjisDxzevpU1Zu5LX Q9SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=P9cHZGK6; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t186-20020a632dc3000000b003ab1a126de4si1082368pgt.65.2022.05.17.21.14.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 21:14:27 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=P9cHZGK6; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1138D6CAA3; Tue, 17 May 2022 20:43:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350937AbiEQQe1 (ORCPT + 99 others); Tue, 17 May 2022 12:34:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350921AbiEQQeY (ORCPT ); Tue, 17 May 2022 12:34:24 -0400 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EE084ECC1 for ; Tue, 17 May 2022 09:34:21 -0700 (PDT) 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-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.