Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp316953iob; Wed, 18 May 2022 02:54:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb4zB+jWL4mf2UIF+qsu7S3My1gnA6eov2vKX9m0emABn1dJw6546x3KpijgR1cfhq1TWE X-Received: by 2002:a05:6a00:4385:b0:510:4422:aa3a with SMTP id bt5-20020a056a00438500b005104422aa3amr26774107pfb.16.1652867642625; Wed, 18 May 2022 02:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652867642; cv=none; d=google.com; s=arc-20160816; b=UxOJDw+UGWI4s752aP3sfcFztmzjsrxgM0+Svg/3yp2rMCn4kjkqbchgHWkroNOWU0 QTPOEB7P3Tf2vFPuIQ/wMEPqpP+AqAW+VYAgWXg66P1a9TLV4syeVxS4KMvj7nyLeHRC hZcj14FXVoBSrAd8SPNb4riDUMYkdGGPE9UlBGEnr1sioOrpxclsIL0H9HoM9Jhx+/GT g0L1r0qMHBTu+SixiGBlJqdEqrtmrIjoN8nqDcDIkaWf9ylzxrYyH9MIWrqAJ0ugJkxi gt2UTC2nKW+ezCmyy0eWYnBYydeiKzHcD38EXnYbKkiXErMLoQae+fpLTUBg6VDL+rW7 uh4A== 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=iLhbF+efrgTZiHGNlx8ucyplxCC7hAHiuO4dJxu3EBQ=; b=zfl7pNTeQIA0Hvu58cKkqfITS48CdkZispQfyfT/WpnnZQS8HM9QVmk4aKmrhcX2Hz suXyRw7U9FPT4epdpm+BMHwHIoZVO4ud32kwpL2XjAzRBPC/4hc6FDn8ZmOGvrBBoUQT 0zvGhhXGRf+znZRs7pllxZmRU6mapow9+X90N0YUYKYCyW8EqSkSfcstBK18Po2myCkV P7NlSN/Sfu8p0be0GKwxoDIoHszr6djhS/y8x1NdvWff5KGOTrT0PB8Z5bWsNoyTy0JA QCyTiGzbhTrMwQ0t7dqPrNOT4Icc9Bru6NKruSiVT56Aq/RARjO5XhC16Z3fxMGHN4nP 8xJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mMjGOE14; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t26-20020a056a00139a00b004fa7782f609si2986777pfg.24.2022.05.18.02.54.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 02:54:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mMjGOE14; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D2D114B657; Wed, 18 May 2022 02:40:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234362AbiERJjR (ORCPT + 99 others); Wed, 18 May 2022 05:39:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234372AbiERJib (ORCPT ); Wed, 18 May 2022 05:38:31 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9298986E9 for ; Wed, 18 May 2022 02:38:29 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id r71so1689494pgr.0 for ; Wed, 18 May 2022 02:38:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=iLhbF+efrgTZiHGNlx8ucyplxCC7hAHiuO4dJxu3EBQ=; b=mMjGOE14sdNldlmv/5r9sCKhwXj8srVWREHJKNt8rLdaTCta8o6qPqBR6pQblqdvEW WribvmFzvTAclCr3jCfvYXg9ZeDcES2h7LHJBcch/cdlsAxH6EMd1qbJpke4vH9j9iKf 3+opQQ1XwztckjNsjNm7qx/CA6j7K3rkV+tmrxpe6l1rdjNZmsvxuFQRqERm72Fef4ml 3nyDQZ55Gn3qFtQdAQz7027GbZis5OcQYgpX57EsxXc7B0kOuV0WdHhr/5UMergRloSM wc+EXQbjzcRyQJDBBM2CO4D0RTubWr2dJbl/rq3lQXLXM0xKYDm1YIXYeK+bCTVXQA02 y4Pw== 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=iLhbF+efrgTZiHGNlx8ucyplxCC7hAHiuO4dJxu3EBQ=; b=spFl6wqDPZqdp9/OmurYDNOKCRC5I2ulV4QX3jgtfL+VVHM+M22hKMtqrxxBNHR3K4 nSiTK+5N4Lm684S/egF/i3uoqf609Hox0ekbOz8iqVMqXjX3bqyRjspQ2poN9QWAIpWm fKT2+4DEZu0KchBUQx8dFUIDBMFBVLBq7P4eSS76FeNqMMP1ECqY2Po5wHveLXpqBW/0 CLDCYuMqoAOk3jCG5lGoVp+8m5MqjM9vWN1vEG0IR6H5sLBA3NLa9ZyeyYuoyxrd51L2 wt0pxB4H/gnJhLqi30UB5JFrA1kXMl2fSnZ4llBX0C7C9F948W78cMSrJwrrCfMaeFrM csWA== X-Gm-Message-State: AOAM531LSZSxxYYgFxfWcWtsdZmf6b0PY0MmyE5hVvZhqpWuUi8w3F3Q vmyntz0n1a64xx7G7C3hBEEsmyEKNAg= X-Received: by 2002:a63:a23:0:b0:3f5:e1e4:ae3f with SMTP id 35-20020a630a23000000b003f5e1e4ae3fmr4352431pgk.110.1652866709438; Wed, 18 May 2022 02:38:29 -0700 (PDT) Received: from hyeyoo ([114.29.24.243]) by smtp.gmail.com with ESMTPSA id v24-20020a170902e8d800b0015f086e4aa5sm1178794plg.291.2022.05.18.02.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 02:38:28 -0700 (PDT) Date: Wed, 18 May 2022 18:38:21 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Roman Gushchin 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-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,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 09:34:13AM -0700, Roman Gushchin wrote: > 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. Or what about adding something like SlabAccounted or MemAccounted in /proc/meminfo if what he want to know is total amount of memory accounted? -- Thanks, Hyeonggon