Re: [PATCH 4/5] jump label: tracepoint support

From: Jason Baron
Date: Mon Mar 22 2010 - 16:45:05 EST


On Mon, Mar 22, 2010 at 12:43:34PM -0400, Steven Rostedt wrote:
> On Mon, 2010-03-22 at 12:07 -0400, Jason Baron wrote:
> > Make use of the jump label infrastructure for tracepoints.
> >
> > Signed-off-by: Jason Baron <jbaron@xxxxxxxxxx>
> > ---
> > include/linux/tracepoint.h | 34 +++++++++++++++++++---------------
> > kernel/tracepoint.c | 8 ++++++++
> > 2 files changed, 27 insertions(+), 15 deletions(-)
> >
> > diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
> > index f59604e..c18b9c0 100644
> > --- a/include/linux/tracepoint.h
> > +++ b/include/linux/tracepoint.h
> > @@ -16,6 +16,7 @@
> >
> > #include <linux/types.h>
> > #include <linux/rcupdate.h>
> > +#include <linux/jump_label.h>
> >
> > struct module;
> > struct tracepoint;
> > @@ -63,20 +64,22 @@ struct tracepoint {
> > * not add unwanted padding between the beginning of the section and the
> > * structure. Force alignment to the same alignment as the section start.
> > */
> > -#define DECLARE_TRACE(name, proto, args) \
> > - extern struct tracepoint __tracepoint_##name; \
> > - static inline void trace_##name(proto) \
> > - { \
> > - if (unlikely(__tracepoint_##name.state)) \
> > - __DO_TRACE(&__tracepoint_##name, \
> > - TP_PROTO(proto), TP_ARGS(args)); \
> > - } \
> > - static inline int register_trace_##name(void (*probe)(proto)) \
> > - { \
> > - return tracepoint_probe_register(#name, (void *)probe); \
> > - } \
> > - static inline int unregister_trace_##name(void (*probe)(proto)) \
> > - { \
> > +#define DECLARE_TRACE(name, proto, args) \
> > + extern struct tracepoint __tracepoint_##name; \
> > + static inline void trace_##name(proto) \
> > + { \
> > + JUMP_LABEL(name, do_trace, __tracepoint_##name.state); \
> > + return; \
> > +do_trace: \
> > + __DO_TRACE(&__tracepoint_##name, \
> > + TP_PROTO(proto), TP_ARGS(args)); \
>
> Does this still work on all archs, and when jump labels are not
> supported?

yes. See the base patch. If the arch doesn't have jump label support we
do:

#define JUMP_LABEL(tag, label, cond) \
if (unlikely(cond)) \
goto label;

-Jason
--
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/