Messages in this thread Patch in this message |  | | | Subject | Re: [RFC][PATCH 6/7] perf: use jump_label to optimize the scheduler hooks | | From | Peter Zijlstra <> | | Date | Sun, 17 Oct 2010 12:16:16 +0200 |
| |
On Sun, 2010-10-17 at 11:52 +0200, Peter Zijlstra wrote: > On Thu, 2010-10-14 at 22:34 +0200, Peter Zijlstra wrote: > > +static inline void perf_event_task_sched_in(struct task_struct *task) > > +{ > > + JUMP_LABEL(&perf_task_events, have_events); > > + return; > > + > > +have_events: > > + __perf_event_task_sched_in(task); > > +} > > OK, so I hate the JUMP_LABEL() interface for it means we have to keep > writing these silly stubs.
The below seems to actually compile too, awesome! ;-)
--- Index: linux-2.6/include/linux/jump_label.h =================================================================== --- linux-2.6.orig/include/linux/jump_label.h +++ linux-2.6/include/linux/jump_label.h @@ -61,4 +61,14 @@ static inline int jump_label_text_reserv #endif +#define COND_STMT(key, stmt) \ +do { \ + __label__ jl_enabled; \ + JUMP_LABEL(key, jl_enabled); \ + if (0) { \ +jl_enabled: \ + stmt; \ + } \ +} while (0) + #endif Index: linux-2.6/include/linux/perf_event.h =================================================================== --- linux-2.6.orig/include/linux/perf_event.h +++ linux-2.6/include/linux/perf_event.h @@ -901,21 +901,13 @@ extern atomic_t perf_task_events; static inline void perf_event_task_sched_in(struct task_struct *task) { - JUMP_LABEL(&perf_task_events, have_events); - return; - -have_events: - __perf_event_task_sched_in(task); + COND_STMT(&perf_task_events, __perf_event_task_sched_in(task)); } static inline void perf_event_task_sched_out(struct task_struct *task, struct task_struct *next) { - JUMP_LABEL(&perf_task_events, have_events); - return; - -have_events: - __perf_event_task_sched_out(task, next); + COND_STMT(&perf_task_events, __perf_event_task_sched_out(task, next)); } extern int perf_event_init_task(struct task_struct *child);
|  |