All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] [GIT PULL] enhancements for tracing in tip
@ 2009-03-10  4:57 Steven Rostedt
  2009-03-10  4:57 ` [PATCH 1/7] tracing: typecast sizeof and offsetof to unsigned int Steven Rostedt
                   ` (7 more replies)
  0 siblings, 8 replies; 25+ messages in thread
From: Steven Rostedt @ 2009-03-10  4:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
	Frederic Weisbecker, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang


Ingo,

This patch series replaces the TRACE_EVENT_FORMAT with the new
TRACE_EVENT

NOTE: I started with a pull from tip/tracing/printk. It does not
show up as a merge since I did the pull at the point where it forked.
But by pulling this branch, you will also receive your changes from
tracing/printk. I rebased my changes off of this pull so that my changes
would be after the pull, making this patch series cleaner.

Please pull the latest tip/tracing/ftrace tree, which can be found at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/ftrace


Steven Rostedt (7):
      tracing: typecast sizeof and offsetof to unsigned int
      tracing: replace TP<var> with TP_<var>
      tracing: use generic __stringify
      tracing: new format for specialized trace points
      tracing: convert the sched trace points to the TRACE_EVENT macros
      tracing: convert irq trace points to new macros
      tracing: remove obsolete TRACE_EVENT_FORMAT macro

----
 Documentation/tracepoints.txt          |    8 +-
 include/linux/tracepoint.h             |   10 +-
 include/trace/block.h                  |   70 +++---
 include/trace/irq_event_types.h        |   46 ++--
 include/trace/lockdep_event_types.h    |   26 +-
 include/trace/power.h                  |   12 +-
 include/trace/sched_event_types.h      |  442 +++++++++++++++++++++++---------
 include/trace/workqueue.h              |   16 +-
 kernel/trace/events.c                  |    4 +-
 kernel/trace/trace.h                   |    5 -
 kernel/trace/trace_event_types.h       |   29 +-
 kernel/trace/trace_events.c            |  174 +------------
 kernel/trace/trace_events_stage_1.h    |   27 +-
 kernel/trace/trace_events_stage_2.h    |   91 +++++--
 kernel/trace/trace_events_stage_3.h    |   42 +---
 kernel/trace/trace_export.c            |   41 +++-
 kernel/trace/trace_format.h            |   55 ----
 kernel/trace/trace_selftest.c          |    6 +-
 samples/tracepoints/tp-samples-trace.h |    8 +-
 19 files changed, 575 insertions(+), 537 deletions(-)
-- 

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

* [PATCH 1/7] tracing: typecast sizeof and offsetof to unsigned int
  2009-03-10  4:57 [PATCH 0/7] [GIT PULL] enhancements for tracing in tip Steven Rostedt
@ 2009-03-10  4:57 ` Steven Rostedt
  2009-03-10  5:20   ` Andrew Morton
  2009-03-10  4:57 ` [PATCH 2/7] tracing: replace TP<var> with TP_<var> Steven Rostedt
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 25+ messages in thread
From: Steven Rostedt @ 2009-03-10  4:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
	Frederic Weisbecker, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang, Steven Rostedt

[-- Attachment #1: 0001-tracing-typecast-sizeof-and-offsetof-to-unsigned-in.patch --]
[-- Type: text/plain, Size: 3609 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: fix compiler warnings

On x86_64 sizeof and offsetof are treated as long, where as on x86_32
they are int. This patch typecasts them to unsigned int to avoid
one arch giving warnings while the other does not.

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace_events.c |   15 ++++++++-------
 kernel/trace/trace_export.c |   10 +++++-----
 kernel/trace/trace_format.h |   12 ++++++------
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 4488d90..fa32ca3 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -448,8 +448,9 @@ event_available_types_read(struct file *filp, char __user *ubuf, size_t cnt,
 }
 
 #undef FIELD
-#define FIELD(type, name) \
-	#type, #name, offsetof(typeof(field), name), sizeof(field.name)
+#define FIELD(type, name)						\
+	#type, #name, (unsigned int)offsetof(typeof(field), name),	\
+		(unsigned int)sizeof(field.name)
 
 static int trace_write_header(struct trace_seq *s)
 {
@@ -457,11 +458,11 @@ static int trace_write_header(struct trace_seq *s)
 
 	/* struct trace_entry */
 	return trace_seq_printf(s,
-				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
-				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
-				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
-				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
-				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
+				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
+				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
+				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
+				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
+				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
 				"\n",
 				FIELD(unsigned char, type),
 				FIELD(unsigned char, flags),
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index 0fb7be7..7162ab4 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -18,11 +18,11 @@
 #include "trace_format.h"
 
 #undef TRACE_FIELD_ZERO_CHAR
-#define TRACE_FIELD_ZERO_CHAR(item)				\
-	ret = trace_seq_printf(s, "\tfield: char " #item ";\t"	\
-			       "offset:%lu;\tsize:0;\n",	\
-			       offsetof(typeof(field), item));	\
-	if (!ret)						\
+#define TRACE_FIELD_ZERO_CHAR(item)					\
+	ret = trace_seq_printf(s, "\tfield: char " #item ";\t"		\
+			       "offset:%u;\tsize:0;\n",			\
+			       (unsigned int)offsetof(typeof(field), item)); \
+	if (!ret)							\
 		return 0;
 
 
diff --git a/kernel/trace/trace_format.h b/kernel/trace/trace_format.h
index 03f9a4c..97e59a9 100644
--- a/kernel/trace/trace_format.h
+++ b/kernel/trace/trace_format.h
@@ -22,9 +22,9 @@
 #undef TRACE_FIELD
 #define TRACE_FIELD(type, item, assign)					\
 	ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t"	\
-			       "offset:%lu;\tsize:%lu;\n",		\
-			       offsetof(typeof(field), item),		\
-			       sizeof(field.item));			\
+			       "offset:%u;\tsize:%u;\n",		\
+			       (unsigned int)offsetof(typeof(field), item), \
+			       (unsigned int)sizeof(field.item));	\
 	if (!ret)							\
 		return 0;
 
@@ -32,9 +32,9 @@
 #undef TRACE_FIELD_SPECIAL
 #define TRACE_FIELD_SPECIAL(type_item, item, cmd)			\
 	ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t"	\
-			       "offset:%lu;\tsize:%lu;\n",		\
-			       offsetof(typeof(field), item),		\
-			       sizeof(field.item));			\
+			       "offset:%u;\tsize:%u;\n",		\
+			       (unsigned int)offsetof(typeof(field), item), \
+			       (unsigned int)sizeof(field.item));	\
 	if (!ret)							\
 		return 0;
 
-- 
1.6.1.3

-- 

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

* [PATCH 2/7] tracing: replace TP<var> with TP_<var>
  2009-03-10  4:57 [PATCH 0/7] [GIT PULL] enhancements for tracing in tip Steven Rostedt
  2009-03-10  4:57 ` [PATCH 1/7] tracing: typecast sizeof and offsetof to unsigned int Steven Rostedt
@ 2009-03-10  4:57 ` Steven Rostedt
  2009-03-17  7:58   ` Christoph Hellwig
  2009-03-10  4:57 ` [PATCH 3/7] tracing: use generic __stringify Steven Rostedt
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 25+ messages in thread
From: Steven Rostedt @ 2009-03-10  4:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
	Frederic Weisbecker, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang, Steven Rostedt

[-- Attachment #1: 0002-tracing-replace-TP-var-with-TP_-var.patch --]
[-- Type: text/plain, Size: 25625 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: clean up

The macros TPPROTO, TPARGS, TPFMT, TPRAWFMT, and TPCMD all look a bit
ugly. This patch adds an underscore to their names.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 Documentation/tracepoints.txt          |    8 +-
 include/linux/tracepoint.h             |    6 +-
 include/trace/block.h                  |   70 +++++++++++-----------
 include/trace/irq_event_types.h        |   16 +++---
 include/trace/lockdep_event_types.h    |   24 ++++----
 include/trace/power.h                  |   12 ++--
 include/trace/sched_event_types.h      |   98 ++++++++++++++++----------------
 include/trace/workqueue.h              |   16 +++---
 kernel/trace/trace_event_types.h       |   28 +++++-----
 kernel/trace/trace_events_stage_2.h    |    6 +-
 kernel/trace/trace_events_stage_3.h    |    8 +-
 kernel/trace/trace_export.c            |    8 +-
 kernel/trace/trace_format.h            |   55 ------------------
 samples/tracepoints/tp-samples-trace.h |    8 +-
 14 files changed, 154 insertions(+), 209 deletions(-)
 delete mode 100644 kernel/trace/trace_format.h

diff --git a/Documentation/tracepoints.txt b/Documentation/tracepoints.txt
index 6f0a044..4ff43c6 100644
--- a/Documentation/tracepoints.txt
+++ b/Documentation/tracepoints.txt
@@ -45,8 +45,8 @@ In include/trace/subsys.h :
 #include <linux/tracepoint.h>
 
 DECLARE_TRACE(subsys_eventname,
-	TPPROTO(int firstarg, struct task_struct *p),
-	TPARGS(firstarg, p));
+	TP_PROTO(int firstarg, struct task_struct *p),
+	TP_ARGS(firstarg, p));
 
 In subsys/file.c (where the tracing statement must be added) :
 
@@ -66,10 +66,10 @@ Where :
     - subsys is the name of your subsystem.
     - eventname is the name of the event to trace.
 
-- TPPROTO(int firstarg, struct task_struct *p) is the prototype of the
+- TP_PROTO(int firstarg, struct task_struct *p) is the prototype of the
   function called by this tracepoint.
 
-- TPARGS(firstarg, p) are the parameters names, same as found in the
+- TP_ARGS(firstarg, p) are the parameters names, same as found in the
   prototype.
 
 Connecting a function (probe) to a tracepoint is done by providing a
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 152b2f0..3bcc3e1 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -31,8 +31,8 @@ struct tracepoint {
 					 * Keep in sync with vmlinux.lds.h.
 					 */
 
-#define TPPROTO(args...)	args
-#define TPARGS(args...)		args
+#define TP_PROTO(args...)	args
+#define TP_ARGS(args...)		args
 
 #ifdef CONFIG_TRACEPOINTS
 
@@ -65,7 +65,7 @@ struct tracepoint {
 	{								\
 		if (unlikely(__tracepoint_##name.state))		\
 			__DO_TRACE(&__tracepoint_##name,		\
-				TPPROTO(proto), TPARGS(args));		\
+				TP_PROTO(proto), TP_ARGS(args));	\
 	}								\
 	static inline int register_trace_##name(void (*probe)(proto))	\
 	{								\
diff --git a/include/trace/block.h b/include/trace/block.h
index 25c6a1f..25b7068 100644
--- a/include/trace/block.h
+++ b/include/trace/block.h
@@ -5,72 +5,72 @@
 #include <linux/tracepoint.h>
 
 DECLARE_TRACE(block_rq_abort,
-	TPPROTO(struct request_queue *q, struct request *rq),
-		TPARGS(q, rq));
+	TP_PROTO(struct request_queue *q, struct request *rq),
+	      TP_ARGS(q, rq));
 
 DECLARE_TRACE(block_rq_insert,
-	TPPROTO(struct request_queue *q, struct request *rq),
-		TPARGS(q, rq));
+	TP_PROTO(struct request_queue *q, struct request *rq),
+	      TP_ARGS(q, rq));
 
 DECLARE_TRACE(block_rq_issue,
-	TPPROTO(struct request_queue *q, struct request *rq),
-		TPARGS(q, rq));
+	TP_PROTO(struct request_queue *q, struct request *rq),
+	      TP_ARGS(q, rq));
 
 DECLARE_TRACE(block_rq_requeue,
-	TPPROTO(struct request_queue *q, struct request *rq),
-		TPARGS(q, rq));
+	TP_PROTO(struct request_queue *q, struct request *rq),
+	      TP_ARGS(q, rq));
 
 DECLARE_TRACE(block_rq_complete,
-	TPPROTO(struct request_queue *q, struct request *rq),
-		TPARGS(q, rq));
+	TP_PROTO(struct request_queue *q, struct request *rq),
+	      TP_ARGS(q, rq));
 
 DECLARE_TRACE(block_bio_bounce,
-	TPPROTO(struct request_queue *q, struct bio *bio),
-		TPARGS(q, bio));
+	TP_PROTO(struct request_queue *q, struct bio *bio),
+	      TP_ARGS(q, bio));
 
 DECLARE_TRACE(block_bio_complete,
-	TPPROTO(struct request_queue *q, struct bio *bio),
-		TPARGS(q, bio));
+	TP_PROTO(struct request_queue *q, struct bio *bio),
+	      TP_ARGS(q, bio));
 
 DECLARE_TRACE(block_bio_backmerge,
-	TPPROTO(struct request_queue *q, struct bio *bio),
-		TPARGS(q, bio));
+	TP_PROTO(struct request_queue *q, struct bio *bio),
+	      TP_ARGS(q, bio));
 
 DECLARE_TRACE(block_bio_frontmerge,
-	TPPROTO(struct request_queue *q, struct bio *bio),
-		TPARGS(q, bio));
+	TP_PROTO(struct request_queue *q, struct bio *bio),
+	      TP_ARGS(q, bio));
 
 DECLARE_TRACE(block_bio_queue,
-	TPPROTO(struct request_queue *q, struct bio *bio),
-		TPARGS(q, bio));
+	TP_PROTO(struct request_queue *q, struct bio *bio),
+	      TP_ARGS(q, bio));
 
 DECLARE_TRACE(block_getrq,
-	TPPROTO(struct request_queue *q, struct bio *bio, int rw),
-		TPARGS(q, bio, rw));
+	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
+	      TP_ARGS(q, bio, rw));
 
 DECLARE_TRACE(block_sleeprq,
-	TPPROTO(struct request_queue *q, struct bio *bio, int rw),
-		TPARGS(q, bio, rw));
+	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
+	      TP_ARGS(q, bio, rw));
 
 DECLARE_TRACE(block_plug,
-	TPPROTO(struct request_queue *q),
-		TPARGS(q));
+	TP_PROTO(struct request_queue *q),
+	      TP_ARGS(q));
 
 DECLARE_TRACE(block_unplug_timer,
-	TPPROTO(struct request_queue *q),
-		TPARGS(q));
+	TP_PROTO(struct request_queue *q),
+	      TP_ARGS(q));
 
 DECLARE_TRACE(block_unplug_io,
-	TPPROTO(struct request_queue *q),
-		TPARGS(q));
+	TP_PROTO(struct request_queue *q),
+	      TP_ARGS(q));
 
 DECLARE_TRACE(block_split,
-	TPPROTO(struct request_queue *q, struct bio *bio, unsigned int pdu),
-		TPARGS(q, bio, pdu));
+	TP_PROTO(struct request_queue *q, struct bio *bio, unsigned int pdu),
+	      TP_ARGS(q, bio, pdu));
 
 DECLARE_TRACE(block_remap,
-	TPPROTO(struct request_queue *q, struct bio *bio, dev_t dev,
-		sector_t from, sector_t to),
-		TPARGS(q, bio, dev, from, to));
+	TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
+		 sector_t from, sector_t to),
+	      TP_ARGS(q, bio, dev, from, to));
 
 #endif
diff --git a/include/trace/irq_event_types.h b/include/trace/irq_event_types.h
index 65850bc..0147d9e 100644
--- a/include/trace/irq_event_types.h
+++ b/include/trace/irq_event_types.h
@@ -9,25 +9,25 @@
 #define TRACE_SYSTEM irq
 
 TRACE_EVENT_FORMAT(irq_handler_entry,
-	TPPROTO(int irq, struct irqaction *action),
-	TPARGS(irq, action),
-	TPFMT("irq=%d handler=%s", irq, action->name),
+	TP_PROTO(int irq, struct irqaction *action),
+	TP_ARGS(irq, action),
+	TP_FMT("irq=%d handler=%s", irq, action->name),
 	TRACE_STRUCT(
 		TRACE_FIELD(int, irq, irq)
 	),
-	TPRAWFMT("irq %d")
+	TP_RAW_FMT("irq %d")
 	);
 
 TRACE_EVENT_FORMAT(irq_handler_exit,
-	TPPROTO(int irq, struct irqaction *action, int ret),
-	TPARGS(irq, action, ret),
-	TPFMT("irq=%d handler=%s return=%s",
+	TP_PROTO(int irq, struct irqaction *action, int ret),
+	TP_ARGS(irq, action, ret),
+	TP_FMT("irq=%d handler=%s return=%s",
 		irq, action->name, ret ? "handled" : "unhandled"),
 	TRACE_STRUCT(
 		TRACE_FIELD(int, irq, irq)
 		TRACE_FIELD(int, ret, ret)
 	),
-	TPRAWFMT("irq %d ret %d")
+	TP_RAW_FMT("irq %d ret %d")
 	);
 
 #undef TRACE_SYSTEM
diff --git a/include/trace/lockdep_event_types.h b/include/trace/lockdep_event_types.h
index f713d74..1f00e8b 100644
--- a/include/trace/lockdep_event_types.h
+++ b/include/trace/lockdep_event_types.h
@@ -10,32 +10,32 @@
 #ifdef CONFIG_LOCKDEP
 
 TRACE_FORMAT(lock_acquire,
-	TPPROTO(struct lockdep_map *lock, unsigned int subclass,
+	TP_PROTO(struct lockdep_map *lock, unsigned int subclass,
 		int trylock, int read, int check,
 		struct lockdep_map *next_lock, unsigned long ip),
-	TPARGS(lock, subclass, trylock, read, check, next_lock, ip),
-	TPFMT("%s%s%s", trylock ? "try " : "",
+	TP_ARGS(lock, subclass, trylock, read, check, next_lock, ip),
+	TP_FMT("%s%s%s", trylock ? "try " : "",
 		read ? "read " : "", lock->name)
 	);
 
 TRACE_FORMAT(lock_release,
-	TPPROTO(struct lockdep_map *lock, int nested, unsigned long ip),
-	TPARGS(lock, nested, ip),
-	TPFMT("%s", lock->name)
+	TP_PROTO(struct lockdep_map *lock, int nested, unsigned long ip),
+	TP_ARGS(lock, nested, ip),
+	TP_FMT("%s", lock->name)
 	);
 
 #ifdef CONFIG_LOCK_STAT
 
 TRACE_FORMAT(lock_contended,
-	TPPROTO(struct lockdep_map *lock, unsigned long ip),
-	TPARGS(lock, ip),
-	TPFMT("%s", lock->name)
+	TP_PROTO(struct lockdep_map *lock, unsigned long ip),
+	TP_ARGS(lock, ip),
+	TP_FMT("%s", lock->name)
 	);
 
 TRACE_FORMAT(lock_acquired,
-	TPPROTO(struct lockdep_map *lock, unsigned long ip),
-	TPARGS(lock, ip),
-	TPFMT("%s", lock->name)
+	TP_PROTO(struct lockdep_map *lock, unsigned long ip),
+	TP_ARGS(lock, ip),
+	TP_FMT("%s", lock->name)
 	);
 
 #endif
diff --git a/include/trace/power.h b/include/trace/power.h
index 38aca53..ef20466 100644
--- a/include/trace/power.h
+++ b/include/trace/power.h
@@ -18,15 +18,15 @@ struct power_trace {
 };
 
 DECLARE_TRACE(power_start,
-	TPPROTO(struct power_trace *it, unsigned int type, unsigned int state),
-		TPARGS(it, type, state));
+	TP_PROTO(struct power_trace *it, unsigned int type, unsigned int state),
+	      TP_ARGS(it, type, state));
 
 DECLARE_TRACE(power_mark,
-	TPPROTO(struct power_trace *it, unsigned int type, unsigned int state),
-		TPARGS(it, type, state));
+	TP_PROTO(struct power_trace *it, unsigned int type, unsigned int state),
+	      TP_ARGS(it, type, state));
 
 DECLARE_TRACE(power_end,
-	TPPROTO(struct power_trace *it),
-		TPARGS(it));
+	TP_PROTO(struct power_trace *it),
+	      TP_ARGS(it));
 
 #endif /* _TRACE_POWER_H */
diff --git a/include/trace/sched_event_types.h b/include/trace/sched_event_types.h
index a6de5c1..71b1482 100644
--- a/include/trace/sched_event_types.h
+++ b/include/trace/sched_event_types.h
@@ -9,143 +9,143 @@
 #define TRACE_SYSTEM sched
 
 TRACE_EVENT_FORMAT(sched_kthread_stop,
-	TPPROTO(struct task_struct *t),
-	TPARGS(t),
-	TPFMT("task %s:%d", t->comm, t->pid),
+	TP_PROTO(struct task_struct *t),
+	TP_ARGS(t),
+	TP_FMT("task %s:%d", t->comm, t->pid),
 	TRACE_STRUCT(
 		TRACE_FIELD(pid_t, pid, t->pid)
 	),
-	TPRAWFMT("task %d")
+	TP_RAW_FMT("task %d")
 	);
 
 TRACE_EVENT_FORMAT(sched_kthread_stop_ret,
-	TPPROTO(int ret),
-	TPARGS(ret),
-	TPFMT("ret=%d", ret),
+	TP_PROTO(int ret),
+	TP_ARGS(ret),
+	TP_FMT("ret=%d", ret),
 	TRACE_STRUCT(
 		TRACE_FIELD(int, ret, ret)
 	),
-	TPRAWFMT("ret=%d")
+	TP_RAW_FMT("ret=%d")
 	);
 
 TRACE_EVENT_FORMAT(sched_wait_task,
-	TPPROTO(struct rq *rq, struct task_struct *p),
-	TPARGS(rq, p),
-	TPFMT("task %s:%d", p->comm, p->pid),
+	TP_PROTO(struct rq *rq, struct task_struct *p),
+	TP_ARGS(rq, p),
+	TP_FMT("task %s:%d", p->comm, p->pid),
 	TRACE_STRUCT(
 		TRACE_FIELD(pid_t, pid, p->pid)
 	),
-	TPRAWFMT("task %d")
+	TP_RAW_FMT("task %d")
 	);
 
 TRACE_EVENT_FORMAT(sched_wakeup,
-	TPPROTO(struct rq *rq, struct task_struct *p, int success),
-	TPARGS(rq, p, success),
-	TPFMT("task %s:%d %s",
+	TP_PROTO(struct rq *rq, struct task_struct *p, int success),
+	TP_ARGS(rq, p, success),
+	TP_FMT("task %s:%d %s",
 	      p->comm, p->pid, success ? "succeeded" : "failed"),
 	TRACE_STRUCT(
 		TRACE_FIELD(pid_t, pid, p->pid)
 		TRACE_FIELD(int, success, success)
 	),
-	TPRAWFMT("task %d success=%d")
+	TP_RAW_FMT("task %d success=%d")
 	);
 
 TRACE_EVENT_FORMAT(sched_wakeup_new,
-	TPPROTO(struct rq *rq, struct task_struct *p, int success),
-	TPARGS(rq, p, success),
-	TPFMT("task %s:%d",
+	TP_PROTO(struct rq *rq, struct task_struct *p, int success),
+	TP_ARGS(rq, p, success),
+	TP_FMT("task %s:%d",
 	      p->comm, p->pid, success ? "succeeded" : "failed"),
 	TRACE_STRUCT(
 		TRACE_FIELD(pid_t, pid, p->pid)
 		TRACE_FIELD(int, success, success)
 	),
-	TPRAWFMT("task %d success=%d")
+	TP_RAW_FMT("task %d success=%d")
 	);
 
 TRACE_EVENT_FORMAT(sched_switch,
-	TPPROTO(struct rq *rq, struct task_struct *prev,
+	TP_PROTO(struct rq *rq, struct task_struct *prev,
 		struct task_struct *next),
-	TPARGS(rq, prev, next),
-	TPFMT("task %s:%d ==> %s:%d",
+	TP_ARGS(rq, prev, next),
+	TP_FMT("task %s:%d ==> %s:%d",
 	      prev->comm, prev->pid, next->comm, next->pid),
 	TRACE_STRUCT(
 		TRACE_FIELD(pid_t, prev_pid, prev->pid)
 		TRACE_FIELD(int, prev_prio, prev->prio)
 		TRACE_FIELD_SPECIAL(char next_comm[TASK_COMM_LEN],
 				    next_comm,
-				    TPCMD(memcpy(TRACE_ENTRY->next_comm,
+				    TP_CMD(memcpy(TRACE_ENTRY->next_comm,
 						 next->comm,
 						 TASK_COMM_LEN)))
 		TRACE_FIELD(pid_t, next_pid, next->pid)
 		TRACE_FIELD(int, next_prio, next->prio)
 	),
-	TPRAWFMT("prev %d:%d ==> next %s:%d:%d")
+	TP_RAW_FMT("prev %d:%d ==> next %s:%d:%d")
 	);
 
 TRACE_EVENT_FORMAT(sched_migrate_task,
-	TPPROTO(struct task_struct *p, int orig_cpu, int dest_cpu),
-	TPARGS(p, orig_cpu, dest_cpu),
-	TPFMT("task %s:%d from: %d  to: %d",
+	TP_PROTO(struct task_struct *p, int orig_cpu, int dest_cpu),
+	TP_ARGS(p, orig_cpu, dest_cpu),
+	TP_FMT("task %s:%d from: %d  to: %d",
 	      p->comm, p->pid, orig_cpu, dest_cpu),
 	TRACE_STRUCT(
 		TRACE_FIELD(pid_t, pid, p->pid)
 		TRACE_FIELD(int, orig_cpu, orig_cpu)
 		TRACE_FIELD(int, dest_cpu, dest_cpu)
 	),
-	TPRAWFMT("task %d  from: %d to: %d")
+	TP_RAW_FMT("task %d  from: %d to: %d")
 	);
 
 TRACE_EVENT_FORMAT(sched_process_free,
-	TPPROTO(struct task_struct *p),
-	TPARGS(p),
-	TPFMT("task %s:%d", p->comm, p->pid),
+	TP_PROTO(struct task_struct *p),
+	TP_ARGS(p),
+	TP_FMT("task %s:%d", p->comm, p->pid),
 	TRACE_STRUCT(
 		TRACE_FIELD(pid_t, pid, p->pid)
 	),
-	TPRAWFMT("task %d")
+	TP_RAW_FMT("task %d")
 	);
 
 TRACE_EVENT_FORMAT(sched_process_exit,
-	TPPROTO(struct task_struct *p),
-	TPARGS(p),
-	TPFMT("task %s:%d", p->comm, p->pid),
+	TP_PROTO(struct task_struct *p),
+	TP_ARGS(p),
+	TP_FMT("task %s:%d", p->comm, p->pid),
 	TRACE_STRUCT(
 		TRACE_FIELD(pid_t, pid, p->pid)
 	),
-	TPRAWFMT("task %d")
+	TP_RAW_FMT("task %d")
 	);
 
 TRACE_EVENT_FORMAT(sched_process_wait,
-	TPPROTO(struct pid *pid),
-	TPARGS(pid),
-	TPFMT("pid %d", pid_nr(pid)),
+	TP_PROTO(struct pid *pid),
+	TP_ARGS(pid),
+	TP_FMT("pid %d", pid_nr(pid)),
 	TRACE_STRUCT(
 		TRACE_FIELD(pid_t, pid, pid_nr(pid))
 	),
-	TPRAWFMT("task %d")
+	TP_RAW_FMT("task %d")
 	);
 
 TRACE_EVENT_FORMAT(sched_process_fork,
-	TPPROTO(struct task_struct *parent, struct task_struct *child),
-	TPARGS(parent, child),
-	TPFMT("parent %s:%d  child %s:%d",
+	TP_PROTO(struct task_struct *parent, struct task_struct *child),
+	TP_ARGS(parent, child),
+	TP_FMT("parent %s:%d  child %s:%d",
 	      parent->comm, parent->pid, child->comm, child->pid),
 	TRACE_STRUCT(
 		TRACE_FIELD(pid_t, parent, parent->pid)
 		TRACE_FIELD(pid_t, child, child->pid)
 	),
-	TPRAWFMT("parent %d  child %d")
+	TP_RAW_FMT("parent %d  child %d")
 	);
 
 TRACE_EVENT_FORMAT(sched_signal_send,
-	TPPROTO(int sig, struct task_struct *p),
-	TPARGS(sig, p),
-	TPFMT("sig: %d   task %s:%d", sig, p->comm, p->pid),
+	TP_PROTO(int sig, struct task_struct *p),
+	TP_ARGS(sig, p),
+	TP_FMT("sig: %d   task %s:%d", sig, p->comm, p->pid),
 	TRACE_STRUCT(
 		TRACE_FIELD(int, sig, sig)
 		TRACE_FIELD(pid_t, pid, p->pid)
 	),
-	TPRAWFMT("sig: %d  task %d")
+	TP_RAW_FMT("sig: %d  task %d")
 	);
 
 #undef TRACE_SYSTEM
diff --git a/include/trace/workqueue.h b/include/trace/workqueue.h
index 867829d..7626523 100644
--- a/include/trace/workqueue.h
+++ b/include/trace/workqueue.h
@@ -6,20 +6,20 @@
 #include <linux/sched.h>
 
 DECLARE_TRACE(workqueue_insertion,
-	   TPPROTO(struct task_struct *wq_thread, struct work_struct *work),
-	   TPARGS(wq_thread, work));
+	   TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
+	   TP_ARGS(wq_thread, work));
 
 DECLARE_TRACE(workqueue_execution,
-	   TPPROTO(struct task_struct *wq_thread, struct work_struct *work),
-	   TPARGS(wq_thread, work));
+	   TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
+	   TP_ARGS(wq_thread, work));
 
 /* Trace the creation of one workqueue thread on a cpu */
 DECLARE_TRACE(workqueue_creation,
-	   TPPROTO(struct task_struct *wq_thread, int cpu),
-	   TPARGS(wq_thread, cpu));
+	   TP_PROTO(struct task_struct *wq_thread, int cpu),
+	   TP_ARGS(wq_thread, cpu));
 
 DECLARE_TRACE(workqueue_destruction,
-	   TPPROTO(struct task_struct *wq_thread),
-	   TPARGS(wq_thread));
+	   TP_PROTO(struct task_struct *wq_thread),
+	   TP_ARGS(wq_thread));
 
 #endif /* __TRACE_WORKQUEUE_H */
diff --git a/kernel/trace/trace_event_types.h b/kernel/trace/trace_event_types.h
index fb4eba1..d94179a 100644
--- a/kernel/trace/trace_event_types.h
+++ b/kernel/trace/trace_event_types.h
@@ -10,7 +10,7 @@ TRACE_EVENT_FORMAT(function, TRACE_FN, ftrace_entry, ignore,
 		TRACE_FIELD(unsigned long, ip, ip)
 		TRACE_FIELD(unsigned long, parent_ip, parent_ip)
 	),
-	TPRAWFMT(" %lx <-- %lx")
+	TP_RAW_FMT(" %lx <-- %lx")
 );
 
 TRACE_EVENT_FORMAT(funcgraph_entry, TRACE_GRAPH_ENT,
@@ -19,7 +19,7 @@ TRACE_EVENT_FORMAT(funcgraph_entry, TRACE_GRAPH_ENT,
 		TRACE_FIELD(unsigned long, graph_ent.func, func)
 		TRACE_FIELD(int, graph_ent.depth, depth)
 	),
-	TPRAWFMT("--> %lx (%d)")
+	TP_RAW_FMT("--> %lx (%d)")
 );
 
 TRACE_EVENT_FORMAT(funcgraph_exit, TRACE_GRAPH_RET,
@@ -28,7 +28,7 @@ TRACE_EVENT_FORMAT(funcgraph_exit, TRACE_GRAPH_RET,
 		TRACE_FIELD(unsigned long, ret.func, func)
 		TRACE_FIELD(int, ret.depth, depth)
 	),
-	TPRAWFMT("<-- %lx (%d)")
+	TP_RAW_FMT("<-- %lx (%d)")
 );
 
 TRACE_EVENT_FORMAT(wakeup, TRACE_WAKE, ctx_switch_entry, ignore,
@@ -41,7 +41,7 @@ TRACE_EVENT_FORMAT(wakeup, TRACE_WAKE, ctx_switch_entry, ignore,
 		TRACE_FIELD(unsigned char, next_state, next_state)
 		TRACE_FIELD(unsigned int, next_cpu, next_cpu)
 	),
-	TPRAWFMT("%u:%u:%u  ==+ %u:%u:%u [%03u]")
+	TP_RAW_FMT("%u:%u:%u  ==+ %u:%u:%u [%03u]")
 );
 
 TRACE_EVENT_FORMAT(context_switch, TRACE_CTX, ctx_switch_entry, ignore,
@@ -54,7 +54,7 @@ TRACE_EVENT_FORMAT(context_switch, TRACE_CTX, ctx_switch_entry, ignore,
 		TRACE_FIELD(unsigned char, next_state, next_state)
 		TRACE_FIELD(unsigned int, next_cpu, next_cpu)
 	),
-	TPRAWFMT("%u:%u:%u  ==+ %u:%u:%u [%03u]")
+	TP_RAW_FMT("%u:%u:%u  ==+ %u:%u:%u [%03u]")
 );
 
 TRACE_EVENT_FORMAT(special, TRACE_SPECIAL, special_entry, ignore,
@@ -63,7 +63,7 @@ TRACE_EVENT_FORMAT(special, TRACE_SPECIAL, special_entry, ignore,
 		TRACE_FIELD(unsigned long, arg2, arg2)
 		TRACE_FIELD(unsigned long, arg3, arg3)
 	),
-	TPRAWFMT("(%08lx) (%08lx) (%08lx)")
+	TP_RAW_FMT("(%08lx) (%08lx) (%08lx)")
 );
 
 /*
@@ -83,7 +83,7 @@ TRACE_EVENT_FORMAT(kernel_stack, TRACE_STACK, stack_entry, ignore,
 		TRACE_FIELD(unsigned long, caller[6], stack6)
 		TRACE_FIELD(unsigned long, caller[7], stack7)
 	),
-	TPRAWFMT("\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n"
+	TP_RAW_FMT("\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n"
 		 "\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n")
 );
 
@@ -98,7 +98,7 @@ TRACE_EVENT_FORMAT(user_stack, TRACE_USER_STACK, userstack_entry, ignore,
 		TRACE_FIELD(unsigned long, caller[6], stack6)
 		TRACE_FIELD(unsigned long, caller[7], stack7)
 	),
-	TPRAWFMT("\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n"
+	TP_RAW_FMT("\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n"
 		 "\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n")
 );
 
@@ -108,7 +108,7 @@ TRACE_EVENT_FORMAT(print, TRACE_PRINT, print_entry, ignore,
 		TRACE_FIELD(unsigned int, depth, depth)
 		TRACE_FIELD_ZERO_CHAR(buf)
 	),
-	TPRAWFMT("%08lx (%d) %s")
+	TP_RAW_FMT("%08lx (%d) %s")
 );
 
 TRACE_EVENT_FORMAT(branch, TRACE_BRANCH, trace_branch, ignore,
@@ -118,7 +118,7 @@ TRACE_EVENT_FORMAT(branch, TRACE_BRANCH, trace_branch, ignore,
 		TRACE_FIELD_SPECIAL(char file[TRACE_FUNC_SIZE+1], file, file)
 		TRACE_FIELD(char, correct, correct)
 	),
-	TPRAWFMT("%u:%s:%s (%u)")
+	TP_RAW_FMT("%u:%s:%s (%u)")
 );
 
 TRACE_EVENT_FORMAT(hw_branch, TRACE_HW_BRANCHES, hw_branch_entry, ignore,
@@ -126,7 +126,7 @@ TRACE_EVENT_FORMAT(hw_branch, TRACE_HW_BRANCHES, hw_branch_entry, ignore,
 		TRACE_FIELD(u64, from, from)
 		TRACE_FIELD(u64, to, to)
 	),
-	TPRAWFMT("from: %llx to: %llx")
+	TP_RAW_FMT("from: %llx to: %llx")
 );
 
 TRACE_EVENT_FORMAT(power, TRACE_POWER, trace_power, ignore,
@@ -136,7 +136,7 @@ TRACE_EVENT_FORMAT(power, TRACE_POWER, trace_power, ignore,
 		TRACE_FIELD(int, state_data.type, type)
 		TRACE_FIELD(int, state_data.state, state)
 	),
-	TPRAWFMT("%llx->%llx type:%u state:%u")
+	TP_RAW_FMT("%llx->%llx type:%u state:%u")
 );
 
 TRACE_EVENT_FORMAT(kmem_alloc, TRACE_KMEM_ALLOC, kmemtrace_alloc_entry, ignore,
@@ -149,7 +149,7 @@ TRACE_EVENT_FORMAT(kmem_alloc, TRACE_KMEM_ALLOC, kmemtrace_alloc_entry, ignore,
 		TRACE_FIELD(gfp_t, gfp_flags, gfp_flags)
 		TRACE_FIELD(int, node, node)
 	),
-	TPRAWFMT("type:%u call_site:%lx ptr:%p req:%lu alloc:%lu"
+	TP_RAW_FMT("type:%u call_site:%lx ptr:%p req:%lu alloc:%lu"
 		 " flags:%x node:%d")
 );
 
@@ -159,7 +159,7 @@ TRACE_EVENT_FORMAT(kmem_free, TRACE_KMEM_FREE, kmemtrace_free_entry, ignore,
 		TRACE_FIELD(unsigned long, call_site, call_site)
 		TRACE_FIELD(const void *, ptr, ptr)
 	),
-	TPRAWFMT("type:%u call_site:%lx ptr:%p")
+	TP_RAW_FMT("type:%u call_site:%lx ptr:%p")
 );
 
 #undef TRACE_SYSTEM
diff --git a/kernel/trace/trace_events_stage_2.h b/kernel/trace/trace_events_stage_2.h
index d24a97e..8e2e0f5 100644
--- a/kernel/trace/trace_events_stage_2.h
+++ b/kernel/trace/trace_events_stage_2.h
@@ -20,7 +20,7 @@
  *
  *	field = (typeof(field))entry;
  *
- *	ret = trace_seq_printf(s, <TPRAWFMT> "%s", <ARGS> "\n");
+ *	ret = trace_seq_printf(s, <TP_RAW_FMT> "%s", <ARGS> "\n");
  *	if (!ret)
  *		return TRACE_TYPE_PARTIAL_LINE;
  *
@@ -44,8 +44,8 @@
 	field->item,
 
 
-#undef TPRAWFMT
-#define TPRAWFMT(args...)	args
+#undef TP_RAW_FMT
+#define TP_RAW_FMT(args...)	args
 
 #undef TRACE_EVENT_FORMAT
 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)	\
diff --git a/kernel/trace/trace_events_stage_3.h b/kernel/trace/trace_events_stage_3.h
index 2c8d76c..557ca52 100644
--- a/kernel/trace/trace_events_stage_3.h
+++ b/kernel/trace/trace_events_stage_3.h
@@ -106,8 +106,8 @@
  *
  */
 
-#undef TPFMT
-#define TPFMT(fmt, args...)	fmt "\n", ##args
+#undef TP_FMT
+#define TP_FMT(fmt, args...)	fmt "\n", ##args
 
 #define _TRACE_FORMAT(call, proto, args, fmt)				\
 static void ftrace_event_##call(proto)					\
@@ -152,8 +152,8 @@ __attribute__((section("_ftrace_events"))) event_##call = {		\
 #define TRACE_FIELD(type, item, assign)\
 	entry->item = assign;
 
-#undef TPCMD
-#define TPCMD(cmd...)	cmd
+#undef TP_CMD
+#define TP_CMD(cmd...)	cmd
 
 #undef TRACE_ENTRY
 #define TRACE_ENTRY	entry
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index 7162ab4..e62bc10 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -26,8 +26,8 @@
 		return 0;
 
 
-#undef TPRAWFMT
-#define TPRAWFMT(args...) args
+#undef TP_RAW_FMT
+#define TP_RAW_FMT(args...) args
 
 #undef TRACE_EVENT_FORMAT
 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)	\
@@ -57,8 +57,8 @@ ftrace_format_##call(struct trace_seq *s)				\
 #define TRACE_FIELD(type, item, assign)\
 	entry->item = assign;
 
-#undef TPCMD
-#define TPCMD(cmd...)	cmd
+#undef TP_CMD
+#define TP_CMD(cmd...)	cmd
 
 #undef TRACE_ENTRY
 #define TRACE_ENTRY	entry
diff --git a/kernel/trace/trace_format.h b/kernel/trace/trace_format.h
deleted file mode 100644
index 97e59a9..0000000
--- a/kernel/trace/trace_format.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Setup the showing format of trace point.
- *
- * int
- * ftrace_format_##call(struct trace_seq *s)
- * {
- *	struct ftrace_raw_##call field;
- *	int ret;
- *
- *	ret = trace_seq_printf(s, #type " " #item ";"
- *			       " size:%d; offset:%d;\n",
- *			       sizeof(field.type),
- *			       offsetof(struct ftrace_raw_##call,
- *					item));
- *
- * }
- */
-
-#undef TRACE_STRUCT
-#define TRACE_STRUCT(args...) args
-
-#undef TRACE_FIELD
-#define TRACE_FIELD(type, item, assign)					\
-	ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t"	\
-			       "offset:%u;\tsize:%u;\n",		\
-			       (unsigned int)offsetof(typeof(field), item), \
-			       (unsigned int)sizeof(field.item));	\
-	if (!ret)							\
-		return 0;
-
-
-#undef TRACE_FIELD_SPECIAL
-#define TRACE_FIELD_SPECIAL(type_item, item, cmd)			\
-	ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t"	\
-			       "offset:%u;\tsize:%u;\n",		\
-			       (unsigned int)offsetof(typeof(field), item), \
-			       (unsigned int)sizeof(field.item));	\
-	if (!ret)							\
-		return 0;
-
-#undef TRACE_EVENT_FORMAT
-#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)	\
-static int								\
-ftrace_format_##call(struct trace_seq *s)				\
-{									\
-	struct ftrace_raw_##call field;					\
-	int ret;							\
-									\
-	tstruct;							\
-									\
-	trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt);		\
-									\
-	return ret;							\
-}
-
diff --git a/samples/tracepoints/tp-samples-trace.h b/samples/tracepoints/tp-samples-trace.h
index 01724e0..dffdc49 100644
--- a/samples/tracepoints/tp-samples-trace.h
+++ b/samples/tracepoints/tp-samples-trace.h
@@ -5,9 +5,9 @@
 #include <linux/tracepoint.h>
 
 DECLARE_TRACE(subsys_event,
-	TPPROTO(struct inode *inode, struct file *file),
-	TPARGS(inode, file));
+	TP_PROTO(struct inode *inode, struct file *file),
+	TP_ARGS(inode, file));
 DECLARE_TRACE(subsys_eventb,
-	TPPROTO(void),
-	TPARGS());
+	TP_PROTO(void),
+	TP_ARGS());
 #endif
-- 
1.6.1.3

-- 

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

* [PATCH 3/7] tracing: use generic __stringify
  2009-03-10  4:57 [PATCH 0/7] [GIT PULL] enhancements for tracing in tip Steven Rostedt
  2009-03-10  4:57 ` [PATCH 1/7] tracing: typecast sizeof and offsetof to unsigned int Steven Rostedt
  2009-03-10  4:57 ` [PATCH 2/7] tracing: replace TP<var> with TP_<var> Steven Rostedt
@ 2009-03-10  4:57 ` Steven Rostedt
  2009-03-10 10:56   ` Frederic Weisbecker
  2009-03-10  4:57 ` [PATCH 4/7] tracing: new format for specialized trace points Steven Rostedt
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 25+ messages in thread
From: Steven Rostedt @ 2009-03-10  4:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
	Frederic Weisbecker, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang, Steven Rostedt

[-- Attachment #1: 0003-tracing-use-generic-__stringify.patch --]
[-- Type: text/plain, Size: 2819 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: clean up

This removes the custom made STR(x) macros in the tracer and uses
the generic __stringify macro instead.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/events.c               |    4 +---
 kernel/trace/trace_events_stage_3.h |    4 ++--
 kernel/trace/trace_selftest.c       |    6 ++----
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/kernel/trace/events.c b/kernel/trace/events.c
index f2509cb..9fc918d 100644
--- a/kernel/trace/events.c
+++ b/kernel/trace/events.c
@@ -2,9 +2,7 @@
  * This is the place to register all trace points as events.
  */
 
-/* someday this needs to go in a generic header */
-#define __STR(x) #x
-#define STR(x) __STR(x)
+#include <linux/stringify.h>
 
 #include <trace/trace_events.h>
 
diff --git a/kernel/trace/trace_events_stage_3.h b/kernel/trace/trace_events_stage_3.h
index 557ca52..41b82b9 100644
--- a/kernel/trace/trace_events_stage_3.h
+++ b/kernel/trace/trace_events_stage_3.h
@@ -139,7 +139,7 @@ static struct ftrace_event_call __used					\
 __attribute__((__aligned__(4)))						\
 __attribute__((section("_ftrace_events"))) event_##call = {		\
 	.name 			= #call,				\
-	.system			= STR(TRACE_SYSTEM),			\
+	.system			= __stringify(TRACE_SYSTEM),		\
 	.regfunc		= ftrace_reg_event_##call,		\
 	.unregfunc		= ftrace_unreg_event_##call,		\
 }
@@ -225,7 +225,7 @@ static struct ftrace_event_call __used					\
 __attribute__((__aligned__(4)))						\
 __attribute__((section("_ftrace_events"))) event_##call = {		\
 	.name 			= #call,				\
-	.system			= STR(TRACE_SYSTEM),			\
+	.system			= __stringify(TRACE_SYSTEM),		\
 	.regfunc		= ftrace_reg_event_##call,		\
 	.unregfunc		= ftrace_unreg_event_##call,		\
 	.raw_init		= ftrace_raw_init_event_##call,		\
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
index 7238646..f907a2b 100644
--- a/kernel/trace/trace_selftest.c
+++ b/kernel/trace/trace_selftest.c
@@ -1,5 +1,6 @@
 /* Include in trace.c */
 
+#include <linux/stringify.h>
 #include <linux/kthread.h>
 #include <linux/delay.h>
 
@@ -100,9 +101,6 @@ static inline void warn_failed_init_tracer(struct tracer *trace, int init_ret)
 
 #ifdef CONFIG_DYNAMIC_FTRACE
 
-#define __STR(x) #x
-#define STR(x) __STR(x)
-
 /* Test dynamic code modification and ftrace filters */
 int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
 					   struct trace_array *tr,
@@ -130,7 +128,7 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
 	 * start of the function names. We simply put a '*' to
 	 * accommodate them.
 	 */
-	func_name = "*" STR(DYN_FTRACE_TEST_NAME);
+	func_name = "*" __stringify(DYN_FTRACE_TEST_NAME);
 
 	/* filter only on our function */
 	ftrace_set_filter(func_name, strlen(func_name), 1);
-- 
1.6.1.3

-- 

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

* [PATCH 4/7] tracing: new format for specialized trace points
  2009-03-10  4:57 [PATCH 0/7] [GIT PULL] enhancements for tracing in tip Steven Rostedt
                   ` (2 preceding siblings ...)
  2009-03-10  4:57 ` [PATCH 3/7] tracing: use generic __stringify Steven Rostedt
@ 2009-03-10  4:57 ` Steven Rostedt
  2009-03-10  5:50   ` KOSAKI Motohiro
                     ` (2 more replies)
  2009-03-10  4:57 ` [PATCH 5/7] tracing: convert the sched trace points to the TRACE_EVENT macros Steven Rostedt
                   ` (3 subsequent siblings)
  7 siblings, 3 replies; 25+ messages in thread
From: Steven Rostedt @ 2009-03-10  4:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
	Frederic Weisbecker, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang, Steven Rostedt

[-- Attachment #1: 0004-tracing-new-format-for-specialized-trace-points.patch --]
[-- Type: text/plain, Size: 20720 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: clean up and enhancement

The TRACE_EVENT_FORMAT macro looks quite ugly and is limited in its
ability to save data as well as to print the record out. Working with
Ingo Molnar, we came up with a new format that is much more pleasing to
the eye of C developers. This new macro is more C style than the old
macro, and is more obvious to what it does.

Here's the example. The only updated macro in this patch is the
sched_switch trace point.

The old method looked like this:

 TRACE_EVENT_FORMAT(sched_switch,
        TP_PROTO(struct rq *rq, struct task_struct *prev,
                struct task_struct *next),
        TP_ARGS(rq, prev, next),
        TP_FMT("task %s:%d ==> %s:%d",
              prev->comm, prev->pid, next->comm, next->pid),
        TRACE_STRUCT(
                TRACE_FIELD(pid_t, prev_pid, prev->pid)
                TRACE_FIELD(int, prev_prio, prev->prio)
                TRACE_FIELD_SPECIAL(char next_comm[TASK_COMM_LEN],
                                    next_comm,
                                    TP_CMD(memcpy(TRACE_ENTRY->next_comm,
                                                 next->comm,
                                                 TASK_COMM_LEN)))
                TRACE_FIELD(pid_t, next_pid, next->pid)
                TRACE_FIELD(int, next_prio, next->prio)
        ),
        TP_RAW_FMT("prev %d:%d ==> next %s:%d:%d")
        );

The above method is hard to read and requires two format fields.

The new method:

 /*
  * Tracepoint for task switches, performed by the scheduler:
  *
  * (NOTE: the 'rq' argument is not used by generic trace events,
  *        but used by the latency tracer plugin. )
  */
 TRACE_EVENT(sched_switch,

	TP_PROTO(struct rq *rq, struct task_struct *prev,
		 struct task_struct *next),

	TP_ARGS(rq, prev, next),

	TP_STRUCT__entry(
		__array(	char,	prev_comm,	TASK_COMM_LEN	)
		__field(	pid_t,	prev_pid			)
		__field(	int,	prev_prio			)
		__array(	char,	next_comm,	TASK_COMM_LEN	)
		__field(	pid_t,	next_pid			)
		__field(	int,	next_prio			)
	),

	TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
		__entry->next_comm, __entry->next_pid, __entry->next_prio),

	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;
	)
 );

This macro is called TRACE_EVENT, it is broken up into 5 parts:

 TP_PROTO:        the proto type of the trace point
 TP_ARGS:         the arguments of the trace point
 TP_STRUCT_entry: the structure layout of the entry in the ring buffer
 TP_printk:       the printk format
 TP_fast_assign:  the method used to write the entry into the ring buffer

The structure is the definition of how the event will be saved in the
ring buffer. The printk is used by the internal tracing in case of
an oops, and the kernel needs to print out the format of the record
to the console. This the TP_printk gives a means to show the records
in a human readable format. It is also used to print out the data
from the trace file.

The TP_fast_assign is executed directly. It is basically like a C function,
where the __entry is the handle to the record.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 include/linux/tracepoint.h          |    3 +
 include/trace/sched_event_types.h   |   48 +++++++----
 kernel/trace/trace.h                |    5 -
 kernel/trace/trace_event_types.h    |    3 +-
 kernel/trace/trace_events.c         |  159 +----------------------------------
 kernel/trace/trace_events_stage_1.h |   28 ++++---
 kernel/trace/trace_events_stage_2.h |   89 ++++++++++++++++----
 kernel/trace/trace_events_stage_3.h |   34 ++-----
 kernel/trace/trace_export.c         |   23 +++++-
 9 files changed, 159 insertions(+), 233 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 3bcc3e1..6b4f1bb 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -160,4 +160,7 @@ static inline void tracepoint_synchronize_unregister(void)
 #define TRACE_EVENT_FORMAT(name, proto, args, fmt, struct, tpfmt)	\
 	TRACE_FORMAT(name, PARAMS(proto), PARAMS(args), PARAMS(fmt))
 
+#define TRACE_EVENT(name, proto, args, struct, print, assign)	\
+	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+
 #endif
diff --git a/include/trace/sched_event_types.h b/include/trace/sched_event_types.h
index 71b1482..aa77fb7 100644
--- a/include/trace/sched_event_types.h
+++ b/include/trace/sched_event_types.h
@@ -62,25 +62,41 @@ TRACE_EVENT_FORMAT(sched_wakeup_new,
 	TP_RAW_FMT("task %d success=%d")
 	);
 
-TRACE_EVENT_FORMAT(sched_switch,
+/*
+ * Tracepoint for task switches, performed by the scheduler:
+ *
+ * (NOTE: the 'rq' argument is not used by generic trace events,
+ *        but used by the latency tracer plugin. )
+ */
+TRACE_EVENT(sched_switch,
+
 	TP_PROTO(struct rq *rq, struct task_struct *prev,
-		struct task_struct *next),
+		 struct task_struct *next),
+
 	TP_ARGS(rq, prev, next),
-	TP_FMT("task %s:%d ==> %s:%d",
-	      prev->comm, prev->pid, next->comm, next->pid),
-	TRACE_STRUCT(
-		TRACE_FIELD(pid_t, prev_pid, prev->pid)
-		TRACE_FIELD(int, prev_prio, prev->prio)
-		TRACE_FIELD_SPECIAL(char next_comm[TASK_COMM_LEN],
-				    next_comm,
-				    TP_CMD(memcpy(TRACE_ENTRY->next_comm,
-						 next->comm,
-						 TASK_COMM_LEN)))
-		TRACE_FIELD(pid_t, next_pid, next->pid)
-		TRACE_FIELD(int, next_prio, next->prio)
+
+	TP_STRUCT__entry(
+		__array(	char,	prev_comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	prev_pid			)
+		__field(	int,	prev_prio			)
+		__array(	char,	next_comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	next_pid			)
+		__field(	int,	next_prio			)
 	),
-	TP_RAW_FMT("prev %d:%d ==> next %s:%d:%d")
-	);
+
+	TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
+		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
+		__entry->next_comm, __entry->next_pid, __entry->next_prio),
+
+	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;
+	)
+);
 
 TRACE_EVENT_FORMAT(sched_migrate_task,
 	TP_PROTO(struct task_struct *p, int orig_cpu, int dest_cpu),
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 2bfb7d1..c5e1d88 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -751,12 +751,7 @@ struct ftrace_event_call {
 	int		(*regfunc)(void);
 	void		(*unregfunc)(void);
 	int		id;
-	struct dentry	*raw_dir;
-	int		raw_enabled;
-	int		type;
 	int		(*raw_init)(void);
-	int		(*raw_reg)(void);
-	void		(*raw_unreg)(void);
 	int		(*show_format)(struct trace_seq *s);
 };
 
diff --git a/kernel/trace/trace_event_types.h b/kernel/trace/trace_event_types.h
index d94179a..5cca4c9 100644
--- a/kernel/trace/trace_event_types.h
+++ b/kernel/trace/trace_event_types.h
@@ -106,9 +106,10 @@ TRACE_EVENT_FORMAT(print, TRACE_PRINT, print_entry, ignore,
 	TRACE_STRUCT(
 		TRACE_FIELD(unsigned long, ip, ip)
 		TRACE_FIELD(unsigned int, depth, depth)
+		TRACE_FIELD(char *, fmt, fmt)
 		TRACE_FIELD_ZERO_CHAR(buf)
 	),
-	TP_RAW_FMT("%08lx (%d) %s")
+	TP_RAW_FMT("%08lx (%d) fmt:%p %s")
 );
 
 TRACE_EVENT_FORMAT(branch, TRACE_BRANCH, trace_branch, ignore,
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index fa32ca3..1880a64 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -59,22 +59,12 @@ static void ftrace_event_enable_disable(struct ftrace_event_call *call,
 			call->enabled = 0;
 			call->unregfunc();
 		}
-		if (call->raw_enabled) {
-			call->raw_enabled = 0;
-			call->raw_unreg();
-		}
 		break;
 	case 1:
-		if (!call->enabled &&
-		    (call->type & TRACE_EVENT_TYPE_PRINTF)) {
+		if (!call->enabled) {
 			call->enabled = 1;
 			call->regfunc();
 		}
-		if (!call->raw_enabled &&
-		    (call->type & TRACE_EVENT_TYPE_RAW)) {
-			call->raw_enabled = 1;
-			call->raw_reg();
-		}
 		break;
 	}
 }
@@ -300,7 +290,7 @@ event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
 	struct ftrace_event_call *call = filp->private_data;
 	char *buf;
 
-	if (call->enabled || call->raw_enabled)
+	if (call->enabled)
 		buf = "1\n";
 	else
 		buf = "0\n";
@@ -346,107 +336,6 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 	return cnt;
 }
 
-static ssize_t
-event_type_read(struct file *filp, char __user *ubuf, size_t cnt,
-		loff_t *ppos)
-{
-	struct ftrace_event_call *call = filp->private_data;
-	char buf[16];
-	int r = 0;
-
-	if (call->type & TRACE_EVENT_TYPE_PRINTF)
-		r += sprintf(buf, "printf\n");
-
-	if (call->type & TRACE_EVENT_TYPE_RAW)
-		r += sprintf(buf+r, "raw\n");
-
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
-}
-
-static ssize_t
-event_type_write(struct file *filp, const char __user *ubuf, size_t cnt,
-		 loff_t *ppos)
-{
-	struct ftrace_event_call *call = filp->private_data;
-	char buf[64];
-
-	/*
-	 * If there's only one type, we can't change it.
-	 * And currently we always have printf type, and we
-	 * may or may not have raw type.
-	 *
-	 * This is a redundant check, the file should be read
-	 * only if this is the case anyway.
-	 */
-
-	if (!call->raw_init)
-		return -EPERM;
-
-	if (cnt >= sizeof(buf))
-		return -EINVAL;
-
-	if (copy_from_user(&buf, ubuf, cnt))
-		return -EFAULT;
-
-	buf[cnt] = 0;
-
-	if (!strncmp(buf, "printf", 6) &&
-	    (!buf[6] || isspace(buf[6]))) {
-
-		call->type = TRACE_EVENT_TYPE_PRINTF;
-
-		/*
-		 * If raw enabled, the disable it and enable
-		 * printf type.
-		 */
-		if (call->raw_enabled) {
-			call->raw_enabled = 0;
-			call->raw_unreg();
-
-			call->enabled = 1;
-			call->regfunc();
-		}
-
-	} else if (!strncmp(buf, "raw", 3) &&
-	    (!buf[3] || isspace(buf[3]))) {
-
-		call->type = TRACE_EVENT_TYPE_RAW;
-
-		/*
-		 * If printf enabled, the disable it and enable
-		 * raw type.
-		 */
-		if (call->enabled) {
-			call->enabled = 0;
-			call->unregfunc();
-
-			call->raw_enabled = 1;
-			call->raw_reg();
-		}
-	} else
-		return -EINVAL;
-
-	*ppos += cnt;
-
-	return cnt;
-}
-
-static ssize_t
-event_available_types_read(struct file *filp, char __user *ubuf, size_t cnt,
-			   loff_t *ppos)
-{
-	struct ftrace_event_call *call = filp->private_data;
-	char buf[16];
-	int r = 0;
-
-	r += sprintf(buf, "printf\n");
-
-	if (call->raw_init)
-		r += sprintf(buf+r, "raw\n");
-
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
-}
-
 #undef FIELD
 #define FIELD(type, name)						\
 	#type, #name, (unsigned int)offsetof(typeof(field), name),	\
@@ -470,6 +359,7 @@ static int trace_write_header(struct trace_seq *s)
 				FIELD(int, pid),
 				FIELD(int, tgid));
 }
+
 static ssize_t
 event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
 		  loff_t *ppos)
@@ -527,13 +417,6 @@ static const struct seq_operations show_set_event_seq_ops = {
 	.stop = t_stop,
 };
 
-static const struct file_operations ftrace_avail_fops = {
-	.open = ftrace_event_seq_open,
-	.read = seq_read,
-	.llseek = seq_lseek,
-	.release = seq_release,
-};
-
 static const struct file_operations ftrace_set_event_fops = {
 	.open = ftrace_event_seq_open,
 	.read = seq_read,
@@ -548,17 +431,6 @@ static const struct file_operations ftrace_enable_fops = {
 	.write = event_enable_write,
 };
 
-static const struct file_operations ftrace_type_fops = {
-	.open = tracing_open_generic,
-	.read = event_type_read,
-	.write = event_type_write,
-};
-
-static const struct file_operations ftrace_available_types_fops = {
-	.open = tracing_open_generic,
-	.read = event_available_types_read,
-};
-
 static const struct file_operations ftrace_event_format_fops = {
 	.open = tracing_open_generic,
 	.read = event_format_read,
@@ -647,9 +519,6 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
 		}
 	}
 
-	/* default the output to printf */
-	call->type = TRACE_EVENT_TYPE_PRINTF;
-
 	call->dir = debugfs_create_dir(call->name, d_events);
 	if (!call->dir) {
 		pr_warning("Could not create debugfs "
@@ -665,21 +534,6 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
 				   "'%s/enable' entry\n", call->name);
 	}
 
-	/* Only let type be writable, if we can change it */
-	entry = debugfs_create_file("type",
-				    call->raw_init ? 0644 : 0444,
-				    call->dir, call,
-				    &ftrace_type_fops);
-	if (!entry)
-		pr_warning("Could not create debugfs "
-			   "'%s/type' entry\n", call->name);
-
-	entry = debugfs_create_file("available_types", 0444, call->dir, call,
-				    &ftrace_available_types_fops);
-	if (!entry)
-		pr_warning("Could not create debugfs "
-			   "'%s/available_types' entry\n", call->name);
-
 	/* A trace may not want to export its format */
 	if (!call->show_format)
 		return 0;
@@ -704,13 +558,6 @@ static __init int event_trace_init(void)
 	if (!d_tracer)
 		return 0;
 
-	entry = debugfs_create_file("available_events", 0444, d_tracer,
-				    (void *)&show_event_seq_ops,
-				    &ftrace_avail_fops);
-	if (!entry)
-		pr_warning("Could not create debugfs "
-			   "'available_events' entry\n");
-
 	entry = debugfs_create_file("set_event", 0644, d_tracer,
 				    (void *)&show_set_event_seq_ops,
 				    &ftrace_set_event_fops);
diff --git a/kernel/trace/trace_events_stage_1.h b/kernel/trace/trace_events_stage_1.h
index 3830a73..edfcbd3 100644
--- a/kernel/trace/trace_events_stage_1.h
+++ b/kernel/trace/trace_events_stage_1.h
@@ -18,19 +18,23 @@
 #define TRACE_FORMAT(call, proto, args, fmt)
 
 #undef TRACE_EVENT_FORMAT
-#define TRACE_EVENT_FORMAT(name, proto, args, fmt, tstruct, tpfmt)	\
-	struct ftrace_raw_##name {					\
-		struct trace_entry	ent;				\
-		tstruct							\
-	};								\
-	static struct ftrace_event_call event_##name
+#define TRACE_EVENT_FORMAT(name, proto, args, fmt, tstruct, tpfmt)
+
+#undef __array
+#define __array(type, item, len)	type	item[len];
 
-#undef TRACE_STRUCT
-#define TRACE_STRUCT(args...) args
+#undef __field
+#define __field(type, item)		type	item;
 
-#define TRACE_FIELD(type, item, assign) \
-	type item;
-#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
-	type_item;
+#undef TP_STRUCT__entry
+#define TP_STRUCT__entry(args...) args
+
+#undef TRACE_EVENT
+#define TRACE_EVENT(name, proto, args, tstruct, print, assign)	\
+	struct ftrace_raw_##name {				\
+		struct trace_entry	ent;			\
+		tstruct						\
+	};							\
+	static struct ftrace_event_call event_##name
 
 #include <trace/trace_event_types.h>
diff --git a/kernel/trace/trace_events_stage_2.h b/kernel/trace/trace_events_stage_2.h
index 8e2e0f5..d91bf4c 100644
--- a/kernel/trace/trace_events_stage_2.h
+++ b/kernel/trace/trace_events_stage_2.h
@@ -32,23 +32,14 @@
  * in binary.
  */
 
-#undef TRACE_STRUCT
-#define TRACE_STRUCT(args...) args
+#undef __entry
+#define __entry field
 
-#undef TRACE_FIELD
-#define TRACE_FIELD(type, item, assign) \
-	field->item,
+#undef TP_printk
+#define TP_printk(fmt, args...) fmt "\n", args
 
-#undef TRACE_FIELD_SPECIAL
-#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
-	field->item,
-
-
-#undef TP_RAW_FMT
-#define TP_RAW_FMT(args...)	args
-
-#undef TRACE_EVENT_FORMAT
-#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)	\
+#undef TRACE_EVENT
+#define TRACE_EVENT(call, proto, args, tstruct, print, assign)		\
 enum print_line_t							\
 ftrace_raw_output_##call(struct trace_iterator *iter, int flags)	\
 {									\
@@ -66,14 +57,76 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags)	\
 									\
 	field = (typeof(field))entry;					\
 									\
-	ret = trace_seq_printf(s, tpfmt "%s", tstruct "\n");		\
+	ret = trace_seq_printf(s, print);				\
 	if (!ret)							\
 		return TRACE_TYPE_PARTIAL_LINE;				\
 									\
 	return TRACE_TYPE_HANDLED;					\
 }
-
+	
 #include <trace/trace_event_types.h>
 
-#include "trace_format.h"
+/*
+ * Setup the showing format of trace point.
+ *
+ * int
+ * ftrace_format_##call(struct trace_seq *s)
+ * {
+ *	struct ftrace_raw_##call field;
+ *	int ret;
+ *
+ *	ret = trace_seq_printf(s, #type " " #item ";"
+ *			       " size:%d; offset:%d;\n",
+ *			       sizeof(field.type),
+ *			       offsetof(struct ftrace_raw_##call,
+ *					item));
+ *
+ * }
+ */
+
+#undef TP_STRUCT__entry
+#define TP_STRUCT__entry(args...) args
+
+#undef __field
+#define __field(type, item)					\
+	ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t"	\
+			       "offset:%u;\tsize:%u;\n",		\
+			       (unsigned int)offsetof(typeof(field), item), \
+			       (unsigned int)sizeof(field.item));	\
+	if (!ret)							\
+		return 0;
+
+#undef __array
+#define __array(type, item, len)						\
+	ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t"	\
+			       "offset:%u;\tsize:%u;\n",		\
+			       (unsigned int)offsetof(typeof(field), item), \
+			       (unsigned int)sizeof(field.item));	\
+	if (!ret)							\
+		return 0;
+
+#undef __entry
+#define __entry "REC"
+
+#undef TP_printk
+#define TP_printk(fmt, args...) "%s, %s\n", #fmt, #args
+
+#undef TP_fast_assign
+#define TP_fast_assign(args...) args
+
+#undef TRACE_EVENT
+#define TRACE_EVENT(call, proto, args, tstruct, print, func)		\
+static int								\
+ftrace_format_##call(struct trace_seq *s)				\
+{									\
+	struct ftrace_raw_##call field;					\
+	int ret;							\
+									\
+	tstruct;							\
+									\
+	trace_seq_printf(s, "\nprint fmt: " print);			\
+									\
+	return ret;							\
+}
+
 #include <trace/trace_event_types.h>
diff --git a/kernel/trace/trace_events_stage_3.h b/kernel/trace/trace_events_stage_3.h
index 41b82b9..8e398d8 100644
--- a/kernel/trace/trace_events_stage_3.h
+++ b/kernel/trace/trace_events_stage_3.h
@@ -144,27 +144,15 @@ __attribute__((section("_ftrace_events"))) event_##call = {		\
 	.unregfunc		= ftrace_unreg_event_##call,		\
 }
 
-#undef TRACE_FIELD
-#define TRACE_FIELD(type, item, assign)\
-	entry->item = assign;
-
-#undef TRACE_FIELD
-#define TRACE_FIELD(type, item, assign)\
-	entry->item = assign;
-
-#undef TP_CMD
-#define TP_CMD(cmd...)	cmd
-
-#undef TRACE_ENTRY
-#define TRACE_ENTRY	entry
+#undef TRACE_EVENT_FORMAT
+#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, raw)	\
+	TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt))
 
-#undef TRACE_FIELD_SPECIAL
-#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
-	cmd;
+#undef __entry
+#define __entry entry
 
-#undef TRACE_EVENT_FORMAT
-#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)	\
-_TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt))		\
+#undef TRACE_EVENT
+#define TRACE_EVENT(call, proto, args, tstruct, print, assign)		\
 									\
 static struct ftrace_event_call event_##call;				\
 									\
@@ -185,7 +173,7 @@ static void ftrace_raw_event_##call(proto)				\
 		return;							\
 	entry	= ring_buffer_event_data(event);			\
 									\
-	tstruct;							\
+	assign;								\
 									\
 	trace_current_buffer_unlock_commit(event, irq_flags, pc);	\
 }									\
@@ -226,10 +214,8 @@ __attribute__((__aligned__(4)))						\
 __attribute__((section("_ftrace_events"))) event_##call = {		\
 	.name 			= #call,				\
 	.system			= __stringify(TRACE_SYSTEM),		\
-	.regfunc		= ftrace_reg_event_##call,		\
-	.unregfunc		= ftrace_unreg_event_##call,		\
 	.raw_init		= ftrace_raw_init_event_##call,		\
-	.raw_reg		= ftrace_raw_reg_event_##call,		\
-	.raw_unreg		= ftrace_raw_unreg_event_##call,	\
+	.regfunc		= ftrace_raw_reg_event_##call,		\
+	.unregfunc		= ftrace_raw_unreg_event_##call,	\
 	.show_format		= ftrace_format_##call,			\
 }
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index e62bc10..23ae784 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -15,7 +15,28 @@
 
 #include "trace_output.h"
 
-#include "trace_format.h"
+
+#undef TRACE_STRUCT
+#define TRACE_STRUCT(args...) args
+
+#undef TRACE_FIELD
+#define TRACE_FIELD(type, item, assign)					\
+	ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t"	\
+			       "offset:%u;\tsize:%u;\n",		\
+			       (unsigned int)offsetof(typeof(field), item), \
+			       (unsigned int)sizeof(field.item));	\
+	if (!ret)							\
+		return 0;
+
+
+#undef TRACE_FIELD_SPECIAL
+#define TRACE_FIELD_SPECIAL(type_item, item, cmd)			\
+	ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t"	\
+			       "offset:%u;\tsize:%u;\n",		\
+			       (unsigned int)offsetof(typeof(field), item), \
+			       (unsigned int)sizeof(field.item));	\
+	if (!ret)							\
+		return 0;
 
 #undef TRACE_FIELD_ZERO_CHAR
 #define TRACE_FIELD_ZERO_CHAR(item)					\
-- 
1.6.1.3

-- 

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

* [PATCH 5/7] tracing: convert the sched trace points to the TRACE_EVENT macros
  2009-03-10  4:57 [PATCH 0/7] [GIT PULL] enhancements for tracing in tip Steven Rostedt
                   ` (3 preceding siblings ...)
  2009-03-10  4:57 ` [PATCH 4/7] tracing: new format for specialized trace points Steven Rostedt
@ 2009-03-10  4:57 ` Steven Rostedt
  2009-03-10  4:57 ` [PATCH 6/7] tracing: convert irq trace points to new macros Steven Rostedt
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2009-03-10  4:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
	Frederic Weisbecker, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang, Steven Rostedt

[-- Attachment #1: 0005-tracing-convert-the-sched-trace-points-to-the-TRACE.patch --]
[-- Type: text/plain, Size: 9127 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: enhancement

This patch converts the rest of the sched trace points to use the new
more powerful TRACE_EVENT macro.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 include/trace/sched_event_types.h |  322 ++++++++++++++++++++++++++++---------
 1 files changed, 246 insertions(+), 76 deletions(-)

diff --git a/include/trace/sched_event_types.h b/include/trace/sched_event_types.h
index aa77fb7..0bbbf41 100644
--- a/include/trace/sched_event_types.h
+++ b/include/trace/sched_event_types.h
@@ -8,59 +8,137 @@
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM sched
 
-TRACE_EVENT_FORMAT(sched_kthread_stop,
+/*
+ * Tracepoint for calling kthread_stop, performed to end a kthread:
+ */
+TRACE_EVENT(sched_kthread_stop,
+
 	TP_PROTO(struct task_struct *t),
+
 	TP_ARGS(t),
-	TP_FMT("task %s:%d", t->comm, t->pid),
-	TRACE_STRUCT(
-		TRACE_FIELD(pid_t, pid, t->pid)
+
+	TP_STRUCT__entry(
+		__array(	char,	comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	pid			)
 	),
-	TP_RAW_FMT("task %d")
-	);
 
-TRACE_EVENT_FORMAT(sched_kthread_stop_ret,
+	TP_printk("task %s:%d", __entry->comm, __entry->pid),
+
+	TP_fast_assign(
+		memcpy(__entry->comm, t->comm, TASK_COMM_LEN);
+		__entry->pid	= t->pid;
+	)
+);
+
+/*
+ * Tracepoint for the return value of the kthread stopping:
+ */
+TRACE_EVENT(sched_kthread_stop_ret,
+
 	TP_PROTO(int ret),
+
 	TP_ARGS(ret),
-	TP_FMT("ret=%d", ret),
-	TRACE_STRUCT(
-		TRACE_FIELD(int, ret, ret)
+
+	TP_STRUCT__entry(
+		__field(	int,	ret	)
 	),
-	TP_RAW_FMT("ret=%d")
-	);
 
-TRACE_EVENT_FORMAT(sched_wait_task,
+	TP_printk("ret %d", __entry->ret),
+
+	TP_fast_assign(
+		__entry->ret	= ret;
+	)
+);
+
+/*
+ * Tracepoint for waiting on task to unschedule:
+ *
+ * (NOTE: the 'rq' argument is not used by generic trace events,
+ *        but used by the latency tracer plugin. )
+ */
+TRACE_EVENT(sched_wait_task,
+
 	TP_PROTO(struct rq *rq, struct task_struct *p),
+
 	TP_ARGS(rq, p),
-	TP_FMT("task %s:%d", p->comm, p->pid),
-	TRACE_STRUCT(
-		TRACE_FIELD(pid_t, pid, p->pid)
+
+	TP_STRUCT__entry(
+		__array(	char,	comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	pid			)
+		__field(	int,	prio			)
 	),
-	TP_RAW_FMT("task %d")
-	);
 
-TRACE_EVENT_FORMAT(sched_wakeup,
+	TP_printk("task %s:%d [%d]",
+		  __entry->comm, __entry->pid, __entry->prio),
+
+	TP_fast_assign(
+		memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
+		__entry->pid	= p->pid;
+		__entry->prio	= p->prio;
+	)
+);
+
+/*
+ * Tracepoint for waking up a task:
+ *
+ * (NOTE: the 'rq' argument is not used by generic trace events,
+ *        but used by the latency tracer plugin. )
+ */
+TRACE_EVENT(sched_wakeup,
+
 	TP_PROTO(struct rq *rq, struct task_struct *p, int success),
+
 	TP_ARGS(rq, p, success),
-	TP_FMT("task %s:%d %s",
-	      p->comm, p->pid, success ? "succeeded" : "failed"),
-	TRACE_STRUCT(
-		TRACE_FIELD(pid_t, pid, p->pid)
-		TRACE_FIELD(int, success, success)
+
+	TP_STRUCT__entry(
+		__array(	char,	comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	pid			)
+		__field(	int,	prio			)
+		__field(	int,	success			)
 	),
-	TP_RAW_FMT("task %d success=%d")
-	);
 
-TRACE_EVENT_FORMAT(sched_wakeup_new,
+	TP_printk("task %s:%d [%d] success=%d",
+		  __entry->comm, __entry->pid, __entry->prio,
+		  __entry->success),
+
+	TP_fast_assign(
+		memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
+		__entry->pid		= p->pid;
+		__entry->prio		= p->prio;
+		__entry->success	= success;
+	)
+);
+
+/*
+ * Tracepoint for waking up a new task:
+ *
+ * (NOTE: the 'rq' argument is not used by generic trace events,
+ *        but used by the latency tracer plugin. )
+ */
+TRACE_EVENT(sched_wakeup_new,
+
 	TP_PROTO(struct rq *rq, struct task_struct *p, int success),
+
 	TP_ARGS(rq, p, success),
-	TP_FMT("task %s:%d",
-	      p->comm, p->pid, success ? "succeeded" : "failed"),
-	TRACE_STRUCT(
-		TRACE_FIELD(pid_t, pid, p->pid)
-		TRACE_FIELD(int, success, success)
+
+	TP_STRUCT__entry(
+		__array(	char,	comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	pid			)
+		__field(	int,	prio			)
+		__field(	int,	success			)
 	),
-	TP_RAW_FMT("task %d success=%d")
-	);
+
+	TP_printk("task %s:%d [%d] success=%d",
+		  __entry->comm, __entry->pid, __entry->prio,
+		  __entry->success),
+
+	TP_fast_assign(
+		memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
+		__entry->pid		= p->pid;
+		__entry->prio		= p->prio;
+		__entry->success	= success;
+	)
+);
 
 /*
  * Tracepoint for task switches, performed by the scheduler:
@@ -98,70 +176,162 @@ TRACE_EVENT(sched_switch,
 	)
 );
 
-TRACE_EVENT_FORMAT(sched_migrate_task,
+/*
+ * Tracepoint for a task being migrated:
+ */
+TRACE_EVENT(sched_migrate_task,
+
 	TP_PROTO(struct task_struct *p, int orig_cpu, int dest_cpu),
+
 	TP_ARGS(p, orig_cpu, dest_cpu),
-	TP_FMT("task %s:%d from: %d  to: %d",
-	      p->comm, p->pid, orig_cpu, dest_cpu),
-	TRACE_STRUCT(
-		TRACE_FIELD(pid_t, pid, p->pid)
-		TRACE_FIELD(int, orig_cpu, orig_cpu)
-		TRACE_FIELD(int, dest_cpu, dest_cpu)
+
+	TP_STRUCT__entry(
+		__array(	char,	comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	pid			)
+		__field(	int,	prio			)
+		__field(	int,	orig_cpu		)
+		__field(	int,	dest_cpu		)
 	),
-	TP_RAW_FMT("task %d  from: %d to: %d")
-	);
 
-TRACE_EVENT_FORMAT(sched_process_free,
+	TP_printk("task %s:%d [%d] from: %d  to: %d",
+		  __entry->comm, __entry->pid, __entry->prio,
+		  __entry->orig_cpu, __entry->dest_cpu),
+
+	TP_fast_assign(
+		memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
+		__entry->pid		= p->pid;
+		__entry->prio		= p->prio;
+		__entry->orig_cpu	= orig_cpu;
+		__entry->dest_cpu	= dest_cpu;
+	)
+);
+
+/*
+ * Tracepoint for freeing a task:
+ */
+TRACE_EVENT(sched_process_free,
+
 	TP_PROTO(struct task_struct *p),
+
 	TP_ARGS(p),
-	TP_FMT("task %s:%d", p->comm, p->pid),
-	TRACE_STRUCT(
-		TRACE_FIELD(pid_t, pid, p->pid)
+
+	TP_STRUCT__entry(
+		__array(	char,	comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	pid			)
+		__field(	int,	prio			)
 	),
-	TP_RAW_FMT("task %d")
-	);
 
-TRACE_EVENT_FORMAT(sched_process_exit,
+	TP_printk("task %s:%d [%d]",
+		  __entry->comm, __entry->pid, __entry->prio),
+
+	TP_fast_assign(
+		memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
+		__entry->pid		= p->pid;
+		__entry->prio		= p->prio;
+	)
+);
+
+/*
+ * Tracepoint for a task exiting:
+ */
+TRACE_EVENT(sched_process_exit,
+
 	TP_PROTO(struct task_struct *p),
+
 	TP_ARGS(p),
-	TP_FMT("task %s:%d", p->comm, p->pid),
-	TRACE_STRUCT(
-		TRACE_FIELD(pid_t, pid, p->pid)
+
+	TP_STRUCT__entry(
+		__array(	char,	comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	pid			)
+		__field(	int,	prio			)
 	),
-	TP_RAW_FMT("task %d")
-	);
 
-TRACE_EVENT_FORMAT(sched_process_wait,
+	TP_printk("task %s:%d [%d]",
+		  __entry->comm, __entry->pid, __entry->prio),
+
+	TP_fast_assign(
+		memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
+		__entry->pid		= p->pid;
+		__entry->prio		= p->prio;
+	)
+);
+
+/*
+ * Tracepoint for a waiting task:
+ */
+TRACE_EVENT(sched_process_wait,
+
 	TP_PROTO(struct pid *pid),
+
 	TP_ARGS(pid),
-	TP_FMT("pid %d", pid_nr(pid)),
-	TRACE_STRUCT(
-		TRACE_FIELD(pid_t, pid, pid_nr(pid))
+
+	TP_STRUCT__entry(
+		__array(	char,	comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	pid			)
+		__field(	int,	prio			)
 	),
-	TP_RAW_FMT("task %d")
-	);
 
-TRACE_EVENT_FORMAT(sched_process_fork,
+	TP_printk("task %s:%d [%d]",
+		  __entry->comm, __entry->pid, __entry->prio),
+
+	TP_fast_assign(
+		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
+		__entry->pid		= pid_nr(pid);
+		__entry->prio		= current->prio;
+	)
+);
+
+/*
+ * Tracepoint for do_fork:
+ */
+TRACE_EVENT(sched_process_fork,
+
 	TP_PROTO(struct task_struct *parent, struct task_struct *child),
+
 	TP_ARGS(parent, child),
-	TP_FMT("parent %s:%d  child %s:%d",
-	      parent->comm, parent->pid, child->comm, child->pid),
-	TRACE_STRUCT(
-		TRACE_FIELD(pid_t, parent, parent->pid)
-		TRACE_FIELD(pid_t, child, child->pid)
+
+	TP_STRUCT__entry(
+		__array(	char,	parent_comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	parent_pid			)
+		__array(	char,	child_comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	child_pid			)
 	),
-	TP_RAW_FMT("parent %d  child %d")
-	);
 
-TRACE_EVENT_FORMAT(sched_signal_send,
+	TP_printk("parent %s:%d  child %s:%d",
+		__entry->parent_comm, __entry->parent_pid,
+		__entry->child_comm, __entry->child_pid),
+
+	TP_fast_assign(
+		memcpy(__entry->parent_comm, parent->comm, TASK_COMM_LEN);
+		__entry->parent_pid	= parent->pid;
+		memcpy(__entry->child_comm, child->comm, TASK_COMM_LEN);
+		__entry->child_pid	= child->pid;
+	)
+);
+
+/*
+ * Tracepoint for sending a signal:
+ */
+TRACE_EVENT(sched_signal_send,
+
 	TP_PROTO(int sig, struct task_struct *p),
+
 	TP_ARGS(sig, p),
-	TP_FMT("sig: %d   task %s:%d", sig, p->comm, p->pid),
-	TRACE_STRUCT(
-		TRACE_FIELD(int, sig, sig)
-		TRACE_FIELD(pid_t, pid, p->pid)
+
+	TP_STRUCT__entry(
+		__field(	int,	sig			)
+		__array(	char,	comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	pid			)
 	),
-	TP_RAW_FMT("sig: %d  task %d")
-	);
+
+	TP_printk("sig: %d  task %s:%d",
+		  __entry->sig, __entry->comm, __entry->pid),
+
+	TP_fast_assign(
+		memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
+		__entry->pid	= p->pid;
+		__entry->sig	= sig;
+	)
+);
 
 #undef TRACE_SYSTEM
-- 
1.6.1.3

-- 

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

* [PATCH 6/7] tracing: convert irq trace points to new macros
  2009-03-10  4:57 [PATCH 0/7] [GIT PULL] enhancements for tracing in tip Steven Rostedt
                   ` (4 preceding siblings ...)
  2009-03-10  4:57 ` [PATCH 5/7] tracing: convert the sched trace points to the TRACE_EVENT macros Steven Rostedt
@ 2009-03-10  4:57 ` Steven Rostedt
  2009-03-10  4:57 ` [PATCH 7/7] tracing: remove obsolete TRACE_EVENT_FORMAT macro Steven Rostedt
  2009-03-10  8:59 ` [PATCH 0/7] [GIT PULL] enhancements for tracing in tip Ingo Molnar
  7 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2009-03-10  4:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
	Frederic Weisbecker, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang, Steven Rostedt

[-- Attachment #1: 0006-tracing-convert-irq-trace-points-to-new-macros.patch --]
[-- Type: text/plain, Size: 1880 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: enhancement

Converted the two irq trace point macros. The entry macro copies
the name of the irq handler, thus it is better to simply use the
TRACE_FORMAT macro which uses the trace_printk.

The return of the handler does not need to record the name, thus
the faster C style handler is more approriate.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 include/trace/irq_event_types.h |   38 ++++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/include/trace/irq_event_types.h b/include/trace/irq_event_types.h
index 0147d9e..43bcb74 100644
--- a/include/trace/irq_event_types.h
+++ b/include/trace/irq_event_types.h
@@ -8,26 +8,36 @@
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM irq
 
-TRACE_EVENT_FORMAT(irq_handler_entry,
+/*
+ * Tracepoint for entry of interrupt handler:
+ */
+TRACE_FORMAT(irq_handler_entry,
 	TP_PROTO(int irq, struct irqaction *action),
 	TP_ARGS(irq, action),
-	TP_FMT("irq=%d handler=%s", irq, action->name),
-	TRACE_STRUCT(
-		TRACE_FIELD(int, irq, irq)
-	),
-	TP_RAW_FMT("irq %d")
+	TP_FMT("irq=%d handler=%s", irq, action->name)
 	);
 
-TRACE_EVENT_FORMAT(irq_handler_exit,
+/*
+ * Tracepoint for return of an interrupt handler:
+ */
+TRACE_EVENT(irq_handler_exit,
+
 	TP_PROTO(int irq, struct irqaction *action, int ret),
+
 	TP_ARGS(irq, action, ret),
-	TP_FMT("irq=%d handler=%s return=%s",
-		irq, action->name, ret ? "handled" : "unhandled"),
-	TRACE_STRUCT(
-		TRACE_FIELD(int, irq, irq)
-		TRACE_FIELD(int, ret, ret)
+
+	TP_STRUCT__entry(
+		__field(	int,	irq	)
+		__field(	int,	ret	)
 	),
-	TP_RAW_FMT("irq %d ret %d")
-	);
+
+	TP_printk("irq=%d return=%s",
+		  __entry->irq, __entry->ret ? "handled" : "unhandled"),
+
+	TP_fast_assign(
+		__entry->irq	= irq;
+		__entry->ret	= ret;
+	)
+);
 
 #undef TRACE_SYSTEM
-- 
1.6.1.3

-- 

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

* [PATCH 7/7] tracing: remove obsolete TRACE_EVENT_FORMAT macro
  2009-03-10  4:57 [PATCH 0/7] [GIT PULL] enhancements for tracing in tip Steven Rostedt
                   ` (5 preceding siblings ...)
  2009-03-10  4:57 ` [PATCH 6/7] tracing: convert irq trace points to new macros Steven Rostedt
@ 2009-03-10  4:57 ` Steven Rostedt
  2009-03-17  8:08   ` Christoph Hellwig
  2009-03-10  8:59 ` [PATCH 0/7] [GIT PULL] enhancements for tracing in tip Ingo Molnar
  7 siblings, 1 reply; 25+ messages in thread
From: Steven Rostedt @ 2009-03-10  4:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
	Frederic Weisbecker, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang, Steven Rostedt

[-- Attachment #1: 0007-tracing-remove-obsolete-TRACE_EVENT_FORMAT-macro.patch --]
[-- Type: text/plain, Size: 3244 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: clean up

The TRACE_EVENT_FORMAT macro is no longer used by trace points
and only the DECLARE_TRACE, TRACE_FORMAT or TRACE_EVENT macros should
be used by them. Although the TRACE_EVENT_FORMAT macro is still used
by the internal tracing utility, it should not be used in core
kernel code.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 include/linux/tracepoint.h          |    3 ---
 include/trace/lockdep_event_types.h |    2 +-
 include/trace/sched_event_types.h   |    2 +-
 kernel/trace/trace_events_stage_1.h |    3 ---
 kernel/trace/trace_events_stage_3.h |    6 +-----
 5 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 6b4f1bb..69b5698 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -157,9 +157,6 @@ static inline void tracepoint_synchronize_unregister(void)
 #define TRACE_FORMAT(name, proto, args, fmt)		\
 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 
-#define TRACE_EVENT_FORMAT(name, proto, args, fmt, struct, tpfmt)	\
-	TRACE_FORMAT(name, PARAMS(proto), PARAMS(args), PARAMS(fmt))
-
 #define TRACE_EVENT(name, proto, args, struct, print, assign)	\
 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 
diff --git a/include/trace/lockdep_event_types.h b/include/trace/lockdep_event_types.h
index 1f00e8b..adccfcd 100644
--- a/include/trace/lockdep_event_types.h
+++ b/include/trace/lockdep_event_types.h
@@ -1,5 +1,5 @@
 
-#ifndef TRACE_EVENT_FORMAT
+#ifndef TRACE_FORMAT
 # error Do not include this file directly.
 # error Unless you know what you are doing.
 #endif
diff --git a/include/trace/sched_event_types.h b/include/trace/sched_event_types.h
index 0bbbf41..fb37af6 100644
--- a/include/trace/sched_event_types.h
+++ b/include/trace/sched_event_types.h
@@ -1,6 +1,6 @@
 
 /* use <trace/sched.h> instead */
-#ifndef TRACE_EVENT_FORMAT
+#ifndef TRACE_EVENT
 # error Do not include this file directly.
 # error Unless you know what you are doing.
 #endif
diff --git a/kernel/trace/trace_events_stage_1.h b/kernel/trace/trace_events_stage_1.h
index edfcbd3..15e9bf9 100644
--- a/kernel/trace/trace_events_stage_1.h
+++ b/kernel/trace/trace_events_stage_1.h
@@ -17,9 +17,6 @@
 #undef TRACE_FORMAT
 #define TRACE_FORMAT(call, proto, args, fmt)
 
-#undef TRACE_EVENT_FORMAT
-#define TRACE_EVENT_FORMAT(name, proto, args, fmt, tstruct, tpfmt)
-
 #undef __array
 #define __array(type, item, len)	type	item[len];
 
diff --git a/kernel/trace/trace_events_stage_3.h b/kernel/trace/trace_events_stage_3.h
index 8e398d8..3ba55d4 100644
--- a/kernel/trace/trace_events_stage_3.h
+++ b/kernel/trace/trace_events_stage_3.h
@@ -35,7 +35,7 @@
  * }
  *
  *
- * For those macros defined with TRACE_EVENT_FORMAT:
+ * For those macros defined with TRACE_EVENT:
  *
  * static struct ftrace_event_call event_<call>;
  *
@@ -144,10 +144,6 @@ __attribute__((section("_ftrace_events"))) event_##call = {		\
 	.unregfunc		= ftrace_unreg_event_##call,		\
 }
 
-#undef TRACE_EVENT_FORMAT
-#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, raw)	\
-	TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt))
-
 #undef __entry
 #define __entry entry
 
-- 
1.6.1.3

-- 

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

* Re: [PATCH 1/7] tracing: typecast sizeof and offsetof to unsigned int
  2009-03-10  4:57 ` [PATCH 1/7] tracing: typecast sizeof and offsetof to unsigned int Steven Rostedt
@ 2009-03-10  5:20   ` Andrew Morton
  2009-03-10 13:39     ` Steven Rostedt
  0 siblings, 1 reply; 25+ messages in thread
From: Andrew Morton @ 2009-03-10  5:20 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Thomas Gleixner, Peter Zijlstra,
	Frederic Weisbecker, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang, Steven Rostedt

On Tue, 10 Mar 2009 00:57:11 -0400 Steven Rostedt <rostedt@goodmis.org> wrote:

> On x86_64 sizeof and offsetof are treated as long, where as on x86_32
> they are int. This patch typecasts them to unsigned int to avoid
> one arch giving warnings while the other does not.

Actually, both have type size_t.

>  static int trace_write_header(struct trace_seq *s)
>  {
> @@ -457,11 +458,11 @@ static int trace_write_header(struct trace_seq *s)
>  
>  	/* struct trace_entry */
>  	return trace_seq_printf(s,
> -				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
> -				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
> -				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
> -				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
> -				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
> +				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
> +				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
> +				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
> +				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
> +				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"

Which may be printed with %z.

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

* Re: [PATCH 4/7] tracing: new format for specialized trace points
  2009-03-10  4:57 ` [PATCH 4/7] tracing: new format for specialized trace points Steven Rostedt
@ 2009-03-10  5:50   ` KOSAKI Motohiro
  2009-03-10  8:54     ` Ingo Molnar
  2009-03-10  9:54   ` KOSAKI Motohiro
  2009-03-17  8:08   ` Christoph Hellwig
  2 siblings, 1 reply; 25+ messages in thread
From: KOSAKI Motohiro @ 2009-03-10  5:50 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: kosaki.motohiro, linux-kernel, Ingo Molnar, Andrew Morton,
	Thomas Gleixner, Peter Zijlstra, Frederic Weisbecker,
	Theodore Tso, Arnaldo Carvalho de Melo, H. Peter Anvin,
	Mathieu Desnoyers, Lai Jiangshan, Martin J. Bligh,
	Frank Ch. Eigler, Larry Woodman, Jason Baron, Tom Zanussi,
	Masami Hiramatsu, Christoph Hellwig, Jiaying Zhang,
	Steven Rostedt

Hi Steven,

>  TRACE_EVENT(sched_switch,
> 
> 	TP_PROTO(struct rq *rq, struct task_struct *prev,
> 		 struct task_struct *next),
> 
> 	TP_ARGS(rq, prev, next),
> 
> 	TP_STRUCT__entry(
> 		__array(	char,	prev_comm,	TASK_COMM_LEN	)
> 		__field(	pid_t,	prev_pid			)
> 		__field(	int,	prev_prio			)
> 		__array(	char,	next_comm,	TASK_COMM_LEN	)
> 		__field(	pid_t,	next_pid			)
> 		__field(	int,	next_prio			)
> 	),
> 
> 	TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
> 		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
> 		__entry->next_comm, __entry->next_pid, __entry->next_prio),
> 
> 	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;
> 	)
>  );

Could you please write the documentation how to make new tracepont and 
use various TP_ macro?
Some developer (include me) plan to add new tracepoint. but these macro
usage is a bit difficult.




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

* Re: [PATCH 4/7] tracing: new format for specialized trace points
  2009-03-10  5:50   ` KOSAKI Motohiro
@ 2009-03-10  8:54     ` Ingo Molnar
  2009-03-10 13:45       ` Steven Rostedt
  0 siblings, 1 reply; 25+ messages in thread
From: Ingo Molnar @ 2009-03-10  8:54 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: Steven Rostedt, linux-kernel, Andrew Morton, Thomas Gleixner,
	Peter Zijlstra, Frederic Weisbecker, Theodore Tso,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Mathieu Desnoyers,
	Lai Jiangshan, Martin J. Bligh, Frank Ch. Eigler, Larry Woodman,
	Jason Baron, Tom Zanussi, Masami Hiramatsu, Christoph Hellwig,
	Jiaying Zhang, Steven Rostedt


* KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:

> Hi Steven,
> 
> >  TRACE_EVENT(sched_switch,
> > 
> > 	TP_PROTO(struct rq *rq, struct task_struct *prev,
> > 		 struct task_struct *next),
> > 
> > 	TP_ARGS(rq, prev, next),
> > 
> > 	TP_STRUCT__entry(
> > 		__array(	char,	prev_comm,	TASK_COMM_LEN	)
> > 		__field(	pid_t,	prev_pid			)
> > 		__field(	int,	prev_prio			)
> > 		__array(	char,	next_comm,	TASK_COMM_LEN	)
> > 		__field(	pid_t,	next_pid			)
> > 		__field(	int,	next_prio			)
> > 	),
> > 
> > 	TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
> > 		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
> > 		__entry->next_comm, __entry->next_pid, __entry->next_prio),
> > 
> > 	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;
> > 	)
> >  );
> 
> Could you please write the documentation how to make new 
> tracepont and use various TP_ macro? Some developer (include 
> me) plan to add new tracepoint. but these macro usage is a bit 
> difficult.

Sure, here's a commented/annotated variant:

  /*
   * We define a tracepoint, its arguments, its printk format
   * and its 'fast binay record' layout.
   *
   * Firstly, name your tracepoint via TRACE_EVENT(name : the 
   * 'subsystem_event' notation is fine.
   *
   * Think about this whole construct as the 
   * 'trace_sched_switch() function' from now on.
   */
 
  TRACE_EVENT(sched_switch,

        /*
         * A function has a regular function arguments 
         * prototype, declare it via TP_PROTO():
         */
 	TP_PROTO(struct rq *rq, struct task_struct *prev,
 		 struct task_struct *next),
 
        /*
         * Define the call signature of the 'function'. 
	 * (Design sidenote: we use this instead of a
	 *  TP_PROTO1/TP_PROTO2/TP_PROTO3 ugliness.)
         */
 	TP_ARGS(rq, prev, next),
 
        /*
         * Fast binary tracing: define the trace record via 
         * TP_STRUCT__entry(). You can think about it like a 
         * regular C structure local variable definition.
         *
         * This is how the trace record is structured and will
         * be saved into the ring buffer. These are the fields
         * that will be exposed to user-space in 
         * /debug/tracing/events/*/format.
         *
         * The declared 'local variable' is called '__entry'
         */
 	TP_STRUCT__entry(
 		__array(	char,	prev_comm,	TASK_COMM_LEN	)
 		__field(	pid_t,	prev_pid			)
 		__field(	int,	prev_prio			)
 		__array(	char,	next_comm,	TASK_COMM_LEN	)
 		__field(	pid_t,	next_pid			)
 		__field(	int,	next_prio			)
 	),

        /*
         * Assign the entry into the trace record, by embedding 
         * a full C statement block into TP_fast_assign(). You 
         * can refer to the trace record as '__entry' - 
         * otherwise you can put arbitrary C code in here.
         *
         * Note: this C code will execute every time a trace event 
         * happens, on an active tracepoint.
         */
 	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;
 	)

        /*
         * Formatted output of a trace record via TP_printk(). 
         * This is how the tracepoint will appear under ftrace 
         * plugins that make use of this tracepoint.
         *
         * (raw-binary tracing wont actually perform this step.)
         */
 	TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
 		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
 		__entry->next_comm, __entry->next_pid, __entry->next_prio),

  );

This macro construct is thus used for the regular printk format 
tracing setup, it is used to construct a function pointer based 
tracepoint callback (this is used by programmatic plugins and 
can also by used by generic instrumentation like SystemTap), and 
it is also used to expose a structured trace record in 
/debug/tracing/events/.

Steve: i flipped around TP_fast_assign() and TP_printk() in the 
example above because it makes more sense that way. (we first 
assign the record, then we print it out) I suspect we should 
flip it around in the code too.

	Ingo

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

* Re: [PATCH 0/7] [GIT PULL] enhancements for tracing in tip
  2009-03-10  4:57 [PATCH 0/7] [GIT PULL] enhancements for tracing in tip Steven Rostedt
                   ` (6 preceding siblings ...)
  2009-03-10  4:57 ` [PATCH 7/7] tracing: remove obsolete TRACE_EVENT_FORMAT macro Steven Rostedt
@ 2009-03-10  8:59 ` Ingo Molnar
  7 siblings, 0 replies; 25+ messages in thread
From: Ingo Molnar @ 2009-03-10  8:59 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
	Frederic Weisbecker, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang


* Steven Rostedt <rostedt@goodmis.org> wrote:

> 
> Ingo,
> 
> This patch series replaces the TRACE_EVENT_FORMAT with the new 
> TRACE_EVENT
> 
> NOTE: I started with a pull from tip/tracing/printk. It does 
> not show up as a merge since I did the pull at the point where 
> it forked. But by pulling this branch, you will also receive 
> your changes from tracing/printk. I rebased my changes off of 
> this pull so that my changes would be after the pull, making 
> this patch series cleaner.

(that's OK - tracing/printk is still an active branch.)

> Please pull the latest tip/tracing/ftrace tree, which can be found at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> tip/tracing/ftrace
> 
> 
> Steven Rostedt (7):
>       tracing: typecast sizeof and offsetof to unsigned int
>       tracing: replace TP<var> with TP_<var>
>       tracing: use generic __stringify
>       tracing: new format for specialized trace points
>       tracing: convert the sched trace points to the TRACE_EVENT macros
>       tracing: convert irq trace points to new macros
>       tracing: remove obsolete TRACE_EVENT_FORMAT macro
> 
> ----
>  Documentation/tracepoints.txt          |    8 +-
>  include/linux/tracepoint.h             |   10 +-
>  include/trace/block.h                  |   70 +++---
>  include/trace/irq_event_types.h        |   46 ++--
>  include/trace/lockdep_event_types.h    |   26 +-
>  include/trace/power.h                  |   12 +-
>  include/trace/sched_event_types.h      |  442 +++++++++++++++++++++++---------
>  include/trace/workqueue.h              |   16 +-
>  kernel/trace/events.c                  |    4 +-
>  kernel/trace/trace.h                   |    5 -
>  kernel/trace/trace_event_types.h       |   29 +-
>  kernel/trace/trace_events.c            |  174 +------------
>  kernel/trace/trace_events_stage_1.h    |   27 +-
>  kernel/trace/trace_events_stage_2.h    |   91 +++++--
>  kernel/trace/trace_events_stage_3.h    |   42 +---
>  kernel/trace/trace_export.c            |   41 +++-
>  kernel/trace/trace_format.h            |   55 ----
>  kernel/trace/trace_selftest.c          |    6 +-
>  samples/tracepoints/tp-samples-trace.h |    8 +-
>  19 files changed, 575 insertions(+), 537 deletions(-)

Pulled, thanks Steve! (i suspect you'll fix the %z thing Andrew 
noticed in the next drop.)

	Ingo

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

* Re: [PATCH 4/7] tracing: new format for specialized trace points
  2009-03-10  4:57 ` [PATCH 4/7] tracing: new format for specialized trace points Steven Rostedt
  2009-03-10  5:50   ` KOSAKI Motohiro
@ 2009-03-10  9:54   ` KOSAKI Motohiro
  2009-03-10 13:55     ` Steven Rostedt
  2009-03-17  8:08   ` Christoph Hellwig
  2 siblings, 1 reply; 25+ messages in thread
From: KOSAKI Motohiro @ 2009-03-10  9:54 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: kosaki.motohiro, linux-kernel, Ingo Molnar, Andrew Morton,
	Thomas Gleixner, Peter Zijlstra, Frederic Weisbecker,
	Theodore Tso, Arnaldo Carvalho de Melo, H. Peter Anvin,
	Mathieu Desnoyers, Lai Jiangshan, Martin J. Bligh,
	Frank Ch. Eigler, Larry Woodman, Jason Baron, Tom Zanussi,
	Masami Hiramatsu, Christoph Hellwig, Jiaying Zhang,
	Steven Rostedt

Hi

I have few comment.


> diff --git a/kernel/trace/trace_event_types.h b/kernel/trace/trace_event_types.h
> index d94179a..5cca4c9 100644
> --- a/kernel/trace/trace_event_types.h
> +++ b/kernel/trace/trace_event_types.h
> @@ -106,9 +106,10 @@ TRACE_EVENT_FORMAT(print, TRACE_PRINT, print_entry, ignore,
>  	TRACE_STRUCT(
>  		TRACE_FIELD(unsigned long, ip, ip)
>  		TRACE_FIELD(unsigned int, depth, depth)
> +		TRACE_FIELD(char *, fmt, fmt)
>  		TRACE_FIELD_ZERO_CHAR(buf)
>  	),
> -	TP_RAW_FMT("%08lx (%d) %s")
> +	TP_RAW_FMT("%08lx (%d) fmt:%p %s")
>  );

I'm not sure about what mean /sys/kernel/debug/tracing/events/ftrace/print/format..

FWIW, I think the internal representation of trace_printk() is

struct print_entry {
        struct trace_entry      ent;
        unsigned long           ip;
        int                     depth;
        const char              *fmt;
        u32                     buf[];
};

then, buf doesn't gurantee NUL-termination, right?


> @@ -665,21 +534,6 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
>  				   "'%s/enable' entry\n", call->name);
>  	}
>  
> -	/* Only let type be writable, if we can change it */
> -	entry = debugfs_create_file("type",
> -				    call->raw_init ? 0644 : 0444,
> -				    call->dir, call,
> -				    &ftrace_type_fops);
> -	if (!entry)
> -		pr_warning("Could not create debugfs "
> -			   "'%s/type' entry\n", call->name);
> -
> -	entry = debugfs_create_file("available_types", 0444, call->dir, call,
> -				    &ftrace_available_types_fops);
> -	if (!entry)
> -		pr_warning("Could not create debugfs "
> -			   "'%s/available_types' entry\n", call->name);
> -
>  	/* A trace may not want to export its format */
>  	if (!call->show_format)
>  		return 0;

this code mean, the output type of event use debug/tracing/trace_options now, right?


> @@ -704,13 +558,6 @@ static __init int event_trace_init(void)
>  	if (!d_tracer)
>  		return 0;
>  
> -	entry = debugfs_create_file("available_events", 0444, d_tracer,
> -				    (void *)&show_event_seq_ops,
> -				    &ftrace_avail_fops);
> -	if (!entry)
> -		pr_warning("Could not create debugfs "
> -			   "'available_events' entry\n");
> -
>  	entry = debugfs_create_file("set_event", 0644, d_tracer,
>  				    (void *)&show_set_event_seq_ops,
>  				    &ftrace_set_event_fops);

Why do you remove available_events file?


> diff --git a/kernel/trace/trace_events_stage_2.h b/kernel/trace/trace_events_stage_2.h
> index 8e2e0f5..d91bf4c 100644
> --- a/kernel/trace/trace_events_stage_2.h
> +++ b/kernel/trace/trace_events_stage_2.h
> @@ -32,23 +32,14 @@
>   * in binary.
>   */
>  
> -#undef TRACE_STRUCT
> -#define TRACE_STRUCT(args...) args
> +#undef __entry
> +#define __entry field
>  
> -#undef TRACE_FIELD
> -#define TRACE_FIELD(type, item, assign) \
> -	field->item,
> +#undef TP_printk
> +#define TP_printk(fmt, args...) fmt "\n", args
>  
> -#undef TRACE_FIELD_SPECIAL
> -#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
> -	field->item,
> -
> -
> -#undef TP_RAW_FMT
> -#define TP_RAW_FMT(args...)	args
> -
> -#undef TRACE_EVENT_FORMAT
> -#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)	\
> +#undef TRACE_EVENT
> +#define TRACE_EVENT(call, proto, args, tstruct, print, assign)		\
>  enum print_line_t							\
>  ftrace_raw_output_##call(struct trace_iterator *iter, int flags)	\
>  {									\
> @@ -66,14 +57,76 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags)	\
>  									\
>  	field = (typeof(field))entry;					\
>  									\
> -	ret = trace_seq_printf(s, tpfmt "%s", tstruct "\n");		\
> +	ret = trace_seq_printf(s, print);				\
>  	if (!ret)							\
>  		return TRACE_TYPE_PARTIAL_LINE;				\
>  									\
>  	return TRACE_TYPE_HANDLED;					\
>  }

the header comment need the same chnge too.


>  #include <trace/trace_event_types.h>
> diff --git a/kernel/trace/trace_events_stage_3.h b/kernel/trace/trace_events_stage_3.h
> index 41b82b9..8e398d8 100644
> --- a/kernel/trace/trace_events_stage_3.h
> +++ b/kernel/trace/trace_events_stage_3.h
> @@ -144,27 +144,15 @@ __attribute__((section("_ftrace_events"))) event_##call = {		\
>  	.unregfunc		= ftrace_unreg_event_##call,		\
>  }
>  
> -#undef TRACE_FIELD
> -#define TRACE_FIELD(type, item, assign)\
> -	entry->item = assign;
> -
> -#undef TRACE_FIELD
> -#define TRACE_FIELD(type, item, assign)\
> -	entry->item = assign;
> -
> -#undef TP_CMD
> -#define TP_CMD(cmd...)	cmd
> -
> -#undef TRACE_ENTRY
> -#define TRACE_ENTRY	entry
> +#undef TRACE_EVENT_FORMAT
> +#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, raw)	\
> +	TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt))
>  
> -#undef TRACE_FIELD_SPECIAL
> -#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
> -	cmd;
> +#undef __entry
> +#define __entry entry
>  
> -#undef TRACE_EVENT_FORMAT
> -#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)	\
> -_TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt))		\
> +#undef TRACE_EVENT
> +#define TRACE_EVENT(call, proto, args, tstruct, print, assign)		\
>  									\
>  static struct ftrace_event_call event_##call;				\
>  									\
> @@ -185,7 +173,7 @@ static void ftrace_raw_event_##call(proto)				\
>  		return;							\
>  	entry	= ring_buffer_event_data(event);			\
>  									\
> -	tstruct;							\
> +	assign;								\
>  									\
>  	trace_current_buffer_unlock_commit(event, irq_flags, pc);	\
>  }									\

ditto

> @@ -226,10 +214,8 @@ __attribute__((__aligned__(4)))						\
>  __attribute__((section("_ftrace_events"))) event_##call = {		\
>  	.name 			= #call,				\
>  	.system			= __stringify(TRACE_SYSTEM),		\
> -	.regfunc		= ftrace_reg_event_##call,		\
> -	.unregfunc		= ftrace_unreg_event_##call,		\
>  	.raw_init		= ftrace_raw_init_event_##call,		\
> -	.raw_reg		= ftrace_raw_reg_event_##call,		\
> -	.raw_unreg		= ftrace_raw_unreg_event_##call,	\
> +	.regfunc		= ftrace_raw_reg_event_##call,		\
> +	.unregfunc		= ftrace_raw_unreg_event_##call,	\
>  	.show_format		= ftrace_format_##call,			\
>  }

ditto




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

* Re: [PATCH 3/7] tracing: use generic __stringify
  2009-03-10  4:57 ` [PATCH 3/7] tracing: use generic __stringify Steven Rostedt
@ 2009-03-10 10:56   ` Frederic Weisbecker
  2009-03-10 11:18     ` KOSAKI Motohiro
  2009-03-10 11:21     ` Peter Zijlstra
  0 siblings, 2 replies; 25+ messages in thread
From: Frederic Weisbecker @ 2009-03-10 10:56 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Thomas Gleixner,
	Peter Zijlstra, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang, Steven Rostedt

On Tue, Mar 10, 2009 at 12:57:13AM -0400, Steven Rostedt wrote:
> From: Steven Rostedt <srostedt@redhat.com>
> 
> Impact: clean up
> 
> This removes the custom made STR(x) macros in the tracer and uses
> the generic __stringify macro instead.
> 
> Signed-off-by: Steven Rostedt <srostedt@redhat.com>
> ---


Hi,

Why not simply use the # ?

Frederic.


>  kernel/trace/events.c               |    4 +---
>  kernel/trace/trace_events_stage_3.h |    4 ++--
>  kernel/trace/trace_selftest.c       |    6 ++----
>  3 files changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/kernel/trace/events.c b/kernel/trace/events.c
> index f2509cb..9fc918d 100644
> --- a/kernel/trace/events.c
> +++ b/kernel/trace/events.c
> @@ -2,9 +2,7 @@
>   * This is the place to register all trace points as events.
>   */
>  
> -/* someday this needs to go in a generic header */
> -#define __STR(x) #x
> -#define STR(x) __STR(x)
> +#include <linux/stringify.h>
>  
>  #include <trace/trace_events.h>
>  
> diff --git a/kernel/trace/trace_events_stage_3.h b/kernel/trace/trace_events_stage_3.h
> index 557ca52..41b82b9 100644
> --- a/kernel/trace/trace_events_stage_3.h
> +++ b/kernel/trace/trace_events_stage_3.h
> @@ -139,7 +139,7 @@ static struct ftrace_event_call __used					\
>  __attribute__((__aligned__(4)))						\
>  __attribute__((section("_ftrace_events"))) event_##call = {		\
>  	.name 			= #call,				\
> -	.system			= STR(TRACE_SYSTEM),			\
> +	.system			= __stringify(TRACE_SYSTEM),		\
>  	.regfunc		= ftrace_reg_event_##call,		\
>  	.unregfunc		= ftrace_unreg_event_##call,		\
>  }
> @@ -225,7 +225,7 @@ static struct ftrace_event_call __used					\
>  __attribute__((__aligned__(4)))						\
>  __attribute__((section("_ftrace_events"))) event_##call = {		\
>  	.name 			= #call,				\
> -	.system			= STR(TRACE_SYSTEM),			\
> +	.system			= __stringify(TRACE_SYSTEM),		\
>  	.regfunc		= ftrace_reg_event_##call,		\
>  	.unregfunc		= ftrace_unreg_event_##call,		\
>  	.raw_init		= ftrace_raw_init_event_##call,		\
> diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
> index 7238646..f907a2b 100644
> --- a/kernel/trace/trace_selftest.c
> +++ b/kernel/trace/trace_selftest.c
> @@ -1,5 +1,6 @@
>  /* Include in trace.c */
>  
> +#include <linux/stringify.h>
>  #include <linux/kthread.h>
>  #include <linux/delay.h>
>  
> @@ -100,9 +101,6 @@ static inline void warn_failed_init_tracer(struct tracer *trace, int init_ret)
>  
>  #ifdef CONFIG_DYNAMIC_FTRACE
>  
> -#define __STR(x) #x
> -#define STR(x) __STR(x)
> -
>  /* Test dynamic code modification and ftrace filters */
>  int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
>  					   struct trace_array *tr,
> @@ -130,7 +128,7 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
>  	 * start of the function names. We simply put a '*' to
>  	 * accommodate them.
>  	 */
> -	func_name = "*" STR(DYN_FTRACE_TEST_NAME);
> +	func_name = "*" __stringify(DYN_FTRACE_TEST_NAME);
>  
>  	/* filter only on our function */
>  	ftrace_set_filter(func_name, strlen(func_name), 1);
> -- 
> 1.6.1.3
> 
> -- 


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

* Re: [PATCH 3/7] tracing: use generic __stringify
  2009-03-10 10:56   ` Frederic Weisbecker
@ 2009-03-10 11:18     ` KOSAKI Motohiro
  2009-03-10 11:21     ` Peter Zijlstra
  1 sibling, 0 replies; 25+ messages in thread
From: KOSAKI Motohiro @ 2009-03-10 11:18 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Steven Rostedt, linux-kernel, Ingo Molnar, Andrew Morton,
	Thomas Gleixner, Peter Zijlstra, Theodore Tso,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Mathieu Desnoyers,
	Lai Jiangshan, Martin J. Bligh, Frank Ch. Eigler, Larry Woodman,
	Jason Baron, Tom Zanussi, Masami Hiramatsu, Christoph Hellwig,
	Jiaying Zhang, Steven Rostedt

2009/3/10 Frederic Weisbecker <fweisbec@gmail.com>:
> On Tue, Mar 10, 2009 at 12:57:13AM -0400, Steven Rostedt wrote:
>> From: Steven Rostedt <srostedt@redhat.com>
>>
>> Impact: clean up
>>
>> This removes the custom made STR(x) macros in the tracer and uses
>> the generic __stringify macro instead.
>>
>> Signed-off-by: Steven Rostedt <srostedt@redhat.com>
>> ---
>
>
> Hi,
>
> Why not simply use the # ?
>
> Frederic.

see following url's xstr macro description.

http://gcc.gnu.org/onlinedocs/gcc-4.3.3/cpp/Stringification.html#Stringification

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

* Re: [PATCH 3/7] tracing: use generic __stringify
  2009-03-10 10:56   ` Frederic Weisbecker
  2009-03-10 11:18     ` KOSAKI Motohiro
@ 2009-03-10 11:21     ` Peter Zijlstra
  2009-03-10 15:48       ` Frédéric Weisbecker
  1 sibling, 1 reply; 25+ messages in thread
From: Peter Zijlstra @ 2009-03-10 11:21 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Steven Rostedt, linux-kernel, Ingo Molnar, Andrew Morton,
	Thomas Gleixner, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang, Steven Rostedt

On Tue, 2009-03-10 at 11:56 +0100, Frederic Weisbecker wrote:
> On Tue, Mar 10, 2009 at 12:57:13AM -0400, Steven Rostedt wrote:
 
> > This removes the custom made STR(x) macros in the tracer and uses
> > the generic __stringify macro instead.

> Why not simply use the # ?

> > -#define __STR(x) #x
> > -#define STR(x) __STR(x)

#include <stdio.h>

#define FOO bar

#define __STR(x) #x
#define STR(x) __STR(x)

void main(void)
{
        printf("%s %s\n", __STR(FOO), STR(FOO));
}

$ gcc -o str str.c; ./str
str.c: In function ‘main’:
str.c:9: warning: return type of ‘main’ is not ‘int’
FOO bar




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

* Re: [PATCH 1/7] tracing: typecast sizeof and offsetof to unsigned int
  2009-03-10  5:20   ` Andrew Morton
@ 2009-03-10 13:39     ` Steven Rostedt
  0 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2009-03-10 13:39 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, Ingo Molnar, Thomas Gleixner, Peter Zijlstra,
	Frederic Weisbecker, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang, Steven Rostedt


On Mon, 9 Mar 2009, Andrew Morton wrote:

> On Tue, 10 Mar 2009 00:57:11 -0400 Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > On x86_64 sizeof and offsetof are treated as long, where as on x86_32
> > they are int. This patch typecasts them to unsigned int to avoid
> > one arch giving warnings while the other does not.
> 
> Actually, both have type size_t.
> 
> >  static int trace_write_header(struct trace_seq *s)
> >  {
> > @@ -457,11 +458,11 @@ static int trace_write_header(struct trace_seq *s)
> >  
> >  	/* struct trace_entry */
> >  	return trace_seq_printf(s,
> > -				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
> > -				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
> > -				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
> > -				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
> > -				"\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
> > +				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
> > +				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
> > +				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
> > +				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
> > +				"\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
> 
> Which may be printed with %z.

That's new to me ;-)

OK, I'll add a patch to my next series.

Thanks,

-- Steve


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

* Re: [PATCH 4/7] tracing: new format for specialized trace points
  2009-03-10  8:54     ` Ingo Molnar
@ 2009-03-10 13:45       ` Steven Rostedt
  0 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2009-03-10 13:45 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: KOSAKI Motohiro, linux-kernel, Andrew Morton, Thomas Gleixner,
	Peter Zijlstra, Frederic Weisbecker, Theodore Tso,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Mathieu Desnoyers,
	Lai Jiangshan, Martin J. Bligh, Frank Ch. Eigler, Larry Woodman,
	Jason Baron, Tom Zanussi, Masami Hiramatsu, Christoph Hellwig,
	Jiaying Zhang, Steven Rostedt


On Tue, 10 Mar 2009, Ingo Molnar wrote:

> 
> * KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> 
> > Hi Steven,
> > 
> > >  TRACE_EVENT(sched_switch,
> > > 
> > > 	TP_PROTO(struct rq *rq, struct task_struct *prev,
> > > 		 struct task_struct *next),
> > > 
> > > 	TP_ARGS(rq, prev, next),
> > > 
> > > 	TP_STRUCT__entry(
> > > 		__array(	char,	prev_comm,	TASK_COMM_LEN	)
> > > 		__field(	pid_t,	prev_pid			)
> > > 		__field(	int,	prev_prio			)
> > > 		__array(	char,	next_comm,	TASK_COMM_LEN	)
> > > 		__field(	pid_t,	next_pid			)
> > > 		__field(	int,	next_prio			)
> > > 	),
> > > 
> > > 	TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
> > > 		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
> > > 		__entry->next_comm, __entry->next_pid, __entry->next_prio),
> > > 
> > > 	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;
> > > 	)
> > >  );
> > 
> > Could you please write the documentation how to make new 
> > tracepont and use various TP_ macro? Some developer (include 
> > me) plan to add new tracepoint. but these macro usage is a bit 
> > difficult.
> 
> Sure, here's a commented/annotated variant:
> 
>   /*
>    * We define a tracepoint, its arguments, its printk format
>    * and its 'fast binay record' layout.
>    *
>    * Firstly, name your tracepoint via TRACE_EVENT(name : the 
>    * 'subsystem_event' notation is fine.
>    *
>    * Think about this whole construct as the 
>    * 'trace_sched_switch() function' from now on.
>    */
>  
>   TRACE_EVENT(sched_switch,
> 
>         /*
>          * A function has a regular function arguments 
>          * prototype, declare it via TP_PROTO():
>          */
>  	TP_PROTO(struct rq *rq, struct task_struct *prev,
>  		 struct task_struct *next),
>  
>         /*
>          * Define the call signature of the 'function'. 
> 	 * (Design sidenote: we use this instead of a
> 	 *  TP_PROTO1/TP_PROTO2/TP_PROTO3 ugliness.)
>          */
>  	TP_ARGS(rq, prev, next),
>  
>         /*
>          * Fast binary tracing: define the trace record via 
>          * TP_STRUCT__entry(). You can think about it like a 
>          * regular C structure local variable definition.
>          *
>          * This is how the trace record is structured and will
>          * be saved into the ring buffer. These are the fields
>          * that will be exposed to user-space in 
>          * /debug/tracing/events/*/format.
>          *
>          * The declared 'local variable' is called '__entry'
>          */
>  	TP_STRUCT__entry(
>  		__array(	char,	prev_comm,	TASK_COMM_LEN	)
>  		__field(	pid_t,	prev_pid			)
>  		__field(	int,	prev_prio			)
>  		__array(	char,	next_comm,	TASK_COMM_LEN	)
>  		__field(	pid_t,	next_pid			)
>  		__field(	int,	next_prio			)
>  	),
> 
>         /*
>          * Assign the entry into the trace record, by embedding 
>          * a full C statement block into TP_fast_assign(). You 
>          * can refer to the trace record as '__entry' - 
>          * otherwise you can put arbitrary C code in here.
>          *
>          * Note: this C code will execute every time a trace event 
>          * happens, on an active tracepoint.
>          */
>  	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;
>  	)
> 
>         /*
>          * Formatted output of a trace record via TP_printk(). 
>          * This is how the tracepoint will appear under ftrace 
>          * plugins that make use of this tracepoint.
>          *
>          * (raw-binary tracing wont actually perform this step.)
>          */
>  	TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
>  		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
>  		__entry->next_comm, __entry->next_pid, __entry->next_prio),
> 
>   );
> 
> This macro construct is thus used for the regular printk format 
> tracing setup, it is used to construct a function pointer based 
> tracepoint callback (this is used by programmatic plugins and 
> can also by used by generic instrumentation like SystemTap), and 
> it is also used to expose a structured trace record in 
> /debug/tracing/events/.

Thanks, I'll add the above to include/linux/tracepoint.h as a documented 
example.

> 
> Steve: i flipped around TP_fast_assign() and TP_printk() in the 
> example above because it makes more sense that way. (we first 
> assign the record, then we print it out) I suspect we should 
> flip it around in the code too.

OK, I'll make that change too.

-- Steve


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

* Re: [PATCH 4/7] tracing: new format for specialized trace points
  2009-03-10  9:54   ` KOSAKI Motohiro
@ 2009-03-10 13:55     ` Steven Rostedt
  0 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2009-03-10 13:55 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Thomas Gleixner,
	Peter Zijlstra, Frederic Weisbecker, Theodore Tso,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Mathieu Desnoyers,
	Lai Jiangshan, Martin J. Bligh, Frank Ch. Eigler, Larry Woodman,
	Jason Baron, Tom Zanussi, Masami Hiramatsu, Christoph Hellwig,
	Jiaying Zhang, Steven Rostedt


On Tue, 10 Mar 2009, KOSAKI Motohiro wrote:

> Hi
> 
> I have few comment.
> 
> 
> > diff --git a/kernel/trace/trace_event_types.h b/kernel/trace/trace_event_types.h
> > index d94179a..5cca4c9 100644
> > --- a/kernel/trace/trace_event_types.h
> > +++ b/kernel/trace/trace_event_types.h
> > @@ -106,9 +106,10 @@ TRACE_EVENT_FORMAT(print, TRACE_PRINT, print_entry, ignore,
> >  	TRACE_STRUCT(
> >  		TRACE_FIELD(unsigned long, ip, ip)
> >  		TRACE_FIELD(unsigned int, depth, depth)
> > +		TRACE_FIELD(char *, fmt, fmt)
> >  		TRACE_FIELD_ZERO_CHAR(buf)
> >  	),
> > -	TP_RAW_FMT("%08lx (%d) %s")
> > +	TP_RAW_FMT("%08lx (%d) fmt:%p %s")
> >  );
> 
> I'm not sure about what mean /sys/kernel/debug/tracing/events/ftrace/print/format..
> 
> FWIW, I think the internal representation of trace_printk() is
> 
> struct print_entry {
>         struct trace_entry      ent;
>         unsigned long           ip;
>         int                     depth;
>         const char              *fmt;
>         u32                     buf[];
> };
> 
> then, buf doesn't gurantee NUL-termination, right?

Right but the record has a size value, and a buf[] means that that record
will take up the rest of the record.

The trace_printk is special since it is now a binary format. I'm going
to export the pointers and fmts next. That way a binary reader can see
what the fmt maps to.

> 
> 
> > @@ -665,21 +534,6 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
> >  				   "'%s/enable' entry\n", call->name);
> >  	}
> >  
> > -	/* Only let type be writable, if we can change it */
> > -	entry = debugfs_create_file("type",
> > -				    call->raw_init ? 0644 : 0444,
> > -				    call->dir, call,
> > -				    &ftrace_type_fops);
> > -	if (!entry)
> > -		pr_warning("Could not create debugfs "
> > -			   "'%s/type' entry\n", call->name);
> > -
> > -	entry = debugfs_create_file("available_types", 0444, call->dir, call,
> > -				    &ftrace_available_types_fops);
> > -	if (!entry)
> > -		pr_warning("Could not create debugfs "
> > -			   "'%s/available_types' entry\n", call->name);
> > -
> >  	/* A trace may not want to export its format */
> >  	if (!call->show_format)
> >  		return 0;
> 
> this code mean, the output type of event use debug/tracing/trace_options now, right?

No. The above code is the fact that the new format no longer gives an 
option for a trace point to be a "pretty print printf" format or a "raw" 
format. The new TRACE_EVENT macro is powerful enough to not need the two 
options. You can now have your cake and eat it too.


> 
> 
> > @@ -704,13 +558,6 @@ static __init int event_trace_init(void)
> >  	if (!d_tracer)
> >  		return 0;
> >  
> > -	entry = debugfs_create_file("available_events", 0444, d_tracer,
> > -				    (void *)&show_event_seq_ops,
> > -				    &ftrace_avail_fops);
> > -	if (!entry)
> > -		pr_warning("Could not create debugfs "
> > -			   "'available_events' entry\n");
> > -
> >  	entry = debugfs_create_file("set_event", 0644, d_tracer,
> >  				    (void *)&show_set_event_seq_ops,
> >  				    &ftrace_set_event_fops);
> 
> Why do you remove available_events file?

Arg! Good catch!  That was me getting too happy with the knife.
I'll add that back.

> 
> 
> > diff --git a/kernel/trace/trace_events_stage_2.h b/kernel/trace/trace_events_stage_2.h
> > index 8e2e0f5..d91bf4c 100644
> > --- a/kernel/trace/trace_events_stage_2.h
> > +++ b/kernel/trace/trace_events_stage_2.h
> > @@ -32,23 +32,14 @@
> >   * in binary.
> >   */
> >  
> > -#undef TRACE_STRUCT
> > -#define TRACE_STRUCT(args...) args
> > +#undef __entry
> > +#define __entry field
> >  
> > -#undef TRACE_FIELD
> > -#define TRACE_FIELD(type, item, assign) \
> > -	field->item,
> > +#undef TP_printk
> > +#define TP_printk(fmt, args...) fmt "\n", args
> >  
> > -#undef TRACE_FIELD_SPECIAL
> > -#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
> > -	field->item,
> > -
> > -
> > -#undef TP_RAW_FMT
> > -#define TP_RAW_FMT(args...)	args
> > -
> > -#undef TRACE_EVENT_FORMAT
> > -#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)	\
> > +#undef TRACE_EVENT
> > +#define TRACE_EVENT(call, proto, args, tstruct, print, assign)		\
> >  enum print_line_t							\
> >  ftrace_raw_output_##call(struct trace_iterator *iter, int flags)	\
> >  {									\
> > @@ -66,14 +57,76 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags)	\
> >  									\
> >  	field = (typeof(field))entry;					\
> >  									\
> > -	ret = trace_seq_printf(s, tpfmt "%s", tstruct "\n");		\
> > +	ret = trace_seq_printf(s, print);				\
> >  	if (!ret)							\
> >  		return TRACE_TYPE_PARTIAL_LINE;				\
> >  									\
> >  	return TRACE_TYPE_HANDLED;					\
> >  }
> 
> the header comment need the same chnge too.

I'll change it once more, but if I find that I need to maintain two 
versions, the comment and the header, I will simply cut out the entire 
comment.  I only did the comment because I thought it would be easier than 
reading the macros. Not sure it is worth the trouble.

Thanks for the review,

-- Steve

> 
> 
> >  #include <trace/trace_event_types.h>
> > diff --git a/kernel/trace/trace_events_stage_3.h b/kernel/trace/trace_events_stage_3.h
> > index 41b82b9..8e398d8 100644
> > --- a/kernel/trace/trace_events_stage_3.h
> > +++ b/kernel/trace/trace_events_stage_3.h
> > @@ -144,27 +144,15 @@ __attribute__((section("_ftrace_events"))) event_##call = {		\
> >  	.unregfunc		= ftrace_unreg_event_##call,		\
> >  }
> >  
> > -#undef TRACE_FIELD
> > -#define TRACE_FIELD(type, item, assign)\
> > -	entry->item = assign;
> > -
> > -#undef TRACE_FIELD
> > -#define TRACE_FIELD(type, item, assign)\
> > -	entry->item = assign;
> > -
> > -#undef TP_CMD
> > -#define TP_CMD(cmd...)	cmd
> > -
> > -#undef TRACE_ENTRY
> > -#define TRACE_ENTRY	entry
> > +#undef TRACE_EVENT_FORMAT
> > +#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, raw)	\
> > +	TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt))
> >  
> > -#undef TRACE_FIELD_SPECIAL
> > -#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
> > -	cmd;
> > +#undef __entry
> > +#define __entry entry
> >  
> > -#undef TRACE_EVENT_FORMAT
> > -#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)	\
> > -_TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt))		\
> > +#undef TRACE_EVENT
> > +#define TRACE_EVENT(call, proto, args, tstruct, print, assign)		\
> >  									\
> >  static struct ftrace_event_call event_##call;				\
> >  									\
> > @@ -185,7 +173,7 @@ static void ftrace_raw_event_##call(proto)				\
> >  		return;							\
> >  	entry	= ring_buffer_event_data(event);			\
> >  									\
> > -	tstruct;							\
> > +	assign;								\
> >  									\
> >  	trace_current_buffer_unlock_commit(event, irq_flags, pc);	\
> >  }									\
> 
> ditto
> 
> > @@ -226,10 +214,8 @@ __attribute__((__aligned__(4)))						\
> >  __attribute__((section("_ftrace_events"))) event_##call = {		\
> >  	.name 			= #call,				\
> >  	.system			= __stringify(TRACE_SYSTEM),		\
> > -	.regfunc		= ftrace_reg_event_##call,		\
> > -	.unregfunc		= ftrace_unreg_event_##call,		\
> >  	.raw_init		= ftrace_raw_init_event_##call,		\
> > -	.raw_reg		= ftrace_raw_reg_event_##call,		\
> > -	.raw_unreg		= ftrace_raw_unreg_event_##call,	\
> > +	.regfunc		= ftrace_raw_reg_event_##call,		\
> > +	.unregfunc		= ftrace_raw_unreg_event_##call,	\
> >  	.show_format		= ftrace_format_##call,			\
> >  }
> 
> ditto
> 
> 
> 
> 

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

* Re: [PATCH 3/7] tracing: use generic __stringify
  2009-03-10 11:21     ` Peter Zijlstra
@ 2009-03-10 15:48       ` Frédéric Weisbecker
  0 siblings, 0 replies; 25+ messages in thread
From: Frédéric Weisbecker @ 2009-03-10 15:48 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Steven Rostedt, linux-kernel, Ingo Molnar, Andrew Morton,
	Thomas Gleixner, Theodore Tso, Arnaldo Carvalho de Melo,
	H. Peter Anvin, Mathieu Desnoyers, Lai Jiangshan,
	Martin J. Bligh, Frank Ch. Eigler, KOSAKI Motohiro,
	Larry Woodman, Jason Baron, Tom Zanussi, Masami Hiramatsu,
	Christoph Hellwig, Jiaying Zhang, Steven Rostedt

2009/3/10 Peter Zijlstra <peterz@infradead.org>:
> On Tue, 2009-03-10 at 11:56 +0100, Frederic Weisbecker wrote:
>> On Tue, Mar 10, 2009 at 12:57:13AM -0400, Steven Rostedt wrote:
>
>> > This removes the custom made STR(x) macros in the tracer and uses
>> > the generic __stringify macro instead.
>
>> Why not simply use the # ?
>
>> > -#define __STR(x) #x
>> > -#define STR(x) __STR(x)
>
> #include <stdio.h>
>
> #define FOO bar
>
> #define __STR(x) #x
> #define STR(x) __STR(x)
>
> void main(void)
> {
>        printf("%s %s\n", __STR(FOO), STR(FOO));
> }
>
> $ gcc -o str str.c; ./str
> str.c: In function ‘main’:
> str.c:9: warning: return type of ‘main’ is not ‘int’
> FOO bar


Thank you both for the explanation.

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

* Re: [PATCH 2/7] tracing: replace TP<var> with TP_<var>
  2009-03-10  4:57 ` [PATCH 2/7] tracing: replace TP<var> with TP_<var> Steven Rostedt
@ 2009-03-17  7:58   ` Christoph Hellwig
  2009-03-17 15:30     ` Steven Rostedt
  0 siblings, 1 reply; 25+ messages in thread
From: Christoph Hellwig @ 2009-03-17  7:58 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Thomas Gleixner,
	Peter Zijlstra, Frederic Weisbecker, Theodore Tso,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Mathieu Desnoyers,
	Lai Jiangshan, Martin J. Bligh, Frank Ch. Eigler,
	KOSAKI Motohiro, Larry Woodman, Jason Baron, Tom Zanussi,
	Masami Hiramatsu, Christoph Hellwig, Jiaying Zhang,
	Steven Rostedt

On Tue, Mar 10, 2009 at 12:57:12AM -0400, Steven Rostedt wrote:
> From: Steven Rostedt <srostedt@redhat.com>
> 
> Impact: clean up
> 
> The macros TPPROTO, TPARGS, TPFMT, TPRAWFMT, and TPCMD all look a bit
> ugly. This patch adds an underscore to their names.

Honestly I think they still look ugly.

>  DECLARE_TRACE(subsys_eventname,
> -	TPPROTO(int firstarg, struct task_struct *p),
> -	TPARGS(firstarg, p));
> +	TP_PROTO(int firstarg, struct task_struct *p),
> +	TP_ARGS(firstarg, p));

Compare that to a

DECLARE_TRACE(subsys_eventname,
	trace_proto(int firstarg, struct task_struct *p),
	trace_args(firstarg, p));

or even when you insist on UPPERCASE:

DECLARE_TRACE(subsys_eventname,
	TRACE_PROTO(int firstarg, struct task_struct *p),
	TRACE_ARGS(firstarg, p));



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

* Re: [PATCH 4/7] tracing: new format for specialized trace points
  2009-03-10  4:57 ` [PATCH 4/7] tracing: new format for specialized trace points Steven Rostedt
  2009-03-10  5:50   ` KOSAKI Motohiro
  2009-03-10  9:54   ` KOSAKI Motohiro
@ 2009-03-17  8:08   ` Christoph Hellwig
  2009-03-17 15:41     ` Steven Rostedt
  2 siblings, 1 reply; 25+ messages in thread
From: Christoph Hellwig @ 2009-03-17  8:08 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Thomas Gleixner,
	Peter Zijlstra, Frederic Weisbecker, Theodore Tso,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Mathieu Desnoyers,
	Lai Jiangshan, Martin J. Bligh, Frank Ch. Eigler,
	KOSAKI Motohiro, Larry Woodman, Jason Baron, Tom Zanussi,
	Masami Hiramatsu, Christoph Hellwig, Jiaying Zhang,
	Steven Rostedt

On Tue, Mar 10, 2009 at 12:57:14AM -0400, Steven Rostedt wrote:
> Here's the example. The only updated macro in this patch is the
> sched_switch trace point.

Note that we shouldn't keep two variants around long-term, that's
just going to cause confusion.

> The old method looked like this:
> 
>  TRACE_EVENT_FORMAT(sched_switch,
>         TP_PROTO(struct rq *rq, struct task_struct *prev,
>                 struct task_struct *next),
>         TP_ARGS(rq, prev, next),
>         TP_FMT("task %s:%d ==> %s:%d",
>               prev->comm, prev->pid, next->comm, next->pid),
>         TRACE_STRUCT(
>                 TRACE_FIELD(pid_t, prev_pid, prev->pid)
>                 TRACE_FIELD(int, prev_prio, prev->prio)
>                 TRACE_FIELD_SPECIAL(char next_comm[TASK_COMM_LEN],
>                                     next_comm,
>                                     TP_CMD(memcpy(TRACE_ENTRY->next_comm,
>                                                  next->comm,
>                                                  TASK_COMM_LEN)))
>                 TRACE_FIELD(pid_t, next_pid, next->pid)
>                 TRACE_FIELD(int, next_prio, next->prio)
>         ),
>         TP_RAW_FMT("prev %d:%d ==> next %s:%d:%d")
>         );
> 
> The above method is hard to read and requires two format fields.
> 
> The new method:
> 
>  /*
>   * Tracepoint for task switches, performed by the scheduler:
>   *
>   * (NOTE: the 'rq' argument is not used by generic trace events,
>   *        but used by the latency tracer plugin. )
>   */
>  TRACE_EVENT(sched_switch,
> 
> 	TP_PROTO(struct rq *rq, struct task_struct *prev,
> 		 struct task_struct *next),
> 
> 	TP_ARGS(rq, prev, next),
> 
> 	TP_STRUCT__entry(
> 		__array(	char,	prev_comm,	TASK_COMM_LEN	)
> 		__field(	pid_t,	prev_pid			)
> 		__field(	int,	prev_prio			)
> 		__array(	char,	next_comm,	TASK_COMM_LEN	)
> 		__field(	pid_t,	next_pid			)
> 		__field(	int,	next_prio			)
> 	),
> 
> 	TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
> 		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
> 		__entry->next_comm, __entry->next_pid, __entry->next_prio),
> 
> 	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;
> 	)
>  );

While the idea behing it seems like an improvement to me, the
implementation feel actually worse than the old one too me.  I would
expect this to look more like:

struct trace_sched_switch {
	char	prev_comm[TASK_COMM_LEN],
	pid_t	prev_pid,
	int	prev_prio,
	char	next_comm[TASK_COMM_LEN],
	pid_t	next_pid,
	int	next_prio,
}

static void trace_sched_assign(struct trace_sched_switch *dst, struct rq *rq,
		struct task_struct *prev, struct task_struct *next)
{
	memcpy(dst->next_comm, next->comm, TASK_COMM_LEN);
	dst->prev_pid	= prev->pid;
	dst->prev_prio	= prev->prio;
	memcpy(dst->prev_comm, prev->comm, TASK_COMM_LEN);
	dst->next_pid	= next->pid;
	dst->next_prio	= next->prio;
};


TRACE_EVENT(sched_switch,
	trace_proto(struct rq *rq, struct task_struct *prev,
 		    struct task_struct *next),
	trace_args(rq, prev, next),
	trace_struct(struct trace_sched_switch),
	trace_assign(trace_sched_assign);

	trace_pretty_print("task %s:%d [%d] ==> %s:%d [%d]",
		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
		__entry->next_comm, __entry->next_pid, __entry->next_prio),
);


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

* Re: [PATCH 7/7] tracing: remove obsolete TRACE_EVENT_FORMAT macro
  2009-03-10  4:57 ` [PATCH 7/7] tracing: remove obsolete TRACE_EVENT_FORMAT macro Steven Rostedt
@ 2009-03-17  8:08   ` Christoph Hellwig
  0 siblings, 0 replies; 25+ messages in thread
From: Christoph Hellwig @ 2009-03-17  8:08 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Thomas Gleixner,
	Peter Zijlstra, Frederic Weisbecker, Theodore Tso,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Mathieu Desnoyers,
	Lai Jiangshan, Martin J. Bligh, Frank Ch. Eigler,
	KOSAKI Motohiro, Larry Woodman, Jason Baron, Tom Zanussi,
	Masami Hiramatsu, Christoph Hellwig, Jiaying Zhang,
	Steven Rostedt

Ah, the old one is gone here, ok..


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

* Re: [PATCH 2/7] tracing: replace TP<var> with TP_<var>
  2009-03-17  7:58   ` Christoph Hellwig
@ 2009-03-17 15:30     ` Steven Rostedt
  0 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2009-03-17 15:30 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Thomas Gleixner,
	Peter Zijlstra, Frederic Weisbecker, Theodore Tso,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Mathieu Desnoyers,
	Lai Jiangshan, Martin J. Bligh, Frank Ch. Eigler,
	KOSAKI Motohiro, Larry Woodman, Jason Baron, Tom Zanussi,
	Masami Hiramatsu, Jiaying Zhang, Steven Rostedt


On Tue, 17 Mar 2009, Christoph Hellwig wrote:

> On Tue, Mar 10, 2009 at 12:57:12AM -0400, Steven Rostedt wrote:
> > From: Steven Rostedt <srostedt@redhat.com>
> > 
> > Impact: clean up
> > 
> > The macros TPPROTO, TPARGS, TPFMT, TPRAWFMT, and TPCMD all look a bit
> > ugly. This patch adds an underscore to their names.
> 
> Honestly I think they still look ugly.
> 
> >  DECLARE_TRACE(subsys_eventname,
> > -	TPPROTO(int firstarg, struct task_struct *p),
> > -	TPARGS(firstarg, p));
> > +	TP_PROTO(int firstarg, struct task_struct *p),
> > +	TP_ARGS(firstarg, p));
> 
> Compare that to a
> 
> DECLARE_TRACE(subsys_eventname,
> 	trace_proto(int firstarg, struct task_struct *p),
> 	trace_args(firstarg, p));
> 
> or even when you insist on UPPERCASE:
> 
> DECLARE_TRACE(subsys_eventname,
> 	TRACE_PROTO(int firstarg, struct task_struct *p),
> 	TRACE_ARGS(firstarg, p));

I have no attachement to the name. I can switch it to TRACE_PROTO etc.

Thanks,

-- Steve


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

* Re: [PATCH 4/7] tracing: new format for specialized trace points
  2009-03-17  8:08   ` Christoph Hellwig
@ 2009-03-17 15:41     ` Steven Rostedt
  0 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2009-03-17 15:41 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Thomas Gleixner,
	Peter Zijlstra, Frederic Weisbecker, Theodore Tso,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Mathieu Desnoyers,
	Lai Jiangshan, Martin J. Bligh, Frank Ch. Eigler,
	KOSAKI Motohiro, Larry Woodman, Jason Baron, Tom Zanussi,
	Masami Hiramatsu, Jiaying Zhang, Steven Rostedt


On Tue, 17 Mar 2009, Christoph Hellwig wrote:

> On Tue, Mar 10, 2009 at 12:57:14AM -0400, Steven Rostedt wrote:
> > Here's the example. The only updated macro in this patch is the
> > sched_switch trace point.
> 
> Note that we shouldn't keep two variants around long-term, that's
> just going to cause confusion.
> 
> > The old method looked like this:
> > 
> >  TRACE_EVENT_FORMAT(sched_switch,
> >         TP_PROTO(struct rq *rq, struct task_struct *prev,
> >                 struct task_struct *next),
> >         TP_ARGS(rq, prev, next),
> >         TP_FMT("task %s:%d ==> %s:%d",
> >               prev->comm, prev->pid, next->comm, next->pid),
> >         TRACE_STRUCT(
> >                 TRACE_FIELD(pid_t, prev_pid, prev->pid)
> >                 TRACE_FIELD(int, prev_prio, prev->prio)
> >                 TRACE_FIELD_SPECIAL(char next_comm[TASK_COMM_LEN],
> >                                     next_comm,
> >                                     TP_CMD(memcpy(TRACE_ENTRY->next_comm,
> >                                                  next->comm,
> >                                                  TASK_COMM_LEN)))
> >                 TRACE_FIELD(pid_t, next_pid, next->pid)
> >                 TRACE_FIELD(int, next_prio, next->prio)
> >         ),
> >         TP_RAW_FMT("prev %d:%d ==> next %s:%d:%d")
> >         );
> > 
> > The above method is hard to read and requires two format fields.
> > 
> > The new method:
> > 
> >  /*
> >   * Tracepoint for task switches, performed by the scheduler:
> >   *
> >   * (NOTE: the 'rq' argument is not used by generic trace events,
> >   *        but used by the latency tracer plugin. )
> >   */
> >  TRACE_EVENT(sched_switch,
> > 
> > 	TP_PROTO(struct rq *rq, struct task_struct *prev,
> > 		 struct task_struct *next),
> > 
> > 	TP_ARGS(rq, prev, next),
> > 
> > 	TP_STRUCT__entry(
> > 		__array(	char,	prev_comm,	TASK_COMM_LEN	)
> > 		__field(	pid_t,	prev_pid			)
> > 		__field(	int,	prev_prio			)
> > 		__array(	char,	next_comm,	TASK_COMM_LEN	)
> > 		__field(	pid_t,	next_pid			)
> > 		__field(	int,	next_prio			)
> > 	),
> > 
> > 	TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
> > 		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
> > 		__entry->next_comm, __entry->next_pid, __entry->next_prio),
> > 
> > 	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;
> > 	)
> >  );
> 
> While the idea behing it seems like an improvement to me, the
> implementation feel actually worse than the old one too me.  I would
> expect this to look more like:
> 
> struct trace_sched_switch {
> 	char	prev_comm[TASK_COMM_LEN],
> 	pid_t	prev_pid,
> 	int	prev_prio,
> 	char	next_comm[TASK_COMM_LEN],
> 	pid_t	next_pid,
> 	int	next_prio,
> }

We would love to do the above. The problem is that we also need a way
to automatically export the fields offset/size to userspace. Thus we use
the "__field()" and "__array()" macros to do this for us. Otherwise, we 
need to do that manually.


> 
> static void trace_sched_assign(struct trace_sched_switch *dst, struct rq *rq,
> 		struct task_struct *prev, struct task_struct *next)
> {
> 	memcpy(dst->next_comm, next->comm, TASK_COMM_LEN);
> 	dst->prev_pid	= prev->pid;
> 	dst->prev_prio	= prev->prio;
> 	memcpy(dst->prev_comm, prev->comm, TASK_COMM_LEN);
> 	dst->next_pid	= next->pid;
> 	dst->next_prio	= next->prio;
> };

This we could take out of the macro and make a function.

-- Steve

> 
> 
> TRACE_EVENT(sched_switch,
> 	trace_proto(struct rq *rq, struct task_struct *prev,
>  		    struct task_struct *next),
> 	trace_args(rq, prev, next),
> 	trace_struct(struct trace_sched_switch),
> 	trace_assign(trace_sched_assign);
> 
> 	trace_pretty_print("task %s:%d [%d] ==> %s:%d [%d]",
> 		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
> 		__entry->next_comm, __entry->next_pid, __entry->next_prio),
> );
> 
> 

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

end of thread, other threads:[~2009-03-17 15:41 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-10  4:57 [PATCH 0/7] [GIT PULL] enhancements for tracing in tip Steven Rostedt
2009-03-10  4:57 ` [PATCH 1/7] tracing: typecast sizeof and offsetof to unsigned int Steven Rostedt
2009-03-10  5:20   ` Andrew Morton
2009-03-10 13:39     ` Steven Rostedt
2009-03-10  4:57 ` [PATCH 2/7] tracing: replace TP<var> with TP_<var> Steven Rostedt
2009-03-17  7:58   ` Christoph Hellwig
2009-03-17 15:30     ` Steven Rostedt
2009-03-10  4:57 ` [PATCH 3/7] tracing: use generic __stringify Steven Rostedt
2009-03-10 10:56   ` Frederic Weisbecker
2009-03-10 11:18     ` KOSAKI Motohiro
2009-03-10 11:21     ` Peter Zijlstra
2009-03-10 15:48       ` Frédéric Weisbecker
2009-03-10  4:57 ` [PATCH 4/7] tracing: new format for specialized trace points Steven Rostedt
2009-03-10  5:50   ` KOSAKI Motohiro
2009-03-10  8:54     ` Ingo Molnar
2009-03-10 13:45       ` Steven Rostedt
2009-03-10  9:54   ` KOSAKI Motohiro
2009-03-10 13:55     ` Steven Rostedt
2009-03-17  8:08   ` Christoph Hellwig
2009-03-17 15:41     ` Steven Rostedt
2009-03-10  4:57 ` [PATCH 5/7] tracing: convert the sched trace points to the TRACE_EVENT macros Steven Rostedt
2009-03-10  4:57 ` [PATCH 6/7] tracing: convert irq trace points to new macros Steven Rostedt
2009-03-10  4:57 ` [PATCH 7/7] tracing: remove obsolete TRACE_EVENT_FORMAT macro Steven Rostedt
2009-03-17  8:08   ` Christoph Hellwig
2009-03-10  8:59 ` [PATCH 0/7] [GIT PULL] enhancements for tracing in tip Ingo Molnar

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.