Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp106388rdg; Wed, 11 Oct 2023 23:24:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwloQDU2ZJ5s3EJv8RmWlGDYhK7GMXYDU5KpYu0RaKQhI6+x6Mo0Al+qQUqQeeJ0dkcSox X-Received: by 2002:a05:6358:618c:b0:145:6560:d86d with SMTP id w12-20020a056358618c00b001456560d86dmr16584489rww.32.1697091875121; Wed, 11 Oct 2023 23:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697091875; cv=none; d=google.com; s=arc-20160816; b=LB2Tfi4teky47jSLzxT6yqv3K1RnWpuInVyrAzfyOzDuyQhfLoVeRA46pAwNDqVTj6 knmTi3XdsA/s7hb6MD1YakcoXgJaSRINhkmjhIgax+xkaYq+E7FRgLPBsxbrxKvcXAjn Cp/4gKR4Xm3QhB5YlgaVEjl3Dwk+Rcz/l/Ds+tenhl9uxOXXYSiMObrHtd4OZ3gFdbkf TkLEMq+F/SObF6NhQTnG1NhpWpbGBkOKMbp4tMEDwio/tr3HXglrPKZQFkaX+A+E4ASU q48Z/5ChBNaBS01K9q0vALN4QpsV2DgPaopFWAxdE3gWgLSf+qhgEtza29S+QAkqW5dU QXIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=Ym33VVd2BajpUroKBZvd3tTL/sMIOEowMFesXhruLGo=; fh=d2c3GDvCFnEMjeV5/UdzkMgvIdbP06sIBDmJP5CjgvI=; b=uMEPuwYi36j5xzynb3OjOXEtHT3YhladT0PedXCivAvvU61m5iYuLE0gT6fzyC/DL0 +W6iy+jL0HVcpU3oXJIZWnf8dLogjfzDopMEcXMiKcKJARghueVdqpcK0muVqjEZj5kO HR/CNyaDflg1VDwHEfdSlzcNUd27MalLwpvX4ZQ8AQF6pJ96uZUjfWiE0rqlmiwhGaPn QbtlG8fKlgAIIxgAc9+1h7r5JHf+vjgMDGRds+33R2v1W24XlFd8AiJ/c0p/Uv9yC84U VU881XrRBCwFw2IwpCwrsO1Nr8qi+z+icyuiJr/FeiC2lxfBL66rSlSlqD1nXzLQ9l11 R1nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=dtCItIPd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bx11-20020a056a00428b00b00690bd178205si13824901pfb.215.2023.10.11.23.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 23:24:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=dtCItIPd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id D614A81BF2C6; Wed, 11 Oct 2023 23:24:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377532AbjJLGYV (ORCPT + 99 others); Thu, 12 Oct 2023 02:24:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377499AbjJLGYT (ORCPT ); Thu, 12 Oct 2023 02:24:19 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7CDAD8 for ; Wed, 11 Oct 2023 23:24:12 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5a7aa161b2fso9747347b3.2 for ; Wed, 11 Oct 2023 23:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697091852; x=1697696652; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Ym33VVd2BajpUroKBZvd3tTL/sMIOEowMFesXhruLGo=; b=dtCItIPdQ3ab8HIPvToAzsIESurEr15VjpWWQ8yaO+Mg1RPqvT1cE14W9NklAd0jK4 7yQ2iyo7WfgUQHpDzjw4V0bvJWMP9hGr1MpgnkicSitGIq9Hgx6OBpCyvqIgbhaytO4f wE2oz/3Zdc1UDmfqgeYmLjtPPZijSChFDH3QPEX6xvSQcIWUs6fsZeeHOUlMLjxtuLXh 3p4fy/a9+mdQ/ejgOkZKtHwQ4HBkeVjdo6SW9BnVVB/NdYNT2A9GxxV+xXatq9lEOJwJ iQ6OC+badkskyGbxNCbXfyXX8nMbfz3mHiQ/mrp9ETD79Rv+3tw/76vxDOVuOpmZUfK+ bGvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697091852; x=1697696652; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ym33VVd2BajpUroKBZvd3tTL/sMIOEowMFesXhruLGo=; b=YO11XmGkLkqjP0o7F658InpDd0d8TjILPwgOACA794ICrTByAxX3VxErsH2MMujrx8 rGgi4KVAubtFVqWcYPyulES2ubwbxNMUZOZyNcvgUQYmw/r3N0Lt+I9ULgG+nMnyr0ml fMjfPKGuAzvuv5p/ckOPInu0c+w1hQmwsPZ31nhGHY/MFPopIyC/p5pb1sQdsCn4xIAh DT8DgXw4FeQT38QWKZOXU5ew/RpTBLM96KUICSNQtQuNpXeD4ShjK8yNWrAmghAOtQe1 IIpjF5lIG18mz96W5FpCpJgIVa/+pJ1e40Edj12BlzEN1FcwJer10StFRsrO6huOCmNr zNpw== X-Gm-Message-State: AOJu0YwcmAuGMAWezPZvSdxisNUL+GKXUNsjc+0kZBa8O7vKCluyVogE mp/l7d4YccNdk2T91yW7Uj1CNZLfM6OH X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:7be5:14d2:880b:c5c9]) (user=irogers job=sendgmr) by 2002:a25:870c:0:b0:d9a:3a25:36df with SMTP id a12-20020a25870c000000b00d9a3a2536dfmr196216ybl.8.1697091852080; Wed, 11 Oct 2023 23:24:12 -0700 (PDT) Date: Wed, 11 Oct 2023 23:23:49 -0700 In-Reply-To: <20231012062359.1616786-1-irogers@google.com> Message-Id: <20231012062359.1616786-4-irogers@google.com> Mime-Version: 1.0 References: <20231012062359.1616786-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Subject: [PATCH v2 03/13] perf hist: Add missing puts to hist__account_cycles From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , 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" 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 11 Oct 2023 23:24:33 -0700 (PDT) Caught using reference count checking on perf top with "--call-graph=lbr". 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; - bi = sample__resolve_bstack(sample, al); if (bi) { struct addr_map_symbol *prev = 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 = bs->nr - 1; i >= 0; i--) { + for (int i = bs->nr - 1; i >= 0; i--) { addr_map_symbol__account_cycles(&bi[i].from, nonany_branch_mode ? NULL : prev, bi[i].flags.cycles); @@ -2701,6 +2699,12 @@ void hist__account_cycles(struct branch_stack *bs, struct addr_location *al, if (total_cycles) *total_cycles += bi[i].flags.cycles; } + for (unsigned int i = 0; i < bs->nr; i++) { + 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