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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ea40b6d3
...@@ -248,8 +248,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain) ...@@ -248,8 +248,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
ip = chain->ips[2]; ip = chain->ips[2];
thread__find_addr_location(thread, PERF_RECORD_MISC_USER, thread__find_symbol(thread, PERF_RECORD_MISC_USER, ip, &al);
MAP__FUNCTION, ip, &al);
if (al.map) if (al.map)
dso = al.map->dso; dso = al.map->dso;
......
...@@ -533,8 +533,7 @@ static const char *cat_backtrace(union perf_event *event, ...@@ -533,8 +533,7 @@ static const char *cat_backtrace(union perf_event *event,
} }
tal.filtered = 0; tal.filtered = 0;
thread__find_addr_location(al.thread, cpumode, thread__find_symbol(al.thread, cpumode, ip, &tal);
MAP__FUNCTION, ip, &tal);
if (tal.sym) if (tal.sym)
fprintf(f, "..... %016" PRIx64 " %s\n", ip, fprintf(f, "..... %016" PRIx64 " %s\n", ip,
......
...@@ -2024,8 +2024,7 @@ static int trace__pgfault(struct trace *trace, ...@@ -2024,8 +2024,7 @@ static int trace__pgfault(struct trace *trace,
if (trace->summary_only) if (trace->summary_only)
goto out; goto out;
thread__find_addr_location(thread, sample->cpumode, MAP__FUNCTION, thread__find_symbol(thread, sample->cpumode, sample->ip, &al);
sample->ip, &al);
trace__fprintf_entry_head(trace, thread, 0, true, sample->time, trace->output); trace__fprintf_entry_head(trace, thread, 0, true, sample->time, trace->output);
...@@ -2037,12 +2036,10 @@ static int trace__pgfault(struct trace *trace, ...@@ -2037,12 +2036,10 @@ static int trace__pgfault(struct trace *trace,
fprintf(trace->output, "] => "); fprintf(trace->output, "] => ");
thread__find_addr_location(thread, sample->cpumode, MAP__VARIABLE, __thread__find_symbol(thread, sample->cpumode, MAP__VARIABLE, sample->addr, &al);
sample->addr, &al);
if (!al.map) { if (!al.map) {
thread__find_addr_location(thread, sample->cpumode, thread__find_symbol(thread, sample->cpumode, sample->addr, &al);
MAP__FUNCTION, sample->addr, &al);
if (al.map) if (al.map)
map_type = 'x'; map_type = 'x';
......
...@@ -1564,9 +1564,9 @@ void __thread__find_map(struct thread *thread, u8 cpumode, enum map_type type, ...@@ -1564,9 +1564,9 @@ void __thread__find_map(struct thread *thread, u8 cpumode, enum map_type type,
} }
} }
void thread__find_addr_location(struct thread *thread, void __thread__find_symbol(struct thread *thread, u8 cpumode,
u8 cpumode, enum map_type type, u64 addr, enum map_type type, u64 addr,
struct addr_location *al) struct addr_location *al)
{ {
__thread__find_map(thread, cpumode, type, addr, al); __thread__find_map(thread, cpumode, type, addr, al);
if (al->map != NULL) if (al->map != NULL)
......
...@@ -1681,14 +1681,14 @@ static void ip__resolve_data(struct thread *thread, ...@@ -1681,14 +1681,14 @@ static void ip__resolve_data(struct thread *thread,
memset(&al, 0, sizeof(al)); memset(&al, 0, sizeof(al));
thread__find_addr_location(thread, m, MAP__VARIABLE, addr, &al); __thread__find_symbol(thread, m, MAP__VARIABLE, addr, &al);
if (al.map == NULL) { if (al.map == NULL) {
/* /*
* some shared data regions have execute bit set which puts * some shared data regions have execute bit set which puts
* their mapping in the MAP__FUNCTION type array. * their mapping in the MAP__FUNCTION type array.
* Check there as a fallback option before dropping the sample. * Check there as a fallback option before dropping the sample.
*/ */
thread__find_addr_location(thread, m, MAP__FUNCTION, addr, &al); thread__find_symbol(thread, m, addr, &al);
} }
ams->addr = addr; ams->addr = addr;
...@@ -1784,8 +1784,7 @@ static int add_callchain_ip(struct thread *thread, ...@@ -1784,8 +1784,7 @@ static int add_callchain_ip(struct thread *thread,
} }
return 0; return 0;
} }
thread__find_addr_location(thread, *cpumode, MAP__FUNCTION, thread__find_symbol(thread, *cpumode, ip, &al);
ip, &al);
} }
if (al.sym != NULL) { if (al.sym != NULL) {
......
...@@ -384,7 +384,7 @@ void thread__find_cpumode_addr_location(struct thread *thread, ...@@ -384,7 +384,7 @@ void thread__find_cpumode_addr_location(struct thread *thread,
}; };
for (i = 0; i < ARRAY_SIZE(cpumodes); i++) { for (i = 0; i < ARRAY_SIZE(cpumodes); i++) {
thread__find_addr_location(thread, cpumodes[i], type, addr, al); __thread__find_symbol(thread, cpumodes[i], type, addr, al);
if (al->map) if (al->map)
break; break;
} }
......
...@@ -101,9 +101,14 @@ static inline void thread__find_map(struct thread *thread, u8 cpumode, ...@@ -101,9 +101,14 @@ static inline void thread__find_map(struct thread *thread, u8 cpumode,
__thread__find_map(thread, cpumode, MAP__FUNCTION, addr, al); __thread__find_map(thread, cpumode, MAP__FUNCTION, addr, al);
} }
void thread__find_addr_location(struct thread *thread, void __thread__find_symbol(struct thread *thread, u8 cpumode, enum map_type type,
u8 cpumode, enum map_type type, u64 addr, u64 addr, struct addr_location *al);
struct addr_location *al);
static inline void thread__find_symbol(struct thread *thread, u8 cpumode,
u64 addr, struct addr_location *al)
{
return __thread__find_symbol(thread, cpumode, MAP__FUNCTION, addr, al);
}
void thread__find_cpumode_addr_location(struct thread *thread, void thread__find_cpumode_addr_location(struct thread *thread,
enum map_type type, u64 addr, enum map_type type, u64 addr,
......
...@@ -28,10 +28,11 @@ static int __report_module(struct addr_location *al, u64 ip, ...@@ -28,10 +28,11 @@ static int __report_module(struct addr_location *al, u64 ip,
{ {
Dwfl_Module *mod; Dwfl_Module *mod;
struct dso *dso = NULL; struct dso *dso = NULL;
/*
thread__find_addr_location(ui->thread, * Some callers will use al->sym, so we can't just use the
PERF_RECORD_MISC_USER, * cheaper thread__find_map() here.
MAP__FUNCTION, ip, al); */
thread__find_symbol(ui->thread, PERF_RECORD_MISC_USER, ip, al);
if (al->map) if (al->map)
dso = al->map->dso; dso = al->map->dso;
......
...@@ -585,8 +585,7 @@ static int entry(u64 ip, struct thread *thread, ...@@ -585,8 +585,7 @@ static int entry(u64 ip, struct thread *thread,
struct unwind_entry e; struct unwind_entry e;
struct addr_location al; struct addr_location al;
thread__find_addr_location(thread, PERF_RECORD_MISC_USER, thread__find_symbol(thread, PERF_RECORD_MISC_USER, ip, &al);
MAP__FUNCTION, ip, &al);
e.ip = al.addr; e.ip = al.addr;
e.map = al.map; e.map = al.map;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment