Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754616AbbLJJzv (ORCPT ); Thu, 10 Dec 2015 04:55:51 -0500 Received: from mail7.hitachi.co.jp ([133.145.228.42]:59054 "EHLO mail7.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751272AbbLJJzs (ORCPT ); Thu, 10 Dec 2015 04:55:48 -0500 From: =?utf-8?B?5bmz5p2+6ZuF5bezIC8gSElSQU1BVFXvvIxNQVNBTUk=?= To: "'Namhyung Kim'" , Arnaldo Carvalho de Melo CC: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , "David Ahern" , Frederic Weisbecker , "Andi Kleen" , Stephane Eranian , "Adrian Hunter" Subject: RE: [PATCH/RFC 01/16] perf top: Delete half-processed hist entries when exit Thread-Topic: [PATCH/RFC 01/16] perf top: Delete half-processed hist entries when exit Thread-Index: AQHRMx/iDWnCWd2qHUWk6ChE+4Kd157D+1fQ Date: Thu, 10 Dec 2015 09:55:44 +0000 Message-ID: <50399556C9727B4D88A595C8584AAB375264F907@GSjpTKYDCembx32.service.hitachi.net> References: <1449734015-9148-1-git-send-email-namhyung@kernel.org> <1449734015-9148-2-git-send-email-namhyung@kernel.org> In-Reply-To: <1449734015-9148-2-git-send-email-namhyung@kernel.org> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.198.219.40] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id tBA9tu5Z000543 Content-Length: 2492 Lines: 79 >From: Namhyung Kim [mailto:namhyung@kernel.org] > >After sample processing is done, hist entries are in both of >hists->entries and hists->entries_in (or hists->entries_collapsed). >So I guess perf report does not have leaks on hists. > >But for perf top, it's possible to have half-processed entries which >are only in hists->entries_in. Eventually they will go to the >hists->entries and get freed but they cannot be deleted by current >hists__delete_entries(). This patch adds hists__delete_all_entries >function to delete those entries. > This is tested under the refcnt debugger and I've reviewed it. Acked-by: Masami Hiramatsu Tested-by: Masami Hiramatsu Thanks! >Cc: Masami Hiramatsu >Signed-off-by: Namhyung Kim >--- > tools/perf/util/hist.c | 26 +++++++++++++++++++++++++- > 1 file changed, 25 insertions(+), 1 deletion(-) > >diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c >index 565ea3549894..56e97f5af598 100644 >--- a/tools/perf/util/hist.c >+++ b/tools/perf/util/hist.c >@@ -270,6 +270,8 @@ static void hists__delete_entry(struct hists *hists, struct hist_entry *he) > > if (sort__need_collapse) > rb_erase(&he->rb_node_in, &hists->entries_collapsed); >+ else >+ rb_erase(&he->rb_node_in, hists->entries_in); > > --hists->nr_entries; > if (!he->filtered) >@@ -1567,11 +1569,33 @@ static int hists_evsel__init(struct perf_evsel *evsel) > return 0; > } > >+static void hists__delete_remaining_entries(struct rb_root *root) >+{ >+ struct rb_node *node; >+ struct hist_entry *he; >+ >+ while (!RB_EMPTY_ROOT(root)) { >+ node = rb_first(root); >+ rb_erase(node, root); >+ >+ he = rb_entry(node, struct hist_entry, rb_node_in); >+ hist_entry__delete(he); >+ } >+} >+ >+static void hists__delete_all_entries(struct hists *hists) >+{ >+ hists__delete_entries(hists); >+ hists__delete_remaining_entries(&hists->entries_in_array[0]); >+ hists__delete_remaining_entries(&hists->entries_in_array[1]); >+ hists__delete_remaining_entries(&hists->entries_collapsed); >+} >+ > static void hists_evsel__exit(struct perf_evsel *evsel) > { > struct hists *hists = evsel__hists(evsel); > >- hists__delete_entries(hists); >+ hists__delete_all_entries(hists); > } > > /* >-- >2.6.2 ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?