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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8E31C7EE2E for ; Fri, 9 Jun 2023 15:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CDQ5PEHh35+NO4CickkMVm6xN9tbJOfpt8G9LMTFxqM=; b=H2C4Ls5QbTW5bb u5c5t7gKpMRhFOtrasgAg9YPgwVEgl/Vekm6EqQ7z4XRfQiWJp/wMh5+D/kqyuMv2RbLIUedso06j kVaaCAtELT1Jq5YfV0R84DjLnTZCgK6XtXtiGXMiXCiHrMioEKsjEeq+nCipeBcwI6x9FcyqbgEpX dt8bXqxaYdK3bDT4IiPrk+VraPD8e2nVny5H5qiZ2yUbuYn9eQWk5ZYBImUWB5509WQbV3Cx6a5nL cLTtwSFn998VacTXQ/efIrXnuDp1cpYtWeHBY2rCSqnFsI+KeaczuUZGdGY8n5W+DghZFMWb6H27R 5RLJtLRgOY+hpI4cvcrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7eOS-00DWGt-0n; Fri, 09 Jun 2023 15:51:16 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7eON-00DWF4-0X for linux-arm-kernel@bombadil.infradead.org; Fri, 09 Jun 2023 15:51:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=83rnEPvPujOX8bCW0XTxK24uVzVcAFGADX+s0t+48ro=; b=d0rzcGx6qAHpYbYEPkz55+cA4W wRRrtnf2+z6D5T5M/bbN8Sg7mAlhxCQAKj3lAjLiasq1/8CdpjfzQAjadT+ferLIHM+l+23HCazWx Ps3GJqYEFV9uqUoOoXIM88EubNrI/SESYHYMmf5ilyyIxCcdaVYuCrjSa6zpp6D0GV+oMOip2Zl7F evk+qfQcHB5jL4nmY4ZJuDfbVmyQDtGgrPXyV3piELjR03rhZybhTeKsZp7bPmhypvIauYDQPTgQO h7S04YtYPt/Mo8SFrclFloOsiaXP3nsJGpo+a0w1YVujiwo6BxYU0O9E85iOrcljjHYhQX07IVx9j VP7rDePA==; Received: from [187.19.173.165] (helo=quaco.ghostprotocols.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q7cvz-007CkM-0d; Fri, 09 Jun 2023 14:17:47 +0000 Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 20E2140692; Fri, 9 Jun 2023 11:17:42 -0300 (-03) Date: Fri, 9 Jun 2023 11:17:42 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Suzuki K Poulose , "Naveen N. Rao" , Kan Liang , German Gomez , Ali Saidi , Jing Zhang , Athira Rajeev , Miguel Ojeda , ye xingchen , Liam Howlett , Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong , K Prateek Nayak , Changbin Du , Ravi Bangoria , Sean Christopherson , Andi Kleen , "Steinar H. Gunderson" , Yuan Can , Brian Robbins , liuwenyu , Ivan Babrou , Fangrui Song , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, coresight@lists.linaro.org Subject: Re: [PATCH v2 04/26] perf maps: Make delete static, always use put Message-ID: References: <20230608232823.4027869-1-irogers@google.com> <20230608232823.4027869-5-irogers@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230608232823.4027869-5-irogers@google.com> X-Url: http://acmel.wordpress.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Em Thu, Jun 08, 2023 at 04:28:01PM -0700, Ian Rogers escreveu: > Address/leak sanitizer with reference count checking can identify the > location of leaks, so use put rather than delete to avoid free-ing > memory when the reference count is >1. Add maps__zput to ensure the > variable is cleared. Applied. - Arnaldo > Signed-off-by: Ian Rogers > --- > tools/perf/tests/maps.c | 2 +- > tools/perf/util/machine.c | 2 +- > tools/perf/util/maps.c | 2 +- > tools/perf/util/maps.h | 9 ++++++++- > 4 files changed, 11 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/tests/maps.c b/tools/perf/tests/maps.c > index 8c0eb5cf8bb5..5bb1123a91a7 100644 > --- a/tools/perf/tests/maps.c > +++ b/tools/perf/tests/maps.c > @@ -140,7 +140,7 @@ static int test__maps__merge_in(struct test_suite *t __maybe_unused, int subtest > ret = check_maps(merged3, ARRAY_SIZE(merged3), maps); > TEST_ASSERT_VAL("merge check failed", !ret); > > - maps__delete(maps); > + maps__zput(maps); > return TEST_OK; > } > > diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c > index 5d34d60a0045..8972c852d3bd 100644 > --- a/tools/perf/util/machine.c > +++ b/tools/perf/util/machine.c > @@ -248,7 +248,7 @@ void machine__exit(struct machine *machine) > return; > > machine__destroy_kernel_maps(machine); > - maps__delete(machine->kmaps); > + maps__zput(machine->kmaps); > dsos__exit(&machine->dsos); > machine__exit_vdso(machine); > zfree(&machine->root_dir); > diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c > index 5ae6379a1b42..5206a6433117 100644 > --- a/tools/perf/util/maps.c > +++ b/tools/perf/util/maps.c > @@ -171,7 +171,7 @@ struct maps *maps__new(struct machine *machine) > return result; > } > > -void maps__delete(struct maps *maps) > +static void maps__delete(struct maps *maps) > { > maps__exit(maps); > unwind__finish_access(maps); > diff --git a/tools/perf/util/maps.h b/tools/perf/util/maps.h > index d2963456cfbe..83144e0645ed 100644 > --- a/tools/perf/util/maps.h > +++ b/tools/perf/util/maps.h > @@ -57,13 +57,20 @@ struct kmap { > }; > > struct maps *maps__new(struct machine *machine); > -void maps__delete(struct maps *maps); > bool maps__empty(struct maps *maps); > int maps__clone(struct thread *thread, struct maps *parent); > > struct maps *maps__get(struct maps *maps); > void maps__put(struct maps *maps); > > +static inline void __maps__zput(struct maps **map) > +{ > + maps__put(*map); > + *map = NULL; > +} > + > +#define maps__zput(map) __maps__zput(&map) > + > static inline struct rb_root *maps__entries(struct maps *maps) > { > return &RC_CHK_ACCESS(maps)->entries; > -- > 2.41.0.162.gfafddb0af9-goog > -- - Arnaldo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel