if (sysctl__read_int("kernel/perf_event_max_stack", &value) == 0)
sysctl_perf_event_max_stack = value;
+ if (sysctl__read_int("kernel/perf_event_max_contexts_per_stack", &value) == 0)
+ sysctl_perf_event_max_contexts_per_stack = value;
+
cmd = extract_argv0_path(argv[0]);
if (!cmd)
cmd = "perf-help";
{
struct branch_stack *branch = sample->branch_stack;
struct ip_callchain *chain = sample->callchain;
- int chain_nr = min(max_stack, (int)chain->nr);
+ int chain_nr = chain->nr;
u8 cpumode = PERF_RECORD_MISC_USER;
- int i, j, err;
+ int i, j, err, nr_entries, nr_contexts;
int skip_idx = -1;
int first_call = 0;
* Based on DWARF debug information, some architectures skip
* a callchain entry saved by the kernel.
*/
- if (chain->nr < sysctl_perf_event_max_stack)
+ if (chain_nr < sysctl_perf_event_max_stack)
skip_idx = arch_skip_callchain_idx(thread, chain);
/*
}
check_calls:
- if (chain->nr > sysctl_perf_event_max_stack && (int)chain->nr > max_stack) {
- pr_warning("corrupted callchain. skipping...\n");
- return 0;
- }
-
- for (i = first_call; i < chain_nr; i++) {
+ for (i = first_call, nr_entries = 0, nr_contexts = 0;
+ i < chain_nr && nr_entries < max_stack; i++) {
u64 ip;
if (callchain_param.order == ORDER_CALLEE)
#endif
ip = chain->ips[j];
+ if (ip >= PERF_CONTEXT_MAX) {
+ if (++nr_contexts > sysctl_perf_event_max_contexts_per_stack)
+ 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);
if (err)
}
return 0;
+
+out_corrupted_callchain:
+ pr_warning("corrupted callchain. skipping...\n");
+ return 0;
}
static int unwind_entry(struct unwind_entry *entry, void *arg)