From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C017B3306F; Fri, 24 Nov 2023 19:24:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="dcMpm9rh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EA8DC433C7; Fri, 24 Nov 2023 19:24:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700853885; bh=J0qzmFd38Ruxa7GssFmsxsAN7qJtaMxQZYesYyULdmM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dcMpm9rhiiziAacNCEZHeP259ndiPfjRrtn/D6qBOOHes2bBtKz+EZtVFiwmNTr7Q XwETLHIDj/ipsrVzxqXmiCfa6OaxqckAFvps1WCjHkbpeL75jmUMQg95eUq5uZbMCr YW7U5DDhXMShnO5PoPk5s1+C8LqSfUyMLCeAyD5w= 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 5.4 045/159] perf hist: Add missing puts to hist__account_cycles Date: Fri, 24 Nov 2023 17:54:22 +0000 Message-ID: <20231124171943.822904741@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231124171941.909624388@linuxfoundation.org> References: <20231124171941.909624388@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-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 151b9e43c88f9..9a02c1fd83493 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -2576,8 +2576,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; @@ -2592,12 +2590,18 @@ 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); prev = &bi[i].to; } + 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