All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Tracepoint: introduce tracepoint() API
@ 2011-11-25 22:14 Mathieu Desnoyers
  2011-11-25 22:43 ` Eric Dumazet
  0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Desnoyers @ 2011-11-25 22:14 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Jason Baron, Eric Dumazet, Peter Zijlstra, linux-kernel,
	Ingo Molnar, Christoph Lameter

Introduce:

  tracepoint(event_name, arg1, arg2, ...)

while keeping the old tracepoint API in place, e.g.:

  trace_event_name(arg1, arg2, ...)

This allows skipping parameter side-effects (pointer dereference,
function calls, ...) when the tracepoint is not dynamically activated.

This allows progressive (and partial) API transition from trace_*(...)
to tracepoint(*, ...). This differs from the previous attempt to
introduce this change by Jason Baron in that it supports both the
original and new tracepoint APIs, which makes the transition smoother
than having to change all instrumentation at once.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Jason Baron <jbaron@redhat.com>
Link: https://lkml.org/lkml/2009/5/19/328
CC: Eric Dumazet <eric.dumazet@gmail.com>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Ingo Molnar <mingo@elte.hu>
CC: Christoph Lameter <cl@linux-foundation.org>
---
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index d530a44..c9c73f7 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -107,6 +107,12 @@ void tracepoint_update_probe_range(struct tracepoint * const *begin,
 
 #ifdef CONFIG_TRACEPOINTS
 
+#define tracepoint(name, args...)					\
+	do {								\
+		if (static_branch(&__tracepoint_##name.key))		\
+			__trace_##name(args);				\
+	} while (0)
+
 /*
  * it_func[0] is never NULL because there is at least one element in the array
  * when the array itself is non NULL.
@@ -144,13 +150,17 @@ void tracepoint_update_probe_range(struct tracepoint * const *begin,
  */
 #define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args)	\
 	extern struct tracepoint __tracepoint_##name;			\
+	static inline void __trace_##name(proto)			\
+	{								\
+		__DO_TRACE(&__tracepoint_##name,			\
+			TP_PROTO(data_proto),				\
+			TP_ARGS(data_args),				\
+			TP_CONDITION(cond));				\
+	}								\
 	static inline void trace_##name(proto)				\
 	{								\
 		if (static_branch(&__tracepoint_##name.key))		\
-			__DO_TRACE(&__tracepoint_##name,		\
-				TP_PROTO(data_proto),			\
-				TP_ARGS(data_args),			\
-				TP_CONDITION(cond));			\
+			__trace_##name(args);				\
 	}								\
 	static inline int						\
 	register_trace_##name(void (*probe)(data_proto), void *data)	\
@@ -193,7 +203,12 @@ void tracepoint_update_probe_range(struct tracepoint * const *begin,
 	EXPORT_SYMBOL(__tracepoint_##name)
 
 #else /* !CONFIG_TRACEPOINTS */
+
+#define tracepoint(name, args...)	__trace_##name(args)
+
 #define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args)	\
+	static inline void __trace_##name(proto)			\
+	{ }								\
 	static inline void trace_##name(proto)				\
 	{ }								\
 	static inline int						\

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Tracepoint: introduce tracepoint() API
  2011-11-25 22:14 [PATCH] Tracepoint: introduce tracepoint() API Mathieu Desnoyers
@ 2011-11-25 22:43 ` Eric Dumazet
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2011-11-25 22:43 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: Steven Rostedt, Jason Baron, Peter Zijlstra, linux-kernel,
	Ingo Molnar, Christoph Lameter

Le vendredi 25 novembre 2011 à 17:14 -0500, Mathieu Desnoyers a écrit :
> Introduce:
> 
>   tracepoint(event_name, arg1, arg2, ...)
> 
> while keeping the old tracepoint API in place, e.g.:
> 
>   trace_event_name(arg1, arg2, ...)
> 
> This allows skipping parameter side-effects (pointer dereference,
> function calls, ...) when the tracepoint is not dynamically activated.
> 
> This allows progressive (and partial) API transition from trace_*(...)
> to tracepoint(*, ...). This differs from the previous attempt to
> introduce this change by Jason Baron in that it supports both the
> original and new tracepoint APIs, which makes the transition smoother
> than having to change all instrumentation at once.
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Acked-by: Steven Rostedt <rostedt@goodmis.org>
> Acked-by: Jason Baron <jbaron@redhat.com>
> Link: https://lkml.org/lkml/2009/5/19/328
> CC: Eric Dumazet <eric.dumazet@gmail.com>
> CC: Peter Zijlstra <peterz@infradead.org>
> CC: Ingo Molnar <mingo@elte.hu>
> CC: Christoph Lameter <cl@linux-foundation.org>
> ---

Seems good to me, thanks Mathieu !

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-25 22:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-25 22:14 [PATCH] Tracepoint: introduce tracepoint() API Mathieu Desnoyers
2011-11-25 22:43 ` Eric Dumazet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.