We faced segmentation fault on perf top -G at very high sampling rate due to a corrupted callchain. While the root cause was not revealed (I failed to figure it out), this patch tries to protect us from the segfault on such cases.
Showing the changes to include (1 of 2 files). Show all
Unified · Split
| @@ -555,6 +555,8 @@ enum perf_event_type { · 554 unmodified lines | ||
| 555 | 555 | PERF_RECORD_MAX, /* non-ABI */ |
| 556 | 556 | }; |
| 557 | 557 | |
| 558 | +#define PERF_MAX_STACK_DEPTH 255 | |
| 559 | + | |
| 558 | 560 | enum perf_callchain_context { |
| 559 | 561 | PERF_CONTEXT_HV = (__u64)-32, |
| 560 | 562 | PERF_CONTEXT_KERNEL = (__u64)-128, |
| @@ -609,8 +611,6 @@ struct perf_guest_info_callbacks { · 48 unmodified lines | ||
| 609 | 611 | #include <linux/sysfs.h> |
| 610 | 612 | #include <asm/local.h> |
| 611 | 613 | |
| 612 | −#define PERF_MAX_STACK_DEPTH 255 | |
| 613 | − | |
| 614 | 614 | struct perf_callchain_entry { |
| 615 | 615 | __u64 nr; |
| 616 | 616 | __u64 ip[PERF_MAX_STACK_DEPTH]; |