Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf annotate: Add --percent-limit option

Like in 'perf report' and 'perf top', Add this option to limit the
number of functions it displays based on the overhead value in percent.

This affects only stdio and stdio2 output modes. Without this, it
shows very long disassembly lines for every function in the data
file. If users don't want this behavior, they can set a value in
percent to suppress that.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20220502232015.697243-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
cad10ce3 7df319e5

+29
+5
tools/perf/Documentation/perf-annotate.txt
··· 147 147 The period/hits keywords set the base the percentage is computed 148 148 on - the samples period or the number of samples (hits). 149 149 150 + --percent-limit:: 151 + Do not show functions which have an overhead under that percent on 152 + stdio or stdio2 (Default: 0). Note that this is about selection of 153 + functions to display, not about lines within the function. 154 + 150 155 SEE ALSO 151 156 -------- 152 157 linkperf:perf-record[1], linkperf:perf-report[1]
+24
tools/perf/builtin-annotate.c
··· 54 54 bool skip_missing; 55 55 bool has_br_stack; 56 56 bool group_set; 57 + float min_percent; 57 58 const char *sym_hist_filter; 58 59 const char *cpu_list; 59 60 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); ··· 325 324 (strcmp(he->ms.sym->name, ann->sym_hist_filter) != 0)) 326 325 goto find_next; 327 326 327 + if (ann->min_percent) { 328 + float percent = 0; 329 + u64 total = hists__total_period(hists); 330 + 331 + if (total) 332 + percent = 100.0 * he->stat.period / total; 333 + 334 + if (percent < ann->min_percent) 335 + goto find_next; 336 + } 337 + 328 338 notes = symbol__annotation(he->ms.sym); 329 339 if (notes->src == NULL) { 330 340 find_next: ··· 469 457 return ret; 470 458 } 471 459 460 + static int parse_percent_limit(const struct option *opt, const char *str, 461 + int unset __maybe_unused) 462 + { 463 + struct perf_annotate *ann = opt->value; 464 + double pcnt = strtof(str, NULL); 465 + 466 + ann->min_percent = pcnt; 467 + return 0; 468 + } 469 + 472 470 static const char * const annotate_usage[] = { 473 471 "perf annotate [<options>]", 474 472 NULL ··· 579 557 OPT_CALLBACK(0, "percent-type", &annotate.opts, "local-period", 580 558 "Set percent type local/global-period/hits", 581 559 annotate_parse_percent_type), 560 + OPT_CALLBACK(0, "percent-limit", &annotate, "percent", 561 + "Don't show entries under that percent", parse_percent_limit), 582 562 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts", 583 563 "Instruction Tracing options\n" ITRACE_HELP, 584 564 itrace_parse_synth_opts),