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 95739C433F5 for ; Tue, 31 May 2022 11:47:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C23AE6B0072; Tue, 31 May 2022 07:47:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BD0426B0073; Tue, 31 May 2022 07:47:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A946C6B0074; Tue, 31 May 2022 07:47:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 979726B0072 for ; Tue, 31 May 2022 07:47:01 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 6D9598030B for ; Tue, 31 May 2022 11:47:01 +0000 (UTC) X-FDA: 79525861842.17.94CFBC8 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) by imf28.hostedemail.com (Postfix) with ESMTP id 77692C0058 for ; Tue, 31 May 2022 11:46:20 +0000 (UTC) Received: by mail-io1-f42.google.com with SMTP id b4so13778902iog.11 for ; Tue, 31 May 2022 04:46:58 -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=93uhBt8Wzct8J4+CdbYjcgwsc3kwGGU4sNgYP7SDugU=; b=Ok/wAPTVkx7ULmfKE4buubCQQgiOQrL+1p2aGP6w95FzI5yXyJEl3p1oat5ye85LMe 8MrC86gVZKkFsUoWalAUpFCHN3p2mBSk4Pl9FybWQiCWOXyXf6hEBD2OtTiSoKH7PCJ6 MDIXuaxzHxe+Xvn/ucv70+hs8apG5dTtueutariyx7mbE5Iy9jK08VDKtZnNK14gqREa CNVDlxagBgDWqwyv/95OZFh0z5XiF/6+w1nRxd7hZhMqiz+dIA11Q/8d8kHYaXwsIsT+ mqjpmrt97Fu8jzSx+6khcBe7EEQwUrzTEYEvj+fCSmoX8GOS2z2bdkpkFe+EdDyroSk9 ORpA== 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=93uhBt8Wzct8J4+CdbYjcgwsc3kwGGU4sNgYP7SDugU=; b=qzzPlKjdc/EwWjSAeGUMeWiPSocrcn94YP9n8bdh7qdaM5MCcML6p1Vr17+sZqgaq4 wIaz+BjK9jd8EkypqZarMd4lk9mGQv4Y83tpcL24GoFeQPNbDhHatpv/+wQKnZ2oe5Sp FnYC3nbUAlpiH7M6MZJ+PMCVG8i5SsOsITSnjrgxUXStfUmdfh6RlID4Urs5aY6LUpps uFfCAIxAe/wJYEsf2ACgvolNXu5hmclvGHrbYqpUAs4k83+bg/6ZuGp8b4D2NbFDrZbX JFoNEBBfYjwgXZMcvQfrANRa/hbsZZ2LPiViQ/U7bbvUIBfcy+gWT7A85tT8n7i0cIto Pq1A== X-Gm-Message-State: AOAM530Eom8fkx9XuvY0tvrW/D0EasldG2Uj2l4aVkFwDobra0yD3avs WFaboL/NjKPswar5wMeTh6Q= X-Google-Smtp-Source: ABdhPJxV2VhIXeWm6sXONG+DapOQ+XeGntmxg+hgJTxxViQd6k6Owy195rdwhsURjD9ZZJN4XnvmNw== X-Received: by 2002:a5d:9d06:0:b0:65e:5162:475b with SMTP id j6-20020a5d9d06000000b0065e5162475bmr23574835ioj.149.1653997617554; Tue, 31 May 2022 04:46:57 -0700 (PDT) Received: from n2.us-central1-a.c.spheric-algebra-350919.internal (151.16.70.34.bc.googleusercontent.com. [34.70.16.151]) by smtp.gmail.com with ESMTPSA id c18-20020a5ea912000000b00665754e45c2sm4023663iod.24.2022.05.31.04.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 04:46:56 -0700 (PDT) Date: Tue, 31 May 2022 11:46:55 +0000 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Vasily Averin Cc: Vlastimil Babka , kernel@openvz.org, linux-kernel@vger.kernel.org, Steven Rostedt , Ingo Molnar , Andrew Morton , linux-mm@kvack.org, Shakeel Butt , Roman Gushchin , Matthew Wilcox , Joonsoo Kim , David Rientjes , Pekka Enberg , Christoph Lameter , Michal Hocko , Muchun Song Subject: Re: [PATCH v5] tracing: add 'accounted' entry into output of allocation tracepoints Message-ID: References: <80bcb043-3782-1d81-d8a2-4bdcb213cf30@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <80bcb043-3782-1d81-d8a2-4bdcb213cf30@openvz.org> X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 77692C0058 X-Stat-Signature: spi3atchh455uqub8ckb5fn315w7bo63 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Ok/wAPTV"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.166.42 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com X-Rspam-User: X-HE-Tag: 1653997580-724157 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 Mon, May 30, 2022 at 10:47:26AM +0300, Vasily Averin wrote: > Slab 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 boolean "accounted" entry into trace output, > and set it to 'true' for calls used __GFP_ACCOUNT flag and > for allocations from caches marked with SLAB_ACCOUNT. > > Signed-off-by: Vasily Averin > Acked-by: Shakeel Butt > Acked-by: Roman Gushchin > > --- > v5: > 1) re-based to current upstream (v5.18-11267-gb00ed48bb0a7) > 2) added "Acked-by" from Roman > 3) re-addressed to slab maintaiers > > v4: > 1) replaced in patch descripion: "accounted" instead of "allocated" > 2) added "Acked-by" from Shakeel, > 3) re-addressed to akpm@ > > v3: > 1) rework kmem_cache_alloc* tracepoints once again, > added struct kmem_cache argument into existing templates, > thanks to Matthew Wilcox > 2) updated according trace_* calls > 3) added boolean "allocated" entry into trace output, > thanks to Roman > 4) updated patch subject and description > > v2: > 1) handle kmem_cache_alloc_node(), thanks to Shakeel > 2) rework kmem_cache_alloc* tracepoints to use cachep instead > of current cachep->*size parameters. > NB: kmem_cache_alloc_node tracepoint in SLOB cannot use cachep, > and therefore it was replaced by kmalloc_node. > --- > include/trace/events/kmem.h | 38 +++++++++++++++++++++++-------------- > mm/slab.c | 10 +++++----- > mm/slab_common.c | 9 ++++----- > mm/slob.c | 8 ++++---- > mm/slub.c | 20 +++++++++---------- > 5 files changed, 47 insertions(+), 38 deletions(-) > Looks good to me. Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> a small comment: > > TP_fast_assign( > @@ -33,42 +35,46 @@ DECLARE_EVENT_CLASS(kmem_alloc, > __entry->bytes_req = bytes_req; > __entry->bytes_alloc = bytes_alloc; > __entry->gfp_flags = (__force unsigned long)gfp_flags; > + __entry->accounted = (gfp_flags & __GFP_ACCOUNT) || > + (s && s->flags & SLAB_ACCOUNT); > ), > It doesn't make sense for SLOB to print accounted=true because SLOB does not support object accounting. > DEFINE_EVENT(kmem_alloc, kmalloc, > > - TP_PROTO(unsigned long call_site, const void *ptr, > + TP_PROTO(unsigned long call_site, const void *ptr, struct kmem_cache *s, > size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags), > > - TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags) > + TP_ARGS(call_site, ptr, s, bytes_req, bytes_alloc, gfp_flags) > ); > > DEFINE_EVENT(kmem_alloc, kmem_cache_alloc, > > - TP_PROTO(unsigned long call_site, const void *ptr, > + TP_PROTO(unsigned long call_site, const void *ptr, struct kmem_cache *s, > size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags), > > - TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags) > + TP_ARGS(call_site, ptr, s, bytes_req, bytes_alloc, gfp_flags) > ); > > DECLARE_EVENT_CLASS(kmem_alloc_node, > > TP_PROTO(unsigned long call_site, > const void *ptr, > + struct kmem_cache *s, > size_t bytes_req, > size_t bytes_alloc, > gfp_t gfp_flags, > int node), > > - TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node), > + TP_ARGS(call_site, ptr, s, bytes_req, bytes_alloc, gfp_flags, node), > > TP_STRUCT__entry( > __field( unsigned long, call_site ) > @@ -77,6 +83,7 @@ DECLARE_EVENT_CLASS(kmem_alloc_node, > __field( size_t, bytes_alloc ) > __field( unsigned long, gfp_flags ) > __field( int, node ) > + __field( bool, accounted ) > ), > > TP_fast_assign( > @@ -86,33 +93,36 @@ DECLARE_EVENT_CLASS(kmem_alloc_node, > __entry->bytes_alloc = bytes_alloc; > __entry->gfp_flags = (__force unsigned long)gfp_flags; > __entry->node = node; > + __entry->accounted = (gfp_flags & __GFP_ACCOUNT) || > + (s && s->flags & SLAB_ACCOUNT); > ),