Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1325489 > unrolled thread

[PATCH 4/4] perf hists browser: Add 'L' key to change percent limit

Started byNamhyung Kim <namhyung@kernel.org>
First post2016-02-03 15:20 +0100
Last post2016-02-04 13:50 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 4/4] perf hists browser: Add 'L' key to change percent limit Namhyung Kim <namhyung@kernel.org> - 2016-02-03 15:20 +0100
    Re: [PATCH 4/4] perf hists browser: Add 'L' key to change percent  limit Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-03 16:20 +0100
    [tip:perf/core] perf hists browser: Add 'L'   hotkey to change percent limit tip-bot for Namhyung Kim <tipbot@zytor.com> - 2016-02-04 13:50 +0100

#1325489 — [PATCH 4/4] perf hists browser: Add 'L' key to change percent limit

FromNamhyung Kim <namhyung@kernel.org>
Date2016-02-03 15:20 +0100
Subject[PATCH 4/4] perf hists browser: Add 'L' key to change percent limit
Message-ID<qY6rL-31V-9@gated-at.bofh.it>
Add 'L' key action to change the percent limit applied to both of hist
entries and callchains.

Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/browsers/hists.c | 55 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 61d578bf4ffd..c6ae69716002 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2029,6 +2029,42 @@ static void hist_browser__update_nr_entries(struct hist_browser *hb)
 	hb->nr_non_filtered_entries = nr_entries;
 }
 
+static void hist_browser__update_percent_limit(struct hist_browser *hb,
+					       double percent)
+{
+	struct hist_entry *he;
+	struct rb_node *nd = rb_first(&hb->hists->entries);
+	u64 total = hists__total_period(hb->hists);
+	u64 min_callchain_hits = total * (percent / 100);
+
+	hb->min_pcnt = callchain_param.min_percent = percent;
+
+	if (!symbol_conf.use_callchain)
+		return;
+
+	while ((nd = hists__filter_entries(nd, hb->min_pcnt)) != NULL) {
+		he = rb_entry(nd, struct hist_entry, rb_node);
+
+		if (callchain_param.mode == CHAIN_GRAPH_REL) {
+			total = he->stat.period;
+
+			if (symbol_conf.cumulate_callchain)
+				total = he->stat_acc->period;
+
+			min_callchain_hits = total * (percent / 100);
+		}
+
+		callchain_param.sort(&he->sorted_chain, he->callchain,
+				     min_callchain_hits, &callchain_param);
+
+		/* force to re-evaluate folding state of callchains */
+		he->init_have_children = false;
+		hist_entry__set_folding(he, false);
+
+		nd = rb_next(nd);
+	}
+}
+
 static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 				    const char *helpline,
 				    bool left_exits,
@@ -2064,6 +2100,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 	"E             Expand all callchains\n"				\
 	"F             Toggle percentage of filtered entries\n"		\
 	"H             Display column headers\n"			\
+	"L             Change percent limit\n"				\
 	"m             Display context menu\n"				\
 	"S             Zoom into current Processor Socket\n"		\
 
@@ -2219,6 +2256,24 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 				top->zero = !top->zero;
 			}
 			continue;
+		case 'L':
+			if (ui_browser__input_window("Percent Limit",
+					"Please enter the value you want to hide entries under that percent.",
+					buf, "ENTER: OK, ESC: Cancel",
+					delay_secs * 2) == K_ENTER) {
+				char *end;
+				double new_percent = strtod(buf, &end);
+
+				if (new_percent < 0 || new_percent > 100) {
+					ui_browser__warning(&browser->b, delay_secs * 2,
+						"Invalid percent: %.2f", new_percent);
+					continue;
+				}
+
+				hist_browser__update_percent_limit(browser, new_percent);
+				hist_browser__reset(browser);
+			}
+			continue;
 		case K_F1:
 		case 'h':
 		case '?':
-- 
2.7.0

[toc] | [next] | [standalone]


#1325526 — Re: [PATCH 4/4] perf hists browser: Add 'L' key to change percent limit

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-02-03 16:20 +0100
SubjectRe: [PATCH 4/4] perf hists browser: Add 'L' key to change percent limit
Message-ID<qY7nQ-3C1-13@gated-at.bofh.it>
In reply to#1325489
Em Wed, Feb 03, 2016 at 11:11:23PM +0900, Namhyung Kim escreveu:
> Add 'L' key action to change the percent limit applied to both of hist
> entries and callchains.

Thanks a lot, works like a charm!

Applied,

- Arnaldo
 
> Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/ui/browsers/hists.c | 55 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 55 insertions(+)
> 
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index 61d578bf4ffd..c6ae69716002 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -2029,6 +2029,42 @@ static void hist_browser__update_nr_entries(struct hist_browser *hb)
>  	hb->nr_non_filtered_entries = nr_entries;
>  }
>  
> +static void hist_browser__update_percent_limit(struct hist_browser *hb,
> +					       double percent)
> +{
> +	struct hist_entry *he;
> +	struct rb_node *nd = rb_first(&hb->hists->entries);
> +	u64 total = hists__total_period(hb->hists);
> +	u64 min_callchain_hits = total * (percent / 100);
> +
> +	hb->min_pcnt = callchain_param.min_percent = percent;
> +
> +	if (!symbol_conf.use_callchain)
> +		return;
> +
> +	while ((nd = hists__filter_entries(nd, hb->min_pcnt)) != NULL) {
> +		he = rb_entry(nd, struct hist_entry, rb_node);
> +
> +		if (callchain_param.mode == CHAIN_GRAPH_REL) {
> +			total = he->stat.period;
> +
> +			if (symbol_conf.cumulate_callchain)
> +				total = he->stat_acc->period;
> +
> +			min_callchain_hits = total * (percent / 100);
> +		}
> +
> +		callchain_param.sort(&he->sorted_chain, he->callchain,
> +				     min_callchain_hits, &callchain_param);
> +
> +		/* force to re-evaluate folding state of callchains */
> +		he->init_have_children = false;
> +		hist_entry__set_folding(he, false);
> +
> +		nd = rb_next(nd);
> +	}
> +}
> +
>  static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
>  				    const char *helpline,
>  				    bool left_exits,
> @@ -2064,6 +2100,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
>  	"E             Expand all callchains\n"				\
>  	"F             Toggle percentage of filtered entries\n"		\
>  	"H             Display column headers\n"			\
> +	"L             Change percent limit\n"				\
>  	"m             Display context menu\n"				\
>  	"S             Zoom into current Processor Socket\n"		\
>  
> @@ -2219,6 +2256,24 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
>  				top->zero = !top->zero;
>  			}
>  			continue;
> +		case 'L':
> +			if (ui_browser__input_window("Percent Limit",
> +					"Please enter the value you want to hide entries under that percent.",
> +					buf, "ENTER: OK, ESC: Cancel",
> +					delay_secs * 2) == K_ENTER) {
> +				char *end;
> +				double new_percent = strtod(buf, &end);
> +
> +				if (new_percent < 0 || new_percent > 100) {
> +					ui_browser__warning(&browser->b, delay_secs * 2,
> +						"Invalid percent: %.2f", new_percent);
> +					continue;
> +				}
> +
> +				hist_browser__update_percent_limit(browser, new_percent);
> +				hist_browser__reset(browser);
> +			}
> +			continue;
>  		case K_F1:
>  		case 'h':
>  		case '?':
> -- 
> 2.7.0

[toc] | [prev] | [next] | [standalone]


#1326748 — [tip:perf/core] perf hists browser: Add 'L' hotkey to change percent limit

Fromtip-bot for Namhyung Kim <tipbot@zytor.com>
Date2016-02-04 13:50 +0100
Subject[tip:perf/core] perf hists browser: Add 'L' hotkey to change percent limit
Message-ID<qYrwe-gw-1@gated-at.bofh.it>
In reply to#1325489
Commit-ID:  b62e8dfcda8cb133c062c0e1207afea2476eb7fd
Gitweb:     http://git.kernel.org/tip/b62e8dfcda8cb133c062c0e1207afea2476eb7fd
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Wed, 3 Feb 2016 23:11:23 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:22 -0300

perf hists browser: Add 'L' hotkey to change percent limit

Add 'L' key action to change the percent limit applied to both of hist
entries and callchains.

Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1454508683-5735-4-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c | 55 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 3a1e096..a5a5390 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2029,6 +2029,42 @@ static void hist_browser__update_nr_entries(struct hist_browser *hb)
 	hb->nr_non_filtered_entries = nr_entries;
 }
 
+static void hist_browser__update_percent_limit(struct hist_browser *hb,
+					       double percent)
+{
+	struct hist_entry *he;
+	struct rb_node *nd = rb_first(&hb->hists->entries);
+	u64 total = hists__total_period(hb->hists);
+	u64 min_callchain_hits = total * (percent / 100);
+
+	hb->min_pcnt = callchain_param.min_percent = percent;
+
+	if (!symbol_conf.use_callchain)
+		return;
+
+	while ((nd = hists__filter_entries(nd, hb->min_pcnt)) != NULL) {
+		he = rb_entry(nd, struct hist_entry, rb_node);
+
+		if (callchain_param.mode == CHAIN_GRAPH_REL) {
+			total = he->stat.period;
+
+			if (symbol_conf.cumulate_callchain)
+				total = he->stat_acc->period;
+
+			min_callchain_hits = total * (percent / 100);
+		}
+
+		callchain_param.sort(&he->sorted_chain, he->callchain,
+				     min_callchain_hits, &callchain_param);
+
+		/* force to re-evaluate folding state of callchains */
+		he->init_have_children = false;
+		hist_entry__set_folding(he, false);
+
+		nd = rb_next(nd);
+	}
+}
+
 static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 				    const char *helpline,
 				    bool left_exits,
@@ -2064,6 +2100,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 	"E             Expand all callchains\n"				\
 	"F             Toggle percentage of filtered entries\n"		\
 	"H             Display column headers\n"			\
+	"L             Change percent limit\n"				\
 	"m             Display context menu\n"				\
 	"S             Zoom into current Processor Socket\n"		\
 
@@ -2219,6 +2256,24 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 				top->zero = !top->zero;
 			}
 			continue;
+		case 'L':
+			if (ui_browser__input_window("Percent Limit",
+					"Please enter the value you want to hide entries under that percent.",
+					buf, "ENTER: OK, ESC: Cancel",
+					delay_secs * 2) == K_ENTER) {
+				char *end;
+				double new_percent = strtod(buf, &end);
+
+				if (new_percent < 0 || new_percent > 100) {
+					ui_browser__warning(&browser->b, delay_secs * 2,
+						"Invalid percent: %.2f", new_percent);
+					continue;
+				}
+
+				hist_browser__update_percent_limit(browser, new_percent);
+				hist_browser__reset(browser);
+			}
+			continue;
 		case K_F1:
 		case 'h':
 		case '?':

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web