Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp77857lfo; Tue, 17 May 2022 16:32:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOrAz4ydj8wm3QddF7puSsH+i/aKeskLoQr1Ol74wDtjZ8vO/l0TW99qzF04bX5PkQtc2e X-Received: by 2002:a17:90a:9311:b0:1dc:8d06:eb1b with SMTP id p17-20020a17090a931100b001dc8d06eb1bmr27260842pjo.41.1652830363676; Tue, 17 May 2022 16:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652830363; cv=none; d=google.com; s=arc-20160816; b=0eJHGhofmBxoUx20LqxkQ1AnNea1N7/LdRoEt5e7DIhhXUGu9resW3R0Ts1HMDXyoG aeTokH2hfP5+POttagXq7uyfleL5sd0KgQPEeDyUzl31rv+Kvv6GnMQEBdskPqVvVrpA vPtnt3fc2udkcJ7qbhRaubFunYFCp7kv1P76Wxckbg1YO1j0H/DC6QvUSUwFpkeXDVCc xdI2+yORnpy8MyM9xus+WIlfs/uHqYEoxzoj0vkFEcaiaO8DnAkg2+GzEcCrALUQjT21 d4A4CTWVA5T+UohCGP8m+9dYajzWETu2NNtg9GIQu1cb61rI6TJWofACR9RtwFEfelww wW8w== 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:date:dkim-signature; bh=+EPish+mrSvGMlugaYsp/hj+HbUv1tOHcvdoYDFMU50=; b=aGlC3f/O5OYldcPXnF81MambTeCzVIx45slVi8HbvvGUl6HmwJBkbQRjlIgNGw/HPS tzmyQPTUUiiX7mJk+jQw+GcCOgiMYviHEjvP0HUGxu8aUm6UaWDEevSxJtZFInHODNwq tMGKRWwz5zipB8yOcd+acQ3XD28UJX16AmMCr0vmHSV/zJqHejqk5LU8qiWGecbRjby4 BqZPI/Lg0EK+71+hYyzLr13ttZeURXHR5qQxeicmtwMQmBI/ctL7RMT/4+w6nVvwmsvO k8UbGRoIdtnkJCAu8QPIBjzA4sgii4peua5AiBdAkCxhYH9q3jxjro2v8z+qu8Txb6Fo lh8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=U+ft39WX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a170902f68900b0015d9e670bfesi626107plg.554.2022.05.17.16.31.51; Tue, 17 May 2022 16:32:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=U+ft39WX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347745AbiEQN3R (ORCPT + 99 others); Tue, 17 May 2022 09:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347799AbiEQN3K (ORCPT ); Tue, 17 May 2022 09:29:10 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 474774705F for ; Tue, 17 May 2022 06:29:05 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id a11so16901241pff.1 for ; Tue, 17 May 2022 06:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+EPish+mrSvGMlugaYsp/hj+HbUv1tOHcvdoYDFMU50=; b=U+ft39WXLfz5BURlNF2xfDGqiD8mKFTLSuSjjVrY8GNFrAqi5aiZmFzWiyJD8jF7Kh i8pryLD3i5Ge9ofKiKMwmLEHhBWlPZ10Se/4QibleB3rD6RHVLenBF3DAXzYiRaUn6/c 86j/iVF2UfZK80TBSsLyjzv3EnRKrlcrTJkSfqQgmUL3A/R08e3kKiGH4uOjWjrgfzA9 GBogXDfi0Fwj/yQXdjMYj/ss83Pin8XSdgv65RgoWvuYgOq6bHj2ZgwYrSQ8Vrlcy6vi ODxTf3OKG6amIPDJeIj7daN7puClDTJkBV91jS9+B+twGmHFlMOyDSnb00a6oOjKXqsL OGGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+EPish+mrSvGMlugaYsp/hj+HbUv1tOHcvdoYDFMU50=; b=piPNh1qv3MNDQlCwe6l8WvpkMAWE6Yhl/ZxF3uomNZ5RALXg44dp2LVH4T2AB0hFJ+ p/h9kbHWmPNWZK1001+CKN+gtwI+yr2rkGvcPDXX/dFLkjN9uwWxDYeZM5InsxtNPFdr KZ0Figs/6hjIPowJmWdAoIADhncxK/F9LhuUnUmeD7MMQRHp/Hww0QgA/631PoEyrGNP Fz3KSCehxjglMtuvnMOTpKTBzrEoEtoyQ4969d+6gbVLRJt+dtq3beI2E6+alfL6gmcy 9STzI6BK06rdQedFUlhGptJZGazMsi98YGsov2rWrUHAQfGNweQmLNT01mno5hQgqOSl Of/A== X-Gm-Message-State: AOAM533WZdHudHkbJ7iUuur10t3IdlayZX1mNsqNLzrqhe0OFPTQvd96 Fx58rFAf6actkcinlvPrvfdlIw== X-Received: by 2002:a63:8ac1:0:b0:3db:515d:76d2 with SMTP id y184-20020a638ac1000000b003db515d76d2mr20034744pgd.152.1652794144749; Tue, 17 May 2022 06:29:04 -0700 (PDT) Received: from localhost ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id c2-20020a62f842000000b0050dc762813csm9068864pfm.22.2022.05.17.06.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 06:29:04 -0700 (PDT) Date: Tue, 17 May 2022 21:29:01 +0800 From: Muchun Song To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: YoMccU66auLAPEHa@casper.infradead.org, Steven Rostedt , Shakeel Butt , Roman Gushchin , 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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. > Maybe it is not a problem since the functionalities of SLAB_ACCOUNT and __GFP_ACCOUNT are similar. > IMO the problem here is that we don't know which cache kernel is allocating > from. What about just printing name of cache and remove bytes_req, > bytes_alloc? Is it a problem? Because we have changed the behavior to users. Should we treat the tracepoint as a stable API to users? If so, I think we should not change the parameter of this tracepoint. Maybe I am wrong, just some thoughts from me. Thanks. > > And then you can check if the cache uses SLAB_ACCOUNT or not. >