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

perf thread: Introduce thread__find_symbol()

Out of thread__find_addr_location(..., MAP__FUNCTION, ...), idea here is to
continue removing references to MAP__{FUNCTION,VARIABLE} ahead of
getting both types of symbols in the same rbtree, as various places do
two lookups, looking first at MAP__FUNCTION, then at MAP__VARIABLE.

So thread__find_symbol() will eventually do just that, and 'struct
symbol' will have the symbol type, for code that cares about that.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-n7528en9e08yd3flzmb26tth@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+26 -27
+1 -2
tools/perf/arch/powerpc/util/skip-callchain-idx.c
··· 248 248 249 249 ip = chain->ips[2]; 250 250 251 - thread__find_addr_location(thread, PERF_RECORD_MISC_USER, 252 - MAP__FUNCTION, ip, &al); 251 + thread__find_symbol(thread, PERF_RECORD_MISC_USER, ip, &al); 253 252 254 253 if (al.map) 255 254 dso = al.map->dso;
+1 -2
tools/perf/builtin-timechart.c
··· 533 533 } 534 534 535 535 tal.filtered = 0; 536 - thread__find_addr_location(al.thread, cpumode, 537 - MAP__FUNCTION, ip, &tal); 536 + thread__find_symbol(al.thread, cpumode, ip, &tal); 538 537 539 538 if (tal.sym) 540 539 fprintf(f, "..... %016" PRIx64 " %s\n", ip,
+3 -6
tools/perf/builtin-trace.c
··· 2024 2024 if (trace->summary_only) 2025 2025 goto out; 2026 2026 2027 - thread__find_addr_location(thread, sample->cpumode, MAP__FUNCTION, 2028 - sample->ip, &al); 2027 + thread__find_symbol(thread, sample->cpumode, sample->ip, &al); 2029 2028 2030 2029 trace__fprintf_entry_head(trace, thread, 0, true, sample->time, trace->output); 2031 2030 ··· 2036 2037 2037 2038 fprintf(trace->output, "] => "); 2038 2039 2039 - thread__find_addr_location(thread, sample->cpumode, MAP__VARIABLE, 2040 - sample->addr, &al); 2040 + __thread__find_symbol(thread, sample->cpumode, MAP__VARIABLE, sample->addr, &al); 2041 2041 2042 2042 if (!al.map) { 2043 - thread__find_addr_location(thread, sample->cpumode, 2044 - MAP__FUNCTION, sample->addr, &al); 2043 + thread__find_symbol(thread, sample->cpumode, sample->addr, &al); 2045 2044 2046 2045 if (al.map) 2047 2046 map_type = 'x';
+3 -3
tools/perf/util/event.c
··· 1564 1564 } 1565 1565 } 1566 1566 1567 - void thread__find_addr_location(struct thread *thread, 1568 - u8 cpumode, enum map_type type, u64 addr, 1569 - struct addr_location *al) 1567 + void __thread__find_symbol(struct thread *thread, u8 cpumode, 1568 + enum map_type type, u64 addr, 1569 + struct addr_location *al) 1570 1570 { 1571 1571 __thread__find_map(thread, cpumode, type, addr, al); 1572 1572 if (al->map != NULL)
+3 -4
tools/perf/util/machine.c
··· 1681 1681 1682 1682 memset(&al, 0, sizeof(al)); 1683 1683 1684 - thread__find_addr_location(thread, m, MAP__VARIABLE, addr, &al); 1684 + __thread__find_symbol(thread, m, MAP__VARIABLE, addr, &al); 1685 1685 if (al.map == NULL) { 1686 1686 /* 1687 1687 * some shared data regions have execute bit set which puts 1688 1688 * their mapping in the MAP__FUNCTION type array. 1689 1689 * Check there as a fallback option before dropping the sample. 1690 1690 */ 1691 - thread__find_addr_location(thread, m, MAP__FUNCTION, addr, &al); 1691 + thread__find_symbol(thread, m, addr, &al); 1692 1692 } 1693 1693 1694 1694 ams->addr = addr; ··· 1784 1784 } 1785 1785 return 0; 1786 1786 } 1787 - thread__find_addr_location(thread, *cpumode, MAP__FUNCTION, 1788 - ip, &al); 1787 + thread__find_symbol(thread, *cpumode, ip, &al); 1789 1788 } 1790 1789 1791 1790 if (al.sym != NULL) {
+1 -1
tools/perf/util/thread.c
··· 384 384 }; 385 385 386 386 for (i = 0; i < ARRAY_SIZE(cpumodes); i++) { 387 - thread__find_addr_location(thread, cpumodes[i], type, addr, al); 387 + __thread__find_symbol(thread, cpumodes[i], type, addr, al); 388 388 if (al->map) 389 389 break; 390 390 }
+8 -3
tools/perf/util/thread.h
··· 101 101 __thread__find_map(thread, cpumode, MAP__FUNCTION, addr, al); 102 102 } 103 103 104 - void thread__find_addr_location(struct thread *thread, 105 - u8 cpumode, enum map_type type, u64 addr, 106 - struct addr_location *al); 104 + void __thread__find_symbol(struct thread *thread, u8 cpumode, enum map_type type, 105 + u64 addr, struct addr_location *al); 106 + 107 + static inline void thread__find_symbol(struct thread *thread, u8 cpumode, 108 + u64 addr, struct addr_location *al) 109 + { 110 + return __thread__find_symbol(thread, cpumode, MAP__FUNCTION, addr, al); 111 + } 107 112 108 113 void thread__find_cpumode_addr_location(struct thread *thread, 109 114 enum map_type type, u64 addr,
+5 -4
tools/perf/util/unwind-libdw.c
··· 28 28 { 29 29 Dwfl_Module *mod; 30 30 struct dso *dso = NULL; 31 - 32 - thread__find_addr_location(ui->thread, 33 - PERF_RECORD_MISC_USER, 34 - MAP__FUNCTION, ip, al); 31 + /* 32 + * Some callers will use al->sym, so we can't just use the 33 + * cheaper thread__find_map() here. 34 + */ 35 + thread__find_symbol(ui->thread, PERF_RECORD_MISC_USER, ip, al); 35 36 36 37 if (al->map) 37 38 dso = al->map->dso;
+1 -2
tools/perf/util/unwind-libunwind-local.c
··· 585 585 struct unwind_entry e; 586 586 struct addr_location al; 587 587 588 - thread__find_addr_location(thread, PERF_RECORD_MISC_USER, 589 - MAP__FUNCTION, ip, &al); 588 + thread__find_symbol(thread, PERF_RECORD_MISC_USER, ip, &al); 590 589 591 590 e.ip = al.addr; 592 591 e.map = al.map;