jump label: Introduce static_branch() interface
[firefly-linux-kernel-4.4.55.git] / include / linux / perf_event.h
index 614615b8d42b851481a624aeabcb110e7e27078e..730b7821690fc1197dc9d16a7aab382184587ce3 100644 (file)
@@ -505,7 +505,7 @@ struct perf_guest_info_callbacks {
 #include <linux/ftrace.h>
 #include <linux/cpu.h>
 #include <linux/irq_work.h>
-#include <linux/jump_label_ref.h>
+#include <linux/jump_label.h>
 #include <asm/atomic.h>
 #include <asm/local.h>
 
@@ -878,8 +878,8 @@ enum perf_event_context_type {
  * Used as a container for task events and CPU events as well:
  */
 struct perf_event_context {
-       enum perf_event_context_type    type;
        struct pmu                      *pmu;
+       enum perf_event_context_type    type;
        /*
         * Protect the states of the events in the list,
         * nr_active, and the list:
@@ -938,9 +938,7 @@ struct perf_cpu_context {
        struct list_head                rotation_list;
        int                             jiffies_interval;
        struct pmu                      *active_pmu;
-#ifdef CONFIG_CGROUP_PERF
        struct perf_cgroup              *cgrp;
-#endif
 };
 
 struct perf_output_handle {
@@ -1036,7 +1034,7 @@ static inline int is_software_event(struct perf_event *event)
        return event->pmu->task_ctx_nr == perf_sw_context;
 }
 
-extern atomic_t perf_swevent_enabled[PERF_COUNT_SW_MAX];
+extern struct jump_label_key perf_swevent_enabled[PERF_COUNT_SW_MAX];
 
 extern void __perf_sw_event(u32, u64, int, struct pt_regs *, u64);
 
@@ -1065,22 +1063,21 @@ perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
 {
        struct pt_regs hot_regs;
 
-       JUMP_LABEL(&perf_swevent_enabled[event_id], have_event);
-       return;
-
-have_event:
-       if (!regs) {
-               perf_fetch_caller_regs(&hot_regs);
-               regs = &hot_regs;
+       if (static_branch(&perf_swevent_enabled[event_id])) {
+               if (!regs) {
+                       perf_fetch_caller_regs(&hot_regs);
+                       regs = &hot_regs;
+               }
+               __perf_sw_event(event_id, nr, nmi, regs, addr);
        }
-       __perf_sw_event(event_id, nr, nmi, regs, addr);
 }
 
-extern atomic_t perf_sched_events;
+extern struct jump_label_key perf_sched_events;
 
 static inline void perf_event_task_sched_in(struct task_struct *task)
 {
-       COND_STMT(&perf_sched_events, __perf_event_task_sched_in(task));
+       if (static_branch(&perf_sched_events))
+               __perf_event_task_sched_in(task);
 }
 
 static inline
@@ -1088,7 +1085,8 @@ void perf_event_task_sched_out(struct task_struct *task, struct task_struct *nex
 {
        perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 1, NULL, 0);
 
-       COND_STMT(&perf_sched_events, __perf_event_task_sched_out(task, next));
+       if (static_branch(&perf_sched_events))
+               __perf_event_task_sched_out(task, next);
 }
 
 extern void perf_event_mmap(struct vm_area_struct *vma);