linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] ftrace trace event: introduce assignment macros
@ 2010-12-09 16:22 Mathieu Desnoyers
  2010-12-09 17:00 ` Frederic Weisbecker
  0 siblings, 1 reply; 4+ messages in thread
From: Mathieu Desnoyers @ 2010-12-09 16:22 UTC (permalink / raw)
  To: Steven Rostedt, Frederic Weisbecker, Ingo Molnar, linux-kernel
  Cc: Li Zefan, William Cohen, Jun'ichi Nomura, Theodore Ts'o,
	Jason Baron, Mel Gorman, Eduard - Gabriel Munteanu,
	Marcelo Tosatti, Avi Kivity, Gleb Natapov, Hidetoshi Seto,
	Neil Horman, Arjan van de Ven, Peter Zijlstra, Kei Tokunaga,
	Martin K. Petersen, Oleg Nesterov, Masami Hiramatsu, Josh Stone,
	Xiao Guangrong, Thomas Gleixner, Zhaolei, Anton Blanchard

This patch proposes encapsulation of the raw assignments within TP_fast_assign()
by introducing tp_assign() and tp_memcpy() macros. This will allow us to:

- generically filter from input fields,
- redefine the field write primitives.

The current macros map directly to the old code. I changed the documentation in
tracepoint.txt to reflect these new primitives, but all TRACE_EVENT() users
should gradually update their code to use these macro wrappers rather than raw
"=" assignments or mempcy() calls.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: Steven Rostedt <rostedt@goodmis.org>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Ingo Molnar <mingo@redhat.com>
CC: Li Zefan <lizf@cn.fujitsu.com>
CC: William Cohen <wcohen@redhat.com>
CC: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
CC: Theodore Ts'o <tytso@mit.edu>
CC: Jason Baron <jbaron@redhat.com>
CC: Mel Gorman <mel@csn.ul.ie>
CC: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
CC: Marcelo Tosatti <mtosatti@redhat.com>
CC: Avi Kivity <avi@redhat.com>
CC: Gleb Natapov <gleb@redhat.com>
CC: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
CC: Neil Horman <nhorman@tuxdriver.com>
CC: Arjan van de Ven <arjan@linux.intel.com>
CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
CC: Kei Tokunaga <tokunaga.keiich@jp.fujitsu.com>
CC: Martin K. Petersen <martin.petersen@oracle.com>
CC: Oleg Nesterov <oleg@redhat.com>
CC: Masami Hiramatsu <mhiramat@redhat.com>
CC: Josh Stone <jistone@redhat.com>
CC: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Zhaolei <zhaolei@cn.fujitsu.com>
CC: Anton Blanchard <anton@samba.org>
---
 include/linux/tracepoint.h |   12 ++++++------
 include/trace/ftrace.h     |    6 ++++++
 2 files changed, 12 insertions(+), 6 deletions(-)

Index: linux-2.6-lttng.git/include/trace/ftrace.h
===================================================================
--- linux-2.6-lttng.git.orig/include/trace/ftrace.h
+++ linux-2.6-lttng.git/include/trace/ftrace.h
@@ -1,4 +1,10 @@
 /*
+ * Macros mapping tp_assign() and tp_memcpy() to "=" and memcpy.
+ */
+#define tp_assign(dest, src)		__entry->dest = src
+#define tp_memcpy(dest, src, len)	memcpy(__entry->dest, src, len)
+
+/*
  * Stage 1 of the trace events.
  *
  * Override the macros in <trace/trace_events.h> to include the following:
Index: linux-2.6-lttng.git/include/linux/tracepoint.h
===================================================================
--- linux-2.6-lttng.git.orig/include/linux/tracepoint.h
+++ linux-2.6-lttng.git/include/linux/tracepoint.h
@@ -306,12 +306,12 @@ static inline void tracepoint_update_pro
  *	*
  *
  *	TP_fast_assign(
- *		memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
- *		__entry->prev_pid	= prev->pid;
- *		__entry->prev_prio	= prev->prio;
- *		memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
- *		__entry->next_pid	= next->pid;
- *		__entry->next_prio	= next->prio;
+ *		tp_memcpy(next_comm, next->comm, TASK_COMM_LEN);
+ *		tp_assign(prev_pid, prev->pid);
+ *		tp_assign(prev_prio, prev->prio);
+ *		tp_memcpy(prev_comm, prev->comm, TASK_COMM_LEN);
+ *		tp_assign(next_pid, next->pid);
+ *		tp_assign(next_prio, next->prio);
  *	)
  *
  *	*

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

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

* Re: [RFC PATCH] ftrace trace event: introduce assignment macros
  2010-12-09 16:22 [RFC PATCH] ftrace trace event: introduce assignment macros Mathieu Desnoyers
@ 2010-12-09 17:00 ` Frederic Weisbecker
  2010-12-09 20:00   ` Mathieu Desnoyers
  2010-12-09 21:50   ` Mathieu Desnoyers
  0 siblings, 2 replies; 4+ messages in thread
