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

Configure Feed

Select the types of activity you want to include in your feed.

perf annotate: Pass annotation_options to annotation_line__print()

The annotation_line__print() has many arguments. But min_percent,
max_lines and percent_type are from struct annotaion_options. So let's
pass a pointer to the option instead of passing them separately to
reduce the number of function arguments.

Actually it has a recursive call if 'queue' is set. Add a new option
instance to pass different values for the case.

Reviewed-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250310224925.799005-4-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

+14 -8
+14 -8
tools/perf/util/annotate.c
··· 760 760 761 761 static int 762 762 annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start, 763 - struct evsel *evsel, int min_pcnt, int printed, 764 - int max_lines, struct annotation_line *queue, int addr_fmt_width, 765 - int percent_type) 763 + struct evsel *evsel, struct annotation_options *opts, 764 + int printed, struct annotation_line *queue, int addr_fmt_width) 766 765 { 767 766 struct disasm_line *dl = container_of(al, struct disasm_line, al); 768 767 struct annotation *notes = symbol__annotation(sym); 769 768 static const char *prev_line; 769 + int max_lines = opts->max_lines; 770 + int percent_type = opts->percent_type; 770 771 771 772 if (al->offset != -1) { 772 773 double max_percent = 0.0; ··· 787 786 if (al->data_nr > nr_percent) 788 787 nr_percent = al->data_nr; 789 788 790 - if (max_percent < min_pcnt) 789 + if (max_percent < opts->min_pcnt) 791 790 return -1; 792 791 793 792 if (max_lines && printed >= max_lines) 794 793 return 1; 795 794 796 795 if (queue != NULL) { 796 + struct annotation_options queue_opts = { 797 + .max_lines = 1, 798 + .percent_type = percent_type, 799 + }; 800 + 797 801 list_for_each_entry_from(queue, &notes->src->source, node) { 798 802 if (queue == al) 799 803 break; 800 804 annotation_line__print(queue, sym, start, evsel, 801 - 0, 0, 1, NULL, addr_fmt_width, 802 - percent_type); 805 + &queue_opts, /*printed=*/0, 806 + /*queue=*/NULL, 807 + addr_fmt_width); 803 808 } 804 809 } 805 810 ··· 1232 1225 } 1233 1226 1234 1227 err = annotation_line__print(pos, sym, start, evsel, 1235 - opts->min_pcnt, printed, opts->max_lines, 1236 - queue, addr_fmt_width, opts->percent_type); 1228 + opts, printed, queue, addr_fmt_width); 1237 1229 1238 1230 switch (err) { 1239 1231 case 0: