The perf_sample->ip_callchain->nr value includes all the entries in the ip_callchain->ip[] array, real addresses and PERF_CONTEXT_{KERNEL,USER,etc}, while what the user expects is that what is in the kernel.perf_event_max_stack sysctl or in the upcoming per event perf_event_attr.sample_max_stack knob be honoured in terms of IP addresses in the stack trace. So allocate a bunch of extra entries for contexts, and do the accounting via perf_callchain_entry_ctx struct members. A new sysctl, kernel.perf_event_max_contexts_per_stack is also introduced for investigating possible bugs in the callchain implementation by some arch.
Showing the changes to include/uapi (1 of 5 files). Show all
Unified · Split
| @@ -862,6 +862,7 @@ enum perf_event_type { · 861 unmodified lines | |||
| 862 | }; | 862 | }; |
| 863 | 863 | ||
| 864 | #define PERF_MAX_STACK_DEPTH 127 | 864 | #define PERF_MAX_STACK_DEPTH 127 |
| 865 | #define PERF_MAX_CONTEXTS_PER_STACK 8 | ||
| 865 | 866 | ||
| 866 | enum perf_callchain_context { | 867 | enum perf_callchain_context { |
| 867 | PERF_CONTEXT_HV = (__u64)-32, | 868 | PERF_CONTEXT_HV = (__u64)-32, |