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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C57A2C072A2 for ; Wed, 15 Nov 2023 20:00:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344140AbjKOUAx (ORCPT ); Wed, 15 Nov 2023 15:00:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344125AbjKOUAw (ORCPT ); Wed, 15 Nov 2023 15:00:52 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DD1E1A5 for ; Wed, 15 Nov 2023 12:00:48 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1328BC433CC; Wed, 15 Nov 2023 20:00:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700078448; bh=jNAO5jWXgrwqJOghqNNPV0T4TtVKghAKXuUfe72d6Js=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q6LUFia55dyeZKuXmFnX1oU/Vs7BCqwyw//g+PijrkwGPleltfQHKSrTEYcnUv4zU SD95v99u9yuRMLSFfdxCPeMa/MuoR2Tm+C/WnkvH2sP8qlyB4XoBwK0Pq/sfDGTjJK 3rkutbaYkxoamAsr5MKdl+yeuKq6r+qyYLrxWTGU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ian Rogers , K Prateek Nayak , Ravi Bangoria , Sandipan Das , Anshuman Khandual , German Gomez , James Clark , Nick Terrell , Sean Christopherson , Changbin Du , liuwenyu , Yang Jihong , Masami Hiramatsu , Miguel Ojeda , Song Liu , Leo Yan , Kajol Jain , Andi Kleen , Kan Liang , Athira Rajeev , Yanteng Si , Liam Howlett , Paolo Bonzini , Namhyung Kim , Sasha Levin Subject: [PATCH 6.1 303/379] perf hist: Add missing puts to hist__account_cycles Date: Wed, 15 Nov 2023 14:26:18 -0500 Message-ID: <20231115192703.071209660@linuxfoundation.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231115192645.143643130@linuxfoundation.org> References: <20231115192645.143643130@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ian Rogers [ Upstream commit c1149037f65bcf0334886180ebe3d5efcf214912 ] 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 Cc: K Prateek Nayak Cc: Ravi Bangoria Cc: Sandipan Das Cc: Anshuman Khandual Cc: German Gomez Cc: James Clark Cc: Nick Terrell Cc: Sean Christopherson Cc: Changbin Du Cc: liuwenyu Cc: Yang Jihong Cc: Masami Hiramatsu Cc: Miguel Ojeda Cc: Song Liu Cc: Leo Yan Cc: Kajol Jain Cc: Andi Kleen Cc: Kan Liang Cc: Athira Rajeev Cc: Yanteng Si Cc: Liam Howlett Cc: Paolo Bonzini Link: https://lore.kernel.org/r/20231024222353.3024098-6-irogers@google.com Signed-off-by: Namhyung Kim Signed-off-by: Sasha Levin --- 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 17a05e943b44b..bffd058cbecee 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -2645,8 +2645,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; @@ -2661,7 +2659,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); @@ -2670,6 +2668,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