diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/ftrace_event.h | 2 | ||||
| -rw-r--r-- | include/linux/perf_event.h | 28 |
2 files changed, 22 insertions, 8 deletions
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index 0bebb5c348b8..d36f68b08acc 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h | |||
| @@ -595,7 +595,7 @@ extern int ftrace_profile_set_filter(struct perf_event *event, int event_id, | |||
| 595 | char *filter_str); | 595 | char *filter_str); |
| 596 | extern void ftrace_profile_free_filter(struct perf_event *event); | 596 | extern void ftrace_profile_free_filter(struct perf_event *event); |
| 597 | extern void *perf_trace_buf_prepare(int size, unsigned short type, | 597 | extern void *perf_trace_buf_prepare(int size, unsigned short type, |
| 598 | struct pt_regs *regs, int *rctxp); | 598 | struct pt_regs **regs, int *rctxp); |
| 599 | 599 | ||
| 600 | static inline void | 600 | static inline void |
| 601 | perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr, | 601 | perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr, |
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 664de5a4ec46..216653466a67 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
| @@ -659,6 +659,7 @@ static inline int is_software_event(struct perf_event *event) | |||
| 659 | 659 | ||
| 660 | extern struct static_key perf_swevent_enabled[PERF_COUNT_SW_MAX]; | 660 | extern struct static_key perf_swevent_enabled[PERF_COUNT_SW_MAX]; |
| 661 | 661 | ||
| 662 | extern void ___perf_sw_event(u32, u64, struct pt_regs *, u64); | ||
| 662 | extern void __perf_sw_event(u32, u64, struct pt_regs *, u64); | 663 | extern void __perf_sw_event(u32, u64, struct pt_regs *, u64); |
| 663 | 664 | ||
| 664 | #ifndef perf_arch_fetch_caller_regs | 665 | #ifndef perf_arch_fetch_caller_regs |
| @@ -683,14 +684,25 @@ static inline void perf_fetch_caller_regs(struct pt_regs *regs) | |||
| 683 | static __always_inline void | 684 | static __always_inline void |
| 684 | perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr) | 685 | perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr) |
| 685 | { | 686 | { |
| 686 | struct pt_regs hot_regs; | 687 | if (static_key_false(&perf_swevent_enabled[event_id])) |
| 688 | __perf_sw_event(event_id, nr, regs, addr); | ||
| 689 | } | ||
| 690 | |||
| 691 | DECLARE_PER_CPU(struct pt_regs, __perf_regs[4]); | ||
| 687 | 692 | ||
| 693 | /* | ||
| 694 | * 'Special' version for the scheduler, it hard assumes no recursion, | ||
| 695 | * which is guaranteed by us not actually scheduling inside other swevents | ||
| 696 | * because those disable preemption. | ||
| 697 | */ | ||
| 698 | static __always_inline void | ||
| 699 | perf_sw_event_sched(u32 event_id, u64 nr, u64 addr) | ||
| 700 | { | ||
| 688 | if (static_key_false(&perf_swevent_enabled[event_id])) { | 701 | if (static_key_false(&perf_swevent_enabled[event_id])) { |
| 689 | if (!regs) { | 702 | struct pt_regs *regs = this_cpu_ptr(&__perf_regs[0]); |
| 690 | perf_fetch_caller_regs(&hot_regs); | 703 | |
| 691 | regs = &hot_regs; | 704 | perf_fetch_caller_regs(regs); |
| 692 | } | 705 | ___perf_sw_event(event_id, nr, regs, addr); |
| 693 | __perf_sw_event(event_id, nr, regs, addr); | ||
| 694 | } | 706 | } |
| 695 | } | 707 | } |
| 696 | 708 | ||
| @@ -706,7 +718,7 @@ static inline void perf_event_task_sched_in(struct task_struct *prev, | |||
| 706 | static inline void perf_event_task_sched_out(struct task_struct *prev, | 718 | static inline void perf_event_task_sched_out(struct task_struct *prev, |
| 707 | struct task_struct *next) | 719 | struct task_struct *next) |
| 708 | { | 720 | { |
| 709 | perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, NULL, 0); | 721 | perf_sw_event_sched(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 0); |
| 710 | 722 | ||
| 711 | if (static_key_false(&perf_sched_events.key)) | 723 | if (static_key_false(&perf_sched_events.key)) |
| 712 | __perf_event_task_sched_out(prev, next); | 724 | __perf_event_task_sched_out(prev, next); |
| @@ -817,6 +829,8 @@ static inline int perf_event_refresh(struct perf_event *event, int refresh) | |||
| 817 | static inline void | 829 | static inline void |
| 818 | perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr) { } | 830 | perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr) { } |
| 819 | static inline void | 831 | static inline void |
| 832 | perf_sw_event_sched(u32 event_id, u64 nr, u64 addr) { } | ||
| 833 | static inline void | ||
| 820 | perf_bp_event(struct perf_event *event, void *data) { } | 834 | perf_bp_event(struct perf_event *event, void *data) { } |
| 821 | 835 | ||
| 822 | static inline int perf_register_guest_info_callbacks | 836 | static inline int perf_register_guest_info_callbacks |
