Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1997750rda; Tue, 24 Oct 2023 09:13:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRjgxzopO3woEeXF8jTWE577OGtK1Ru31cthHtFGWICyYrKng2XEyv0iQURElIcfIgUtiW X-Received: by 2002:a05:6a20:914a:b0:15e:7323:5c0f with SMTP id x10-20020a056a20914a00b0015e73235c0fmr3476385pzc.16.1698164024153; Tue, 24 Oct 2023 09:13:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698164024; cv=none; d=google.com; s=arc-20160816; b=g4b3jkxqnza7UK30I/czBm3N/42Kiswoy8V7f4d9Ln14/awpzg2nAmfdTJSbU+z0id B0Me9Ecot0QMVjbsJsiAvGfWpJ5B7lpQraKYwZgb5JvuqdhGl/Bp7JSbjbkfnXUMnQT5 kQS1RI9OiRE8UEsPcbediluqhN4+X95sUkIlB3QzoigIgHS2qeryT9Qno/IRnFLBSIMF yxMocqwWTiSwhfxGz2P4fl71wInoxYTxI7yUHYgZ7Ckp9uqgvq+b31fmz1iiks8XykP2 BXdVPT5uRJAn7q91DayT10AqIOWv6Ls7E88jPPLa6AWMlhdSkj5KfDTxaUiLHmgfWxPg LtYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=UTa//f3CF6frOiaIViZbYmNtaYUVdbJcfKPBPGR/E6o=; fh=nl88BES6xn7UI3tGEip4+WC3AAfutaQfoa4Vp0+Z3z8=; b=QCiQZSBAvZdv8eehJfqXyShCFC5Gt/SGRP/YX8aDY4c5ll4iRQ3uqB5UQcIG18P6pz 5YZCm7nLeeKByGdHmB+8dEOyUuTlFsJ8wxT+Heq6y3cHtCfdZTulMgvZw0sDdKAG6WQV 4fNZPg7WS7tqq/WvhSsCMtKePe3M7q+pBhEUNNSOcfZdNiA81dDLQQUyPZa/NotrAl4n lPrR0QDfmpVbFEjezjUKquIvnvOAEhsF7ri2jOSBBqxqDNN1Cz/DK4Ag/y3/8/muU0tG qEk4J650g+FJyMeqM6aYG0Xkz01tCn83ASo2fo09NeZVeWdHdu9L3kKXHhxfUoMV413E 3koQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="wU/pUNZo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id b6-20020a6567c6000000b00578a43e3b0bsi8936474pgs.655.2023.10.24.09.13.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 09:13:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="wU/pUNZo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9875980A87C5; Tue, 24 Oct 2023 09:13:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344172AbjJXQN3 (ORCPT + 99 others); Tue, 24 Oct 2023 12:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235005AbjJXQNM (ORCPT ); Tue, 24 Oct 2023 12:13:12 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E979D171A for ; Tue, 24 Oct 2023 09:12:47 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-53eeb28e8e5so13244a12.1 for ; Tue, 24 Oct 2023 09:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698163966; x=1698768766; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UTa//f3CF6frOiaIViZbYmNtaYUVdbJcfKPBPGR/E6o=; b=wU/pUNZowpJoYV2JJL1DpeVBnaPBuv7UvxbPvk6BRo1qz1Rr9H3Ljsv6+TMuOO5PvM NiTi/gR0FqwDu3qlGz7Cyd6FGYz6KP4Qo9gHWih6owfGIybZEoFH388F5ZwJM/x09k2d hOIZduSb8YG6G7YyKI92mvt/79Fxa9ZoO3P9wLQTHSHHGq2poroP9aoS6nR8yY4fQY3H ySs9Z4NybZtLe/oGcBWT78bl9131vNrLpMZHK2dtmJXDBe7OOXod0AgUYL/54F8JPw4Y ViUmH12pf6IYO0ooQYc3UrMZYO2KH3rVgPF6IdL5oJTjPTMZxvROphFbqcyUHpF+HXH0 AKZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698163966; x=1698768766; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UTa//f3CF6frOiaIViZbYmNtaYUVdbJcfKPBPGR/E6o=; b=lcjx8+3U7Auq/8zJkhYx2kQJRZ4x95G0Dx/Gqj4WmQoRRJu+a88Ne8JEl/kH8jnkbj DRbGlJ6ov6EnbCyh0ko9Dz6OAnDqzAiqbc7khv5RHcDX6vGkuoZKyQWR1Z+IAr5XHX1C 7hq9AUEH7DUX4dnZr+1zwTcWRoPjRp2baaQnx9lZ/iw//1niC2ta9as9wgxQbpO27nRB rjlPeaUL8WglFlDIhK6r5xQ+79NmK1FTdR6GYbofLekDYMass/EnkAKxlMLudYvHQBbG qPsPH801JRmQ3iULt4efiJiYv89nYCjsBI8r8ozk/aNNF71WADYfBcLg4KN/D+QCnqaX eoWQ== X-Gm-Message-State: AOJu0YwQbcXOVAJvyAY9/fqwVaU4igWLn+A/mwYntCgWqfPiRFkKUqa9 16MtWCYtB1uGQg2c2MLvjfq1Wk569vt1eT5BE2TMXg== X-Received: by 2002:a05:6402:32c:b0:540:9f24:6006 with SMTP id q12-20020a056402032c00b005409f246006mr117406edw.6.1698163965905; Tue, 24 Oct 2023 09:12:45 -0700 (PDT) MIME-Version: 1.0 References: <20231012062359.1616786-1-irogers@google.com> <20231012062359.1616786-4-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Tue, 24 Oct 2023 09:12:33 -0700 Message-ID: Subject: Re: [PATCH v2 03/13] perf hist: Add missing puts to hist__account_cycles To: Namhyung Kim Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Nick Terrell , Kan Liang , Song Liu , Sandipan Das , Anshuman Khandual , James Clark , Liam Howlett , Miguel Ojeda , Leo Yan , German Gomez , Ravi Bangoria , Artem Savkov , Athira Rajeev , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 24 Oct 2023 09:13:41 -0700 (PDT) On Wed, Oct 18, 2023 at 4:16=E2=80=AFPM Namhyung Kim = wrote: > > Hi Ian, > > On Wed, Oct 11, 2023 at 11:24=E2=80=AFPM Ian Rogers = wrote: > > > > Caught using reference count checking on perf top with > > "--call-graph=3Dlbr". After this no memory leaks were detected. > > > > Fixes: 57849998e2cd ("perf report: Add processing for cycle histograms"= ) > > Signed-off-by: Ian Rogers > > --- > > tools/perf/util/hist.c | 10 +++++++--- > > 1 file changed, 7 insertions(+), 3 deletions(-) > > > > diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c > > index 3dc8a4968beb..ac8c0ef48a7f 100644 > > --- a/tools/perf/util/hist.c > > +++ b/tools/perf/util/hist.c > > @@ -2676,8 +2676,6 @@ void hist__account_cycles(struct branch_stack *bs= , struct addr_location *al, > > > > /* If we have branch cycles always annotate them. */ > > if (bs && bs->nr && entries[0].flags.cycles) { > > - int i; > > - > > Seems not necessary. > > > bi =3D sample__resolve_bstack(sample, al); > > It looks like this increases the refcount for each bi entry and > it didn't put the refcounts. Right, this is why the loop doing the puts is added. > > > if (bi) { > > struct addr_map_symbol *prev =3D NULL; > > @@ -2692,7 +2690,7 @@ void hist__account_cycles(struct branch_stack *bs= , struct addr_location *al, > > * Note that perf stores branches reversed from > > * program order! > > */ > > - for (i =3D bs->nr - 1; i >=3D 0; i--) { > > + for (int i =3D bs->nr - 1; i >=3D 0; i--) { > > addr_map_symbol__account_cycles(&bi[i].= from, > > nonany_branch_mode ? NULL : pre= v, > > bi[i].flags.cycles); > > @@ -2701,6 +2699,12 @@ void hist__account_cycles(struct branch_stack *b= s, struct addr_location *al, > > if (total_cycles) > > *total_cycles +=3D bi[i].flags.= cycles; > > } > > + for (unsigned int i =3D 0; i < bs->nr; i++) { > > Can we just reuse the int i above? I wanted to move to unsigned for consistency with the rest of the branch_stack code, nr is a u64, but when iterating down the sign matters - so this fixes up where possible. Thanks, Ian > Thanks, > Namhyung > > > > + map__put(bi[i].to.ms.map); > > + maps__put(bi[i].to.ms.maps); > > + map__put(bi[i].from.ms.map); > > + maps__put(bi[i].from.ms.maps); > > + } > > free(bi); > > } > > } > > -- > > 2.42.0.609.gbb76f46606-goog > >