perf callchain: Stop validating callchains by the max_stack sysctl

As thread__resolve_callchain_sample can be used for handling perf.data
files, that could've been recorded with a large max_stack sysctl setting
than what the system used for analysis has set.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Zefan Li <lizefan@huawei.com>
Link: http://lkml.kernel.org/n/tip-2995bt2g5yq2m05vga4kip6m@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c008f78f
...@@ -1771,11 +1771,6 @@ static int resolve_lbr_callchain_sample(struct thread *thread, ...@@ -1771,11 +1771,6 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
*/ */
int mix_chain_nr = i + 1 + lbr_nr + 1; int mix_chain_nr = i + 1 + lbr_nr + 1;
if (mix_chain_nr > (int)sysctl_perf_event_max_stack + PERF_MAX_BRANCH_DEPTH) {
pr_warning("corrupted callchain. skipping...\n");
return 0;
}
for (j = 0; j < mix_chain_nr; j++) { for (j = 0; j < mix_chain_nr; j++) {
if (callchain_param.order == ORDER_CALLEE) { if (callchain_param.order == ORDER_CALLEE) {
if (j < i + 1) if (j < i + 1)
...@@ -1815,7 +1810,7 @@ static int thread__resolve_callchain_sample(struct thread *thread, ...@@ -1815,7 +1810,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
struct ip_callchain *chain = sample->callchain; struct ip_callchain *chain = sample->callchain;
int chain_nr = chain->nr; int chain_nr = chain->nr;
u8 cpumode = PERF_RECORD_MISC_USER; u8 cpumode = PERF_RECORD_MISC_USER;
int i, j, err, nr_entries, nr_contexts; int i, j, err, nr_entries;
int skip_idx = -1; int skip_idx = -1;
int first_call = 0; int first_call = 0;
...@@ -1830,8 +1825,7 @@ static int thread__resolve_callchain_sample(struct thread *thread, ...@@ -1830,8 +1825,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
* Based on DWARF debug information, some architectures skip * Based on DWARF debug information, some architectures skip
* a callchain entry saved by the kernel. * a callchain entry saved by the kernel.
*/ */
if (chain_nr < sysctl_perf_event_max_stack) skip_idx = arch_skip_callchain_idx(thread, chain);
skip_idx = arch_skip_callchain_idx(thread, chain);
/* /*
* Add branches to call stack for easier browsing. This gives * Add branches to call stack for easier browsing. This gives
...@@ -1891,7 +1885,7 @@ static int thread__resolve_callchain_sample(struct thread *thread, ...@@ -1891,7 +1885,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
} }
check_calls: check_calls:
for (i = first_call, nr_entries = 0, nr_contexts = 0; for (i = first_call, nr_entries = 0;
i < chain_nr && nr_entries < max_stack; i++) { i < chain_nr && nr_entries < max_stack; i++) {
u64 ip; u64 ip;
...@@ -1906,13 +1900,8 @@ static int thread__resolve_callchain_sample(struct thread *thread, ...@@ -1906,13 +1900,8 @@ static int thread__resolve_callchain_sample(struct thread *thread,
#endif #endif
ip = chain->ips[j]; ip = chain->ips[j];
if (ip >= PERF_CONTEXT_MAX) { if (ip < PERF_CONTEXT_MAX)
if (++nr_contexts > sysctl_perf_event_max_contexts_per_stack) ++nr_entries;
goto out_corrupted_callchain;
} else {
if (++nr_entries > sysctl_perf_event_max_stack)
goto out_corrupted_callchain;
}
err = add_callchain_ip(thread, cursor, parent, root_al, &cpumode, ip); err = add_callchain_ip(thread, cursor, parent, root_al, &cpumode, ip);
...@@ -1921,10 +1910,6 @@ static int thread__resolve_callchain_sample(struct thread *thread, ...@@ -1921,10 +1910,6 @@ static int thread__resolve_callchain_sample(struct thread *thread,
} }
return 0; return 0;
out_corrupted_callchain:
pr_warning("corrupted callchain. skipping...\n");
return 0;
} }
static int unwind_entry(struct unwind_entry *entry, void *arg) static int unwind_entry(struct unwind_entry *entry, void *arg)
......
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