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: Move 'widths' struct to 'struct annotated_source'

It's only used in 'perf annotate' output which means functions with
actual samples. No need to consume memory for every symbol
('struct annotation').

Also move the 'max_line_len' field into it as it's related.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240404175716.1225482-7-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
a46acc45 cee9b860

+35 -32
+3 -3
tools/perf/ui/browsers/annotate.c
··· 205 205 206 206 ui_browser__set_color(browser, HE_COLORSET_JUMP_ARROWS); 207 207 __ui_browser__line_arrow(browser, 208 - pcnt_width + 2 + notes->widths.addr + width, 208 + pcnt_width + 2 + notes->src->widths.addr + width, 209 209 from, to); 210 210 211 211 diff = is_fused(ab, cursor); 212 212 if (diff > 0) { 213 213 ui_browser__mark_fused(browser, 214 - pcnt_width + 3 + notes->widths.addr + width, 214 + pcnt_width + 3 + notes->src->widths.addr + width, 215 215 from - diff, diff, to > from); 216 216 } 217 217 } ··· 983 983 984 984 ui_helpline__push("Press ESC to exit"); 985 985 986 - browser.b.width = notes->src->max_line_len; 986 + browser.b.width = notes->src->widths.max_line_len; 987 987 browser.b.nr_entries = notes->src->nr_entries; 988 988 browser.b.entries = &notes->src->source, 989 989 browser.b.width += 18; /* Percentage */
+22 -19
tools/perf/util/annotate.c
··· 1383 1383 struct annotation_line *al; 1384 1384 struct annotated_source *src = notes->src; 1385 1385 1386 - src->max_line_len = 0; 1386 + src->widths.max_line_len = 0; 1387 1387 src->nr_entries = 0; 1388 1388 src->nr_asm_entries = 0; 1389 1389 1390 1390 list_for_each_entry(al, &src->source, node) { 1391 1391 size_t line_len = strlen(al->line); 1392 1392 1393 - if (src->max_line_len < line_len) 1394 - src->max_line_len = line_len; 1393 + if (src->widths.max_line_len < line_len) 1394 + src->widths.max_line_len = line_len; 1395 1395 al->idx = src->nr_entries++; 1396 1396 if (al->offset != -1) 1397 1397 al->idx_asm = src->nr_asm_entries++; ··· 1429 1429 static void 1430 1430 annotation__init_column_widths(struct annotation *notes, struct symbol *sym) 1431 1431 { 1432 - notes->widths.addr = notes->widths.target = 1433 - notes->widths.min_addr = hex_width(symbol__size(sym)); 1434 - notes->widths.max_addr = hex_width(sym->end); 1435 - notes->widths.jumps = width_jumps(notes->max_jump_sources); 1436 - notes->widths.max_ins_name = annotation__max_ins_name(notes); 1432 + notes->src->widths.addr = notes->src->widths.target = 1433 + notes->src->widths.min_addr = hex_width(symbol__size(sym)); 1434 + notes->src->widths.max_addr = hex_width(sym->end); 1435 + notes->src->widths.jumps = width_jumps(notes->max_jump_sources); 1436 + notes->src->widths.max_ins_name = annotation__max_ins_name(notes); 1437 1437 } 1438 1438 1439 1439 void annotation__update_column_widths(struct annotation *notes) 1440 1440 { 1441 1441 if (annotate_opts.use_offset) 1442 - notes->widths.target = notes->widths.min_addr; 1442 + notes->src->widths.target = notes->src->widths.min_addr; 1443 1443 else if (annotate_opts.full_addr) 1444 - notes->widths.target = BITS_PER_LONG / 4; 1444 + notes->src->widths.target = BITS_PER_LONG / 4; 1445 1445 else 1446 - notes->widths.target = notes->widths.max_addr; 1446 + notes->src->widths.target = notes->src->widths.max_addr; 1447 1447 1448 - notes->widths.addr = notes->widths.target; 1448 + notes->src->widths.addr = notes->src->widths.target; 1449 1449 1450 1450 if (annotate_opts.show_nr_jumps) 1451 - notes->widths.addr += notes->widths.jumps + 1; 1451 + notes->src->widths.addr += notes->src->widths.jumps + 1; 1452 1452 } 1453 1453 1454 1454 void annotation__toggle_full_addr(struct annotation *notes, struct map_symbol *ms) ··· 1625 1625 obj__printf(obj, " "); 1626 1626 } 1627 1627 1628 - disasm_line__scnprintf(dl, bf, size, !annotate_opts.use_offset, notes->widths.max_ins_name); 1628 + disasm_line__scnprintf(dl, bf, size, !annotate_opts.use_offset, 1629 + notes->src->widths.max_ins_name); 1629 1630 } 1630 1631 1631 1632 static void ipc_coverage_string(char *bf, int size, struct annotation *notes) ··· 1754 1753 obj__printf(obj, "%-*s", width - pcnt_width - cycles_width, " "); 1755 1754 else if (al->offset == -1) { 1756 1755 if (al->line_nr && annotate_opts.show_linenr) 1757 - printed = scnprintf(bf, sizeof(bf), "%-*d ", notes->widths.addr + 1, al->line_nr); 1756 + printed = scnprintf(bf, sizeof(bf), "%-*d ", 1757 + notes->src->widths.addr + 1, al->line_nr); 1758 1758 else 1759 - printed = scnprintf(bf, sizeof(bf), "%-*s ", notes->widths.addr, " "); 1759 + printed = scnprintf(bf, sizeof(bf), "%-*s ", 1760 + notes->src->widths.addr, " "); 1760 1761 obj__printf(obj, bf); 1761 1762 obj__printf(obj, "%-*s", width - printed - pcnt_width - cycles_width + 1, al->line); 1762 1763 } else { ··· 1776 1773 if (annotate_opts.show_nr_jumps) { 1777 1774 int prev; 1778 1775 printed = scnprintf(bf, sizeof(bf), "%*d ", 1779 - notes->widths.jumps, 1776 + notes->src->widths.jumps, 1780 1777 al->jump_sources); 1781 1778 prev = obj__set_jumps_percent_color(obj, al->jump_sources, 1782 1779 current_entry); ··· 1785 1782 } 1786 1783 print_addr: 1787 1784 printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ": ", 1788 - notes->widths.target, addr); 1785 + notes->src->widths.target, addr); 1789 1786 } else if (ins__is_call(&disasm_line(al)->ins) && 1790 1787 annotate_opts.offset_level >= ANNOTATION__OFFSET_CALL) { 1791 1788 goto print_addr; ··· 1793 1790 goto print_addr; 1794 1791 } else { 1795 1792 printed = scnprintf(bf, sizeof(bf), "%-*s ", 1796 - notes->widths.addr, " "); 1793 + notes->src->widths.addr, " "); 1797 1794 } 1798 1795 } 1799 1796
+10 -10
tools/perf/util/annotate.h
··· 250 250 * @nr_entries: Number of annotated_line in the source list. 251 251 * @nr_asm_entries: Number of annotated_line with actual asm instruction in the 252 252 * source list. 253 - * @max_line_len: Maximum length of objdump output in an annotated_line. 253 + * @widths: Precalculated width of each column in the TUI output. 254 254 * 255 255 * disasm_lines are allocated, percentages calculated and all sorted by percentage 256 256 * when the annotation is about to be presented, so the percentages are for ··· 265 265 int nr_histograms; 266 266 int nr_entries; 267 267 int nr_asm_entries; 268 - u16 max_line_len; 268 + struct { 269 + u8 addr; 270 + u8 jumps; 271 + u8 target; 272 + u8 min_addr; 273 + u8 max_addr; 274 + u8 max_ins_name; 275 + u16 max_line_len; 276 + } widths; 269 277 }; 270 278 271 279 struct annotation_line *annotated_source__get_line(struct annotated_source *src, ··· 310 302 u64 start; 311 303 int nr_events; 312 304 int max_jump_sources; 313 - struct { 314 - u8 addr; 315 - u8 jumps; 316 - u8 target; 317 - u8 min_addr; 318 - u8 max_addr; 319 - u8 max_ins_name; 320 - } widths; 321 305 struct annotated_source *src; 322 306 struct annotated_branch *branch; 323 307 };