Skip to contentSkip to conversation

ftrace trace event: introduce assignment macros

RFC PATCH In review Mathieu Desnoyers 2 participants 4 messages Dec 9, 2010

Subsystems (2)
lore
Share & tools
lore

Mathieu Desnoyers

author reviewer
#0 lore raw

RFC PATCH 1/1 ftrace trace event: introduce assignment macros

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.

CC Steven Rostedt <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Ingo Molnar <[email protected]>
CC Li Zefan <[email protected]>
CC William Cohen <[email protected]>
CC Jun'ichi Nomura <[email protected]>
CC Theodore Ts'o <[email protected]>
CC Jason Baron <[email protected]>
CC Mel Gorman <[email protected]>
CC Eduard - Gabriel Munteanu <[email protected]>
CC Marcelo Tosatti <[email protected]>
CC Avi Kivity <[email protected]>
CC Gleb Natapov <[email protected]>
CC Hidetoshi Seto <[email protected]>
CC Neil Horman <[email protected]>
CC Arjan van de Ven <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Kei Tokunaga <[email protected]>
CC Martin K. Petersen <[email protected]>
CC Oleg Nesterov <[email protected]>
CC Masami Hiramatsu <[email protected]>
CC Josh Stone <[email protected]>
CC Xiao Guangrong <[email protected]>
CC Thomas Gleixner <[email protected]>
CC Zhaolei <[email protected]>
CC Anton Blanchard <[email protected]>
---
 include/linux/tracepoint.h |   12 ++++++------
 include/trace/ftrace.h     |    6 ++++++
 2 files changed, 12 insertions(+), 6 deletions(-)
include/trace/ftrace.h +6 -0
Index: 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:
include/linux/tracepoint.h +6 -6
Index: 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);
  *	)
  *
  *	*
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
#1 lore raw
Quoted 48 lines · Mathieu Desnoyers

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.

CC Steven Rostedt <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Ingo Molnar <[email protected]>
CC Li Zefan <[email protected]>
CC William Cohen <[email protected]>
CC Jun'ichi Nomura <[email protected]>
CC Theodore Ts'o <[email protected]>
CC Jason Baron <[email protected]>
CC Mel Gorman <[email protected]>
CC Eduard - Gabriel Munteanu <[email protected]>
CC Marcelo Tosatti <[email protected]>
CC Avi Kivity <[email protected]>
CC Gleb Natapov <[email protected]>
CC Hidetoshi Seto <[email protected]>
CC Neil Horman <[email protected]>
CC Arjan van de Ven <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Kei Tokunaga <[email protected]>
CC Martin K. Petersen <[email protected]>
CC Oleg Nesterov <[email protected]>
CC Masami Hiramatsu <[email protected]>
CC Josh Stone <[email protected]>
CC Xiao Guangrong <[email protected]>
CC Thomas Gleixner <[email protected]>
CC Zhaolei <[email protected]>
CC Anton Blanchard <[email protected]>
---
 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
===================================================================

include/trace/ftrace.h line 5

Quoted 5 lines
include/trace/ftrace.h +4 -0
@@ -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.

Quoted 34 lines
include/trace/ftrace.h +2 -0
+
+/*
  * 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
===================================================================

include/linux/tracepoint.h +6 -6
@@ -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);
  *	)
  *
  *	*
Signature · 5 lines
-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
author reviewer
#2 lore raw
Quoted 12 lines · * Frederic Weisbecker ([email protected]) wrote:
Quoted 11 lines · Mathieu Desnoyers

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.

[...]

Quoted 5 lines
Quoted 5 lines
---
 include/linux/tracepoint.h |   12 ++++++------
 include/trace/ftrace.h     |    6 ++++++
 2 files changed, 12 insertions(+), 6 deletions(-)
Quoted 12 lines

include/trace/ftrace.h line 5

Quoted 10 lines

Index: linux-2.6-lttng.git/include/trace/ftrace.h
===================================================================

include/trace/ftrace.h +4 -0
@@ -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

Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
author reviewer
#3 lore raw
In reply to Frederic Weisbecker
Quoted 11 lines · * Frederic Weisbecker ([email protected]) wrote:
Quoted 10 lines · Mathieu Desnoyers

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

Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com