From: Frederic Weisbecker @ 2010-12-09 17:00 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: Steven Rostedt, Ingo Molnar, linux-kernel, Li Zefan,
	William Cohen, Jun'ichi Nomura, Theodore Ts'o,
	Jason Baron, Mel Gorman, Eduard - Gabriel Munteanu,
	Marcelo Tosatti, Avi Kivity, Gleb Natapov, Hidetoshi Seto,
	Neil Horman, Arjan van de Ven, Peter Zijlstra, Kei Tokunaga,
	Martin K. Petersen, Oleg Nesterov, Masami Hiramatsu, Josh Stone,
	Xiao Guangrong, Thomas Gleixner, Zhaolei, Anton Blanchard

On Thu, Dec 09, 2010 at 11:22:11AM -0500, Mathieu Desnoyers wrote:
> This patch proposes encapsulation of the raw assignments within TP_fast_assign()
> by introducing tp_assign() and tp_memcpy() macros. This will allow us to:
> 
> - generically filter from input fields,
> - redefine the field write primitives.
> 
> The current macros map directly to the old code. I changed the documentation in
> tracepoint.txt to reflect these new primitives, but all TRACE_EVENT() users
> should gradually update their code to use these macro wrappers rather than raw
> "=" assignments or mempcy() calls.
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> CC: Steven Rostedt <rostedt@goodmis.org>
> CC: Frederic Weisbecker <fweisbec@gmail.com>
> CC: Ingo Molnar <mingo@redhat.com>
> CC: Li Zefan <lizf@cn.fujitsu.com>
> CC: William Cohen <wcohen@redhat.com>
> CC: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
> CC: Theodore Ts'o <tytso@mit.edu>
> CC: Jason Baron <jbaron@redhat.com>
> CC: Mel Gorman <mel@csn.ul.ie>
> CC: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
> CC: Marcelo Tosatti <mtosatti@redhat.com>
> CC: Avi Kivity <avi@redhat.com>
> CC: Gleb Natapov <gleb@redhat.com>
> CC: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
> CC: Neil Horman <nhorman@tuxdriver.com>
> CC: Arjan van de Ven <arjan@linux.intel.com>
> CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
> CC: Kei Tokunaga <tokunaga.keiich@jp.fujitsu.com>
> CC: Martin K. Petersen <martin.petersen@oracle.com>
> CC: Oleg Nesterov <oleg@redhat.com>
> CC: Masami Hiramatsu <mhiramat@redhat.com>
> CC: Josh Stone <jistone@redhat.com>
> CC: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Zhaolei <zhaolei@cn.fujitsu.com>
> CC: Anton Blanchard <anton@samba.org>
> ---
>  include/linux/tracepoint.h |   12 ++++++------
>  include/trace/ftrace.h     |    6 ++++++
>  2 files changed, 12 insertions(+), 6 deletions(-)
> 
> Index: linux-2.6-lttng.git/include/trace/ftrace.h
> ===================================================================
> --- linux-2.6-lttng.git.orig/include/trace/ftrace.h
> +++ linux-2.6-lttng.git/include/trace/ftrace.h
> @@ -1,4 +1,10 @@
>  /*
> + * Macros mapping tp_assign() and tp_memcpy() to "=" and memcpy.
> + */
> +#define tp_assign(dest, src)		__entry->dest = src
> +#define tp_memcpy(dest, src, len)	memcpy(__entry->dest, src, len)

Looks good.


> +
> +/*
>   * Stage 1 of the trace events.
>   *
>   * Override the macros in <trace/trace_events.h> to include the following:
> Index: linux-2.6-lttng.git/include/linux/tracepoint.h
> ===================================================================
> --- linux-2.6-lttng.git.orig/include/linux/tracepoint.h
> +++ linux-2.6-lttng.git/include/linux/tracepoint.h
> @@ -306,12 +306,12 @@ static inline void tracepoint_update_pro
>   *	*
>   *
>   *	TP_fast_assign(
> - *		memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
> - *		__entry->prev_pid	= prev->pid;
> - *		__entry->prev_prio	= prev->prio;
> - *		memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
> - *		__entry->next_pid	= next->pid;
> - *		__entry->next_prio	= next->prio;
> + *		tp_memcpy(next_comm, next->comm, TASK_COMM_LEN);
> + *		tp_assign(prev_pid, prev->pid);
> + *		tp_assign(prev_prio, prev->prio);
> + *		tp_memcpy(prev_comm, prev->comm, TASK_COMM_LEN);
> + *		tp_assign(next_pid, next->pid);
> + *		tp_assign(next_prio, next->prio);
>   *	)
>   *
>   *	*
> 
> -- 
> Mathieu Desnoyers
> Operating System Efficiency R&D Consultant
> EfficiOS Inc.
> http://www.efficios.com

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

* Re: [RFC PATCH] ftrace trace event: introduce assignment macros
  2010-12-09 17:00 ` Frederic Weisbecker
@ 2010-12-09 20:00   ` Mathieu Desnoyers
  2010-12-09 21:50   ` Mathieu Desnoyers
  1 sibling, 0 replies; 4+ messages in thread
From: Mathieu Desnoyers @ 2010-12-09 20:00 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Steven Rostedt, Ingo Molnar, linux-kernel, Li Zefan,
	William Cohen, Jun'ichi Nomura, Theodore Ts'o,
	Jason Baron, Mel Gorman, Eduard - Gabriel Munteanu,
	Marcelo Tosatti, Avi Kivity, Gleb Natapov, Hidetoshi Seto,
	Neil Horman, Arjan van de Ven, Peter Zijlstra, Kei Tokunaga,
	Martin K. Petersen, Oleg Nesterov, Masami Hiramatsu, Josh Stone,
	Xiao Guangrong, Thomas Gleixner, Zhaolei, Anton Blanchard

* Frederic Weisbecker (fweisbec@gmail.com) wrote:
> On Thu, Dec 09, 2010 at 11:22:11AM -0500, Mathieu Desnoyers wrote:
> > This patch proposes encapsulation of the raw assignments within TP_fast_assign()
> > by introducing tp_assign() and tp_memcpy() macros. This will allow us to:
> > 
> > - generically filter from input fields,
> > - redefine the field write primitives.
> > 
> > The current macros map directly to the old code. I changed the documentation in
> > tracepoint.txt to reflect these new primitives, but all TRACE_EVENT() users
> > should gradually update their code to use these macro wrappers rather than raw
> > "=" assignments or mempcy() calls.
> > 
[...]
> > ---
> >  include/linux/tracepoint.h |   12 ++++++------
> >  include/trace/ftrace.h     |    6 ++++++
> >  2 files changed, 12 insertions(+), 6 deletions(-)
> > 
> > Index: linux-2.6-lttng.git/include/trace/ftrace.h
> > ===================================================================
> > --- linux-2.6-lttng.git.orig/include/trace/ftrace.h
> > +++ linux-2.6-lttng.git/include/trace/ftrace.h
> > @@ -1,4 +1,10 @@
> >  /*
> > + * Macros mapping tp_assign() and tp_memcpy() to "=" and memcpy.
> > + */
> > +#define tp_assign(dest, src)		__entry->dest = src
> > +#define tp_memcpy(dest, src, len)	memcpy(__entry->dest, src, len)
> 
> Looks good.

Great! Can I resend it without "RFC" with your Acked-by ?

If there is wide-spread agreement on this change, I might soon start rolling out
patches that migrate TRACE_EVENT users to these new primitives.

Thanks,

Mathieu

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

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

* Re: [RFC PATCH] ftrace trace event: introduce assignment macros
  2010-12-09 17:00 ` Frederic Weisbecker
  2010-12-09 20:00   ` Mathieu Desnoyers
@ 2010-12-09 21:50   ` Mathieu Desnoyers
  1 sibling, 0 replies; 4+ messages in thread
From: Mathieu Desnoyers @ 2010-12-09 21:50 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Steven Rostedt, Ingo Molnar, linux-kernel, Li Zefan,
	William Cohen, Jun'ichi Nomura, Theodore Ts'o,
	Jason Baron, Mel Gorman, Eduard - Gabriel Munteanu,
	Marcelo Tosatti, Avi Kivity, Gleb Natapov, Hidetoshi Seto,
	Neil Horman, Arjan van de Ven, Peter Zijlstra, Kei Tokunaga,
	Martin K. Petersen, Oleg Nesterov, Masami Hiramatsu, Josh Stone,
	Xiao Guangrong, Thomas Gleixner, Zhaolei, Anton Blanchard

* Frederic Weisbecker (fweisbec@gmail.com) wrote:
> On Thu, Dec 09, 2010 at 11:22:11AM -0500, Mathieu Desnoyers wrote:
> > This patch proposes encapsulation of the raw assignments within TP_fast_assign()
> > by introducing tp_assign() and tp_memcpy() macros. This will allow us to:
> > 
> > - generically filter from input fields,
> > - redefine the field write primitives.
> > 
> > The current macros map directly to the old code. I changed the documentation in
> > tracepoint.txt to reflect these new primitives, but all TRACE_EVENT() users
> > should gradually update their code to use these macro wrappers rather than raw
> > "=" assignments or mempcy() calls.

Hrm, while we are there, I notice the presence of __assign_str(). Maybe we
should also create the following mapping, for the sake of streamlining the
interface:

#define tp_strcpy(dest, src)   __assign_str(dest, src)

Thoughts ?

Thanks,

Mathieu

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

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

end of thread, other threads:[~2010-12-09 21:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-09 16:22 [RFC PATCH] ftrace trace event: introduce assignment macros Mathieu Desnoyers
2010-12-09 17:00 ` Frederic Weisbecker
2010-12-09 20:00   ` Mathieu Desnoyers
2010-12-09 21:50   ` Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).