Additionally to being able to control the system wide maximum depth via /proc/sys/kernel/perf_event_max_stack, now we are able to ask for different depths per event, using perf_event_attr.sample_max_stack for that. This uses an u16 hole at the end of perf_event_attr, that, when perf_event_attr.sample_type has the PERF_SAMPLE_CALLCHAIN, if sample_max_stack is zero, means use perf_event_max_stack, otherwise it'll be bounds checked under callchain_mutex.
Showing the changes to include/uapi/linux (1 of 5 files). Show all
Unified · Split
| @@ -276,6 +276,9 @@ enum perf_event_read_format { · 275 unmodified lines | |||
| 276 | 276 | ||
| 277 | /* | 277 | /* |
| 278 | * Hardware event_id to monitor via a performance monitoring event: | 278 | * Hardware event_id to monitor via a performance monitoring event: |
| 279 | * | ||
| 280 | * @sample_max_stack: Max number of frame pointers in a callchain, | ||
| 281 | * should be < /proc/sys/kernel/perf_event_max_stack | ||
| 279 | */ | 282 | */ |
| 280 | struct perf_event_attr { | 283 | struct perf_event_attr { |
| 281 | 284 | ||
| @@ -385,7 +388,8 @@ struct perf_event_attr { · 103 unmodified lines | |||
| 385 | * Wakeup watermark for AUX area | 388 | * Wakeup watermark for AUX area |
| 386 | */ | 389 | */ |
| 387 | __u32 aux_watermark; | 390 | __u32 aux_watermark; |
| 388 | __u32 __reserved_2; /* align to __u64 */ | 391 | __u16 sample_max_stack; |
| 392 | __u16 __reserved_2; /* align to __u64 */ | ||
| 389 | }; | 393 | }; |
| 390 | 394 | ||
| 391 | #define perf_flags(attr) (*(&(attr)->read_format + 1)) | 395 | #define perf_flags(attr) (*(&(attr)->read_format + 1)) |