Re: [RFC][PATCH 6/7] perf: use jump_label to optimize thescheduler hooks
From: Peter Zijlstra
Date: Sun Oct 17 2010 - 06:16:46 EST
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);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/