From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753484AbcBYHsB (ORCPT ); Thu, 25 Feb 2016 02:48:01 -0500 Received: from torg.zytor.com ([198.137.202.12]:57966 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759783AbcBYHrr (ORCPT ); Thu, 25 Feb 2016 02:47:47 -0500 Date: Wed, 24 Feb 2016 23:46:02 -0800 From: tip-bot for Namhyung Kim Message-ID: Cc: namhyung@kernel.org, jolsa@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org, penberg@kernel.org, eranian@google.com, acme@redhat.com, wangnan0@huawei.com, andi@firstfloor.org, peterz@infradead.org, hpa@zytor.com, dsahern@gmail.com, tglx@linutronix.de Reply-To: acme@redhat.com, wangnan0@huawei.com, hpa@zytor.com, andi@firstfloor.org, peterz@infradead.org, eranian@google.com, penberg@kernel.org, linux-kernel@vger.kernel.org, mingo@kernel.org, namhyung@kernel.org, jolsa@kernel.org, tglx@linutronix.de, dsahern@gmail.com In-Reply-To: <1456326830-30456-18-git-send-email-namhyung@kernel.org> References: <1456326830-30456-18-git-send-email-namhyung@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf hists: Support decaying in hierarchy mode Git-Commit-ID: 5d8200ae67724960f7761b3a2216a1ca651fcc65 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 5d8200ae67724960f7761b3a2216a1ca651fcc65 Gitweb: http://git.kernel.org/tip/5d8200ae67724960f7761b3a2216a1ca651fcc65 Author: Namhyung Kim AuthorDate: Thu, 25 Feb 2016 00:13:49 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 24 Feb 2016 20:21:15 -0300 perf hists: Support decaying in hierarchy mode In the hierarchy mode, hist entries should decay their children too. Also update hists__delete_entry() to be able to free child entries. Signed-off-by: Namhyung Kim Acked-by: Pekka Enberg Cc: Andi Kleen Cc: David Ahern Cc: Jiri Olsa Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Wang Nan Link: http://lkml.kernel.org/r/1456326830-30456-18-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/hist.c | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index a44bf5a..1c53042 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -248,6 +248,8 @@ static void he_stat__decay(struct he_stat *he_stat) /* XXX need decay for weight too? */ } +static void hists__delete_entry(struct hists *hists, struct hist_entry *he); + static bool hists__decay_entry(struct hists *hists, struct hist_entry *he) { u64 prev_period = he->stat.period; @@ -263,21 +265,45 @@ static bool hists__decay_entry(struct hists *hists, struct hist_entry *he) diff = prev_period - he->stat.period; - hists->stats.total_period -= diff; - if (!he->filtered) - hists->stats.total_non_filtered_period -= diff; + if (!he->depth) { + hists->stats.total_period -= diff; + if (!he->filtered) + hists->stats.total_non_filtered_period -= diff; + } + + if (!he->leaf) { + struct hist_entry *child; + struct rb_node *node = rb_first(&he->hroot_out); + while (node) { + child = rb_entry(node, struct hist_entry, rb_node); + node = rb_next(node); + + if (hists__decay_entry(hists, child)) + hists__delete_entry(hists, child); + } + } return he->stat.period == 0; } static void hists__delete_entry(struct hists *hists, struct hist_entry *he) { - rb_erase(&he->rb_node, &hists->entries); + struct rb_root *root_in; + struct rb_root *root_out; - if (sort__need_collapse) - rb_erase(&he->rb_node_in, &hists->entries_collapsed); - else - rb_erase(&he->rb_node_in, hists->entries_in); + if (he->parent_he) { + root_in = &he->parent_he->hroot_in; + root_out = &he->parent_he->hroot_out; + } else { + if (sort__need_collapse) + root_in = &hists->entries_collapsed; + else + root_in = hists->entries_in; + root_out = &hists->entries; + } + + rb_erase(&he->rb_node_in, root_in); + rb_erase(&he->rb_node, root_out); --hists->nr_entries; if (!he->filtered)