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 BCA80C433FE for ; Wed, 18 May 2022 09:38:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 387578D0001; Wed, 18 May 2022 05:38:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 336276B0075; Wed, 18 May 2022 05:38:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D7648D0001; Wed, 18 May 2022 05:38:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0EAAB6B0074 for ; Wed, 18 May 2022 05:38:31 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id D741A801F7 for ; Wed, 18 May 2022 09:38:30 +0000 (UTC) X-FDA: 79478363580.23.969A97B Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf16.hostedemail.com (Postfix) with ESMTP id E61C51800E6 for ; Wed, 18 May 2022 09:38:18 +0000 (UTC) Received: by mail-pf1-f180.google.com with SMTP id p8so1623844pfh.8 for ; Wed, 18 May 2022 02:38:30 -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=utRBzyDCBE6ZpXg0DP8VKm/o6gcA8n2XaPhwht6Z2eKJA7k9KhbthLrfIW9Fu2Cmaa 6eMJ33OxfbW4VG6GArJiiu0QhhFZ8wOFPL0lbDMMeq8Sr0XyXDD0UjgwkzhULFqIvqct oBEpzx26QVAYUbgwJ1IvIzfWoYJkGzUoNzmYbMbJ00ZqmICxo6eJOSiUf/GJFvht76Xa OLFoSlCNYFFN844QwfttbgR8ptOSTZiur+4CPpuLgIKS2RrgSUVFz0M2dENuOU3mUwrs rj1WaiA0oDeEpL/Q3PEoc741zNfYTQlaA+Z6GAqNbP0OfqTvUaJWgBpzTkoMfgovO8sA CFyQ== X-Gm-Message-State: AOAM530TXb02Fpzk+dWJnBVJagd39p7S5gzq5n5AYhBg27H++iVVAuKy PGNeYiIAZS5Satl+pMicN0w= X-Google-Smtp-Source: ABdhPJxyMHfoaAJAqXH7xBrBPiVRRQnZMaLapYQ39nTZXZxhPB6gi7p/Nr3FIcx7+mZ+3HlJuRvIZA== 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: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=mMjGOE14; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E61C51800E6 X-Rspam-User: X-Stat-Signature: bys9ayg7b18ez61tkzh939zmzfkyo9i3 X-HE-Tag: 1652866698-762537 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 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