Commit 73dbcd65 authored by David Hildenbrand's avatar David Hildenbrand Committed by Arnaldo Carvalho de Melo

perf callchain: Fix kernel symbol resolution by remembering the cpumode

Commit 2e77784b ("perf callchain: Move cpumode resolve code to
add_callchain_ip") promised "No change in behavior.".

As this commit breaks callchains on s390x (symbols not getting resolved,
observed when profiling the kernel), this statement is wrong. The cpumode
must be kept when iterating over all ips, otherwise the default
(PERF_RECORD_MISC_USER) will be used by error.
Signed-off-by: default avatarDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Hildenbrand <dahi@linux.vnet.ibm.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1427703060-59883-1-git-send-email-dahi@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 6ab2b762
...@@ -1408,29 +1408,27 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample, ...@@ -1408,29 +1408,27 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample,
static int add_callchain_ip(struct thread *thread, static int add_callchain_ip(struct thread *thread,
struct symbol **parent, struct symbol **parent,
struct addr_location *root_al, struct addr_location *root_al,
bool branch_history, u8 *cpumode,
u64 ip) u64 ip)
{ {
struct addr_location al; struct addr_location al;
al.filtered = 0; al.filtered = 0;
al.sym = NULL; al.sym = NULL;
if (branch_history) if (!cpumode) {
thread__find_cpumode_addr_location(thread, MAP__FUNCTION, thread__find_cpumode_addr_location(thread, MAP__FUNCTION,
ip, &al); ip, &al);
else { } else {
u8 cpumode = PERF_RECORD_MISC_USER;
if (ip >= PERF_CONTEXT_MAX) { if (ip >= PERF_CONTEXT_MAX) {
switch (ip) { switch (ip) {
case PERF_CONTEXT_HV: case PERF_CONTEXT_HV:
cpumode = PERF_RECORD_MISC_HYPERVISOR; *cpumode = PERF_RECORD_MISC_HYPERVISOR;
break; break;
case PERF_CONTEXT_KERNEL: case PERF_CONTEXT_KERNEL:
cpumode = PERF_RECORD_MISC_KERNEL; *cpumode = PERF_RECORD_MISC_KERNEL;
break; break;
case PERF_CONTEXT_USER: case PERF_CONTEXT_USER:
cpumode = PERF_RECORD_MISC_USER; *cpumode = PERF_RECORD_MISC_USER;
break; break;
default: default:
pr_debug("invalid callchain context: " pr_debug("invalid callchain context: "
...@@ -1444,8 +1442,8 @@ static int add_callchain_ip(struct thread *thread, ...@@ -1444,8 +1442,8 @@ static int add_callchain_ip(struct thread *thread,
} }
return 0; return 0;
} }
thread__find_addr_location(thread, cpumode, MAP__FUNCTION, thread__find_addr_location(thread, *cpumode, MAP__FUNCTION,
ip, &al); ip, &al);
} }
if (al.sym != NULL) { if (al.sym != NULL) {
...@@ -1538,6 +1536,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread, ...@@ -1538,6 +1536,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
{ {
struct ip_callchain *chain = sample->callchain; struct ip_callchain *chain = sample->callchain;
int chain_nr = min(max_stack, (int)chain->nr); int chain_nr = min(max_stack, (int)chain->nr);
u8 cpumode = PERF_RECORD_MISC_USER;
int i, j, err; int i, j, err;
u64 ip; u64 ip;
...@@ -1584,7 +1583,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread, ...@@ -1584,7 +1583,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
ip = lbr_stack->entries[0].to; ip = lbr_stack->entries[0].to;
} }
err = add_callchain_ip(thread, parent, root_al, false, ip); err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
if (err) if (err)
return (err < 0) ? err : 0; return (err < 0) ? err : 0;
} }
...@@ -1604,6 +1603,7 @@ static int thread__resolve_callchain_sample(struct thread *thread, ...@@ -1604,6 +1603,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
struct branch_stack *branch = sample->branch_stack; struct branch_stack *branch = sample->branch_stack;
struct ip_callchain *chain = sample->callchain; struct ip_callchain *chain = sample->callchain;
int chain_nr = min(max_stack, (int)chain->nr); int chain_nr = min(max_stack, (int)chain->nr);
u8 cpumode = PERF_RECORD_MISC_USER;
int i, j, err; int i, j, err;
int skip_idx = -1; int skip_idx = -1;
int first_call = 0; int first_call = 0;
...@@ -1669,10 +1669,10 @@ static int thread__resolve_callchain_sample(struct thread *thread, ...@@ -1669,10 +1669,10 @@ static int thread__resolve_callchain_sample(struct thread *thread,
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
err = add_callchain_ip(thread, parent, root_al, err = add_callchain_ip(thread, parent, root_al,
true, be[i].to); NULL, be[i].to);
if (!err) if (!err)
err = add_callchain_ip(thread, parent, root_al, err = add_callchain_ip(thread, parent, root_al,
true, be[i].from); NULL, be[i].from);
if (err == -EINVAL) if (err == -EINVAL)
break; break;
if (err) if (err)
...@@ -1701,7 +1701,7 @@ static int thread__resolve_callchain_sample(struct thread *thread, ...@@ -1701,7 +1701,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
#endif #endif
ip = chain->ips[j]; ip = chain->ips[j];
err = add_callchain_ip(thread, parent, root_al, false, ip); err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
if (err) if (err)
return (err < 0) ? err : 0; return (err < 0) ? err : 0;
......
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