Skip to content

Commit bf8bddb

Browse files
committed
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 <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Brendan Gregg <[email protected]> Cc: David Ahern <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: He Kuang <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Milian Wolff <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Cc: Wang Nan <[email protected]> Cc: Zefan Li <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent c008f78 commit bf8bddb

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

tools/perf/util/machine.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,11 +1771,6 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
17711771
*/
17721772
int mix_chain_nr = i + 1 + lbr_nr + 1;
17731773

1774-
if (mix_chain_nr > (int)sysctl_perf_event_max_stack + PERF_MAX_BRANCH_DEPTH) {
1775-
pr_warning("corrupted callchain. skipping...\n");
1776-
return 0;
1777-
}
1778-
17791774
for (j = 0; j < mix_chain_nr; j++) {
17801775
if (callchain_param.order == ORDER_CALLEE) {
17811776
if (j < i + 1)
@@ -1815,7 +1810,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
18151810
struct ip_callchain *chain = sample->callchain;
18161811
int chain_nr = chain->nr;
18171812
u8 cpumode = PERF_RECORD_MISC_USER;
1818-
int i, j, err, nr_entries, nr_contexts;
1813+
int i, j, err, nr_entries;
18191814
int skip_idx = -1;
18201815
int first_call = 0;
18211816

@@ -1830,8 +1825,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
18301825
* Based on DWARF debug information, some architectures skip
18311826
* a callchain entry saved by the kernel.
18321827
*/
1833-
if (chain_nr < sysctl_perf_event_max_stack)
1834-
skip_idx = arch_skip_callchain_idx(thread, chain);
1828+
skip_idx = arch_skip_callchain_idx(thread, chain);
18351829

18361830
/*
18371831
* Add branches to call stack for easier browsing. This gives
@@ -1891,7 +1885,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
18911885
}
18921886

18931887
check_calls:
1894-
for (i = first_call, nr_entries = 0, nr_contexts = 0;
1888+
for (i = first_call, nr_entries = 0;
18951889
i < chain_nr && nr_entries < max_stack; i++) {
18961890
u64 ip;
18971891

@@ -1906,13 +1900,8 @@ static int thread__resolve_callchain_sample(struct thread *thread,
19061900
#endif
19071901
ip = chain->ips[j];
19081902

1909-
if (ip >= PERF_CONTEXT_MAX) {
1910-
if (++nr_contexts > sysctl_perf_event_max_contexts_per_stack)
1911-
goto out_corrupted_callchain;
1912-
} else {
1913-
if (++nr_entries > sysctl_perf_event_max_stack)
1914-
goto out_corrupted_callchain;
1915-
}
1903+
if (ip < PERF_CONTEXT_MAX)
1904+
++nr_entries;
19161905

19171906
err = add_callchain_ip(thread, cursor, parent, root_al, &cpumode, ip);
19181907

@@ -1921,10 +1910,6 @@ static int thread__resolve_callchain_sample(struct thread *thread,
19211910
}
19221911

19231912
return 0;
1924-
1925-
out_corrupted_callchain:
1926-
pr_warning("corrupted callchain. skipping...\n");
1927-
return 0;
19281913
}
19291914

19301915
static int unwind_entry(struct unwind_entry *entry, void *arg)

0 commit comments

Comments
 (0)