Commit fa5df94350510571cbe825f333996f57223b3cd2

Authored by Namhyung Kim
Committed by Arnaldo Carvalho de Melo
1 parent 064f19815c

perf top: Add --percent-limit option

The --percent-limit option is for not showing small overhead entries in
the output.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1368497347-9628-8-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Showing 4 changed files with 34 additions and 4 deletions Side-by-side Diff

tools/perf/Documentation/perf-top.txt
... ... @@ -155,6 +155,10 @@
155 155  
156 156 Default: fractal,0.5,callee.
157 157  
  158 +--percent-limit::
  159 + Do not show entries which have an overhead under that percent.
  160 + (Default: 0).
  161 +
158 162 INTERACTIVE PROMPTING KEYS
159 163 --------------------------
160 164  
tools/perf/builtin-top.c
... ... @@ -296,7 +296,8 @@
296 296 top->print_entries - printed);
297 297 putchar('\n');
298 298 hists__fprintf(&top->sym_evsel->hists, false,
299   - top->print_entries - printed, win_width, 0, stdout);
  299 + top->print_entries - printed, win_width,
  300 + top->min_percent, stdout);
300 301 }
301 302  
302 303 static void prompt_integer(int *target, const char *msg)
... ... @@ -580,7 +581,7 @@
580 581 list_for_each_entry(pos, &top->evlist->entries, node)
581 582 pos->hists.uid_filter_str = top->record_opts.target.uid_str;
582 583  
583   - perf_evlist__tui_browse_hists(top->evlist, help, &hbt, 0,
  584 + perf_evlist__tui_browse_hists(top->evlist, help, &hbt, top->min_percent,
584 585 &top->session->header.env);
585 586  
586 587 done = 1;
... ... @@ -1021,6 +1022,16 @@
1021 1022 return record_parse_callchain_opt(opt, arg, unset);
1022 1023 }
1023 1024  
  1025 +static int
  1026 +parse_percent_limit(const struct option *opt, const char *arg,
  1027 + int unset __maybe_unused)
  1028 +{
  1029 + struct perf_top *top = opt->value;
  1030 +
  1031 + top->min_percent = strtof(arg, NULL);
  1032 + return 0;
  1033 +}
  1034 +
1024 1035 int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1025 1036 {
1026 1037 int status;
... ... @@ -1106,6 +1117,8 @@
1106 1117 OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
1107 1118 "Specify disassembler style (e.g. -M intel for intel syntax)"),
1108 1119 OPT_STRING('u', "uid", &target->uid_str, "user", "user to profile"),
  1120 + OPT_CALLBACK(0, "percent-limit", &top, "percent",
  1121 + "Don't show entries under that percent", parse_percent_limit),
1109 1122 OPT_END()
1110 1123 };
1111 1124 const char * const top_usage[] = {
tools/perf/ui/browsers/hists.c
... ... @@ -310,6 +310,8 @@
310 310 "Or reduce the sampling frequency.");
311 311 }
312 312  
  313 +static void hist_browser__update_pcnt_entries(struct hist_browser *hb);
  314 +
313 315 static int hist_browser__run(struct hist_browser *browser, const char *ev_name,
314 316 struct hist_browser_timer *hbt)
315 317 {
316 318  
317 319  
... ... @@ -333,10 +335,19 @@
333 335 key = ui_browser__run(&browser->b, delay_secs);
334 336  
335 337 switch (key) {
336   - case K_TIMER:
  338 + case K_TIMER: {
  339 + u64 nr_entries;
337 340 hbt->timer(hbt->arg);
338   - ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries);
339 341  
  342 + if (browser->min_pcnt) {
  343 + hist_browser__update_pcnt_entries(browser);
  344 + nr_entries = browser->nr_pcnt_entries;
  345 + } else {
  346 + nr_entries = browser->hists->nr_entries;
  347 + }
  348 +
  349 + ui_browser__update_nr_entries(&browser->b, nr_entries);
  350 +
340 351 if (browser->hists->stats.nr_lost_warned !=
341 352 browser->hists->stats.nr_events[PERF_RECORD_LOST]) {
342 353 browser->hists->stats.nr_lost_warned =
... ... @@ -347,6 +358,7 @@
347 358 hists__browser_title(browser->hists, title, sizeof(title), ev_name);
348 359 ui_browser__show_title(&browser->b, title);
349 360 continue;
  361 + }
350 362 case 'D': { /* Debug */
351 363 static int seq;
352 364 struct hist_entry *h = rb_entry(browser->b.top,
tools/perf/util/top.h
... ... @@ -36,6 +36,7 @@
36 36 int realtime_prio;
37 37 int sym_pcnt_filter;
38 38 const char *sym_filter;
  39 + float min_percent;
39 40 };
40 41  
41 42 size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size);