All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE
@ 2009-11-26  7:02 Li Zefan
  2009-11-26  7:03 ` [PATCH 1/9] tracing: Convert module refcnt events to DEFINE_EVENT Li Zefan
                   ` (9 more replies)
  0 siblings, 10 replies; 43+ messages in thread
From: Li Zefan @ 2009-11-26  7:02 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Steven Rostedt, Frederic Weisbecker, LKML

Convert some trace events defined in include/trace/events/*.h
to DEFINE_TRACE and DEFINE_TRACE_PRINT.

This reduces hundreds of code lines, and shrinks the size
of object files.

Tested by comparing the formats of each trace_event before
and after patching.

This patchset is based on -tip tree, but I've conformed the
ext4 bits won't conflict with ext4 tree.

---
 include/trace/events/block.h     |  202 ++++++++------------------------------
 include/trace/events/ext4.h      |  129 +++++++------------------
 include/trace/events/irq.h       |   46 ++++-----
 include/trace/events/jbd2.h      |   63 ++----------
 include/trace/events/kmem.h      |  130 ++++++++-----------------
 include/trace/events/module.h    |   22 ++---
 include/trace/events/power.h     |   36 +++----
 include/trace/events/sched.h     |   18 +---
 include/trace/events/workqueue.h |   22 ++---
 mm/page_alloc.c                  |    4 +-
 mm/util.c                        |    3 -
 11 files changed, 187 insertions(+), 488 deletions(-)


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

* [PATCH 1/9] tracing: Convert module refcnt events to DEFINE_EVENT
  2009-11-26  7:02 [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Li Zefan
@ 2009-11-26  7:03 ` Li Zefan
  2009-11-26  8:42   ` [tip:perf/core] " tip-bot for Li Zefan
  2009-11-26  7:04 ` [PATCH 2/9] tracing: Convert some kmem " Li Zefan
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 43+ messages in thread
From: Li Zefan @ 2009-11-26  7:03 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Rusty Russell, Steven Rostedt, Frederic Weisbecker, LKML

Use TRACE_EVENT_TEMPLATE to remove duplicate code:

   text    data     bss     dec     hex filename
  29854    1980     128   31962    7cda kernel/module.o.old
  28750    1980     128   30858    788a kernel/module.o

Two events are converted:

  module_refcnt: module_get, module_put

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/trace/events/module.h |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/include/trace/events/module.h b/include/trace/events/module.h
index 84160fb..32c28db 100644
--- a/include/trace/events/module.h
+++ b/include/trace/events/module.h
@@ -51,7 +51,7 @@ TRACE_EVENT(module_free,
 	TP_printk("%s", __get_str(name))
 );
 
-TRACE_EVENT(module_get,
+TRACE_EVENT_TEMPLATE(module_refcnt,
 
 	TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
 
@@ -73,26 +73,18 @@ TRACE_EVENT(module_get,
 		  __get_str(name), (void *)__entry->ip, __entry->refcnt)
 );
 
-TRACE_EVENT(module_put,
+DEFINE_EVENT(module_refcnt, module_get,
 
 	TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
 
-	TP_ARGS(mod, ip, refcnt),
+	TP_ARGS(mod, ip, refcnt)
+);
 
-	TP_STRUCT__entry(
-		__field(	unsigned long,	ip		)
-		__field(	int,		refcnt		)
-		__string(	name,		mod->name	)
-	),
+DEFINE_EVENT(module_refcnt, module_put,
 
-	TP_fast_assign(
-		__entry->ip	= ip;
-		__entry->refcnt	= refcnt;
-		__assign_str(name, mod->name);
-	),
+	TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
 
-	TP_printk("%s call_site=%pf refcnt=%d",
-		  __get_str(name), (void *)__entry->ip, __entry->refcnt)
+	TP_ARGS(mod, ip, refcnt)
 );
 
 TRACE_EVENT(module_request,
-- 
1.6.3



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

* [PATCH 2/9] tracing: Convert some kmem events to DEFINE_EVENT
  2009-11-26  7:02 [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Li Zefan
  2009-11-26  7:03 ` [PATCH 1/9] tracing: Convert module refcnt events to DEFINE_EVENT Li Zefan
@ 2009-11-26  7:04 ` Li Zefan
  2009-11-26  7:24   ` Pekka Enberg
                     ` (3 more replies)
  2009-11-26  7:04 ` [PATCH 3/9] tracing: Convert softirq events to DEFINE_EVENT Li Zefan
                   ` (7 subsequent siblings)
  9 siblings, 4 replies; 43+ messages in thread
From: Li Zefan @ 2009-11-26  7:04 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Steven Rostedt, Frederic Weisbecker, LKML, Pekka Enberg, Mel Gorman

Use TRACE_EVENT_TEMPLATE to remove duplicate code:

   text    data     bss     dec     hex filename
 333987   69800   27228  431015   693a7 mm/built-in.o.old
 330030   69800   27228  427058   68432 mm/built-in.o

8 events are converted:

  kmem_alloc: kmalloc, kmem_cache_alloc
  kmem_alloc_node: kmalloc_node, kmem_cache_alloc_node
  kmem_free: kfree, kmem_cache_free
  mm_page: mm_page_alloc_zone_locked, mm_page_pcpu_drain

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/trace/events/kmem.h |  130 +++++++++++++-----------------------------
 mm/page_alloc.c             |    4 +-
 mm/util.c                   |    3 -
 3 files changed, 43 insertions(+), 94 deletions(-)

diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index eaf46bd..af3e2ec 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -44,7 +44,7 @@
 	{(unsigned long)__GFP_MOVABLE,		"GFP_MOVABLE"}		\
 	) : "GFP_NOWAIT"
 
-TRACE_EVENT(kmalloc,
+TRACE_EVENT_TEMPLATE(kmem_alloc,
 
 	TP_PROTO(unsigned long call_site,
 		 const void *ptr,
@@ -78,41 +78,23 @@ TRACE_EVENT(kmalloc,
 		show_gfp_flags(__entry->gfp_flags))
 );
 
-TRACE_EVENT(kmem_cache_alloc,
+DEFINE_EVENT(kmem_alloc, kmalloc,
 
-	TP_PROTO(unsigned long call_site,
-		 const void *ptr,
-		 size_t bytes_req,
-		 size_t bytes_alloc,
-		 gfp_t gfp_flags),
+	TP_PROTO(unsigned long call_site, const void *ptr,
+		 size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
 
-	TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags),
+	TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
+);
 
-	TP_STRUCT__entry(
-		__field(	unsigned long,	call_site	)
-		__field(	const void *,	ptr		)
-		__field(	size_t,		bytes_req	)
-		__field(	size_t,		bytes_alloc	)
-		__field(	gfp_t,		gfp_flags	)
-	),
+DEFINE_EVENT(kmem_alloc, kmem_cache_alloc,
 
-	TP_fast_assign(
-		__entry->call_site	= call_site;
-		__entry->ptr		= ptr;
-		__entry->bytes_req	= bytes_req;
-		__entry->bytes_alloc	= bytes_alloc;
-		__entry->gfp_flags	= gfp_flags;
-	),
+	TP_PROTO(unsigned long call_site, const void *ptr,
+		 size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
 
-	TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
-		__entry->call_site,
-		__entry->ptr,
-		__entry->bytes_req,
-		__entry->bytes_alloc,
-		show_gfp_flags(__entry->gfp_flags))
+	TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
 );
 
-TRACE_EVENT(kmalloc_node,
+TRACE_EVENT_TEMPLATE(kmem_alloc_node,
 
 	TP_PROTO(unsigned long call_site,
 		 const void *ptr,
@@ -150,45 +132,25 @@ TRACE_EVENT(kmalloc_node,
 		__entry->node)
 );
 
-TRACE_EVENT(kmem_cache_alloc_node,
+DEFINE_EVENT(kmem_alloc_node, kmalloc_node,
 
-	TP_PROTO(unsigned long call_site,
-		 const void *ptr,
-		 size_t bytes_req,
-		 size_t bytes_alloc,
-		 gfp_t gfp_flags,
-		 int node),
+	TP_PROTO(unsigned long call_site, const void *ptr,
+		 size_t bytes_req, size_t bytes_alloc,
+		 gfp_t gfp_flags, int node),
 
-	TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node),
+	TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
+);
 
-	TP_STRUCT__entry(
-		__field(	unsigned long,	call_site	)
-		__field(	const void *,	ptr		)
-		__field(	size_t,		bytes_req	)
-		__field(	size_t,		bytes_alloc	)
-		__field(	gfp_t,		gfp_flags	)
-		__field(	int,		node		)
-	),
+DEFINE_EVENT(kmem_alloc_node, kmem_cache_alloc_node,
 
-	TP_fast_assign(
-		__entry->call_site	= call_site;
-		__entry->ptr		= ptr;
-		__entry->bytes_req	= bytes_req;
-		__entry->bytes_alloc	= bytes_alloc;
-		__entry->gfp_flags	= gfp_flags;
-		__entry->node		= node;
-	),
+	TP_PROTO(unsigned long call_site, const void *ptr,
+		 size_t bytes_req, size_t bytes_alloc,
+		 gfp_t gfp_flags, int node),
 
-	TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
-		__entry->call_site,
-		__entry->ptr,
-		__entry->bytes_req,
-		__entry->bytes_alloc,
-		show_gfp_flags(__entry->gfp_flags),
-		__entry->node)
+	TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
 );
 
-TRACE_EVENT(kfree,
+TRACE_EVENT_TEMPLATE(kmem_free,
 
 	TP_PROTO(unsigned long call_site, const void *ptr),
 
@@ -207,23 +169,18 @@ TRACE_EVENT(kfree,
 	TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
 );
 
-TRACE_EVENT(kmem_cache_free,
+DEFINE_EVENT(kmem_free, kfree,
 
 	TP_PROTO(unsigned long call_site, const void *ptr),
 
-	TP_ARGS(call_site, ptr),
+	TP_ARGS(call_site, ptr)
+);
 
-	TP_STRUCT__entry(
-		__field(	unsigned long,	call_site	)
-		__field(	const void *,	ptr		)
-	),
+DEFINE_EVENT(kmem_free, kmem_cache_free,
 
-	TP_fast_assign(
-		__entry->call_site	= call_site;
-		__entry->ptr		= ptr;
-	),
+	TP_PROTO(unsigned long call_site, const void *ptr),
 
-	TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
+	TP_ARGS(call_site, ptr)
 );
 
 TRACE_EVENT(mm_page_free_direct,
@@ -299,7 +256,7 @@ TRACE_EVENT(mm_page_alloc,
 		show_gfp_flags(__entry->gfp_flags))
 );
 
-TRACE_EVENT(mm_page_alloc_zone_locked,
+TRACE_EVENT_TEMPLATE(mm_page,
 
 	TP_PROTO(struct page *page, unsigned int order, int migratetype),
 
@@ -325,29 +282,22 @@ TRACE_EVENT(mm_page_alloc_zone_locked,
 		__entry->order == 0)
 );
 
-TRACE_EVENT(mm_page_pcpu_drain,
+DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked,
 
-	TP_PROTO(struct page *page, int order, int migratetype),
+	TP_PROTO(struct page *page, unsigned int order, int migratetype),
 
-	TP_ARGS(page, order, migratetype),
+	TP_ARGS(page, order, migratetype)
+);
 
-	TP_STRUCT__entry(
-		__field(	struct page *,	page		)
-		__field(	int,		order		)
-		__field(	int,		migratetype	)
-	),
+DEFINE_EVENT_PRINT(mm_page, mm_page_pcpu_drain,
 
-	TP_fast_assign(
-		__entry->page		= page;
-		__entry->order		= order;
-		__entry->migratetype	= migratetype;
-	),
+	TP_PROTO(struct page *page, unsigned int order, int migratetype),
+
+	TP_ARGS(page, order, migratetype),
 
 	TP_printk("page=%p pfn=%lu order=%d migratetype=%d",
-		__entry->page,
-		page_to_pfn(__entry->page),
-		__entry->order,
-		__entry->migratetype)
+		__entry->page, page_to_pfn(__entry->page),
+		__entry->order, __entry->migratetype)
 );
 
 TRACE_EVENT(mm_page_alloc_extfrag,
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2bc2ac6..bdb22f5 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -48,12 +48,14 @@
 #include <linux/page_cgroup.h>
 #include <linux/debugobjects.h>
 #include <linux/kmemleak.h>
-#include <trace/events/kmem.h>
 
 #include <asm/tlbflush.h>
 #include <asm/div64.h>
 #include "internal.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/kmem.h>
+
 /*
  * Array of node states.
  */
diff --git a/mm/util.c b/mm/util.c
index 7c35ad9..15d1975 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -6,9 +6,6 @@
 #include <linux/sched.h>
 #include <asm/uaccess.h>
 
-#define CREATE_TRACE_POINTS
-#include <trace/events/kmem.h>
-
 /**
  * kstrdup - allocate space for and copy an existing string
  * @s: the string to duplicate
-- 
1.6.3



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

* [PATCH 3/9] tracing: Convert softirq events to DEFINE_EVENT
  2009-11-26  7:02 [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Li Zefan
  2009-11-26  7:03 ` [PATCH 1/9] tracing: Convert module refcnt events to DEFINE_EVENT Li Zefan
  2009-11-26  7:04 ` [PATCH 2/9] tracing: Convert some kmem " Li Zefan
@ 2009-11-26  7:04 ` Li Zefan
  2009-11-26  8:43   ` [tip:perf/core] " tip-bot for Li Zefan
  2009-11-26  7:05 ` [PATCH 4/9] tracing: Convert some workqueue " Li Zefan
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 43+ messages in thread
From: Li Zefan @ 2009-11-26  7:04 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Steven Rostedt, Frederic Weisbecker, LKML

Use TRACE_EVENT_TEMPLATE to remove duplicate code:

   text    data     bss     dec     hex filename
  12781     952      36   13769    35c9 kernel/softirq.o.old
  11981     952      32   12965    32a5 kernel/softirq.o

Two events are converted:

  softirq: softirq_entry, softirq_exit

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/trace/events/irq.h |   46 ++++++++++++++++++++-----------------------
 1 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
index dcfcd44..f8a94d7 100644
--- a/include/trace/events/irq.h
+++ b/include/trace/events/irq.h
@@ -82,18 +82,7 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
-/**
- * softirq_entry - called immediately before the softirq handler
- * @h: pointer to struct softirq_action
- * @vec: pointer to first struct softirq_action in softirq_vec array
- *
- * The @h parameter, contains a pointer to the struct softirq_action
- * which has a pointer to the action handler that is called. By subtracting
- * the @vec pointer from the @h pointer, we can determine the softirq
- * number. Also, when used in combination with the softirq_exit tracepoint
- * we can determine the softirq latency.
- */
-TRACE_EVENT(softirq_entry,
+TRACE_EVENT_TEMPLATE(softirq,
 
 	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
 
@@ -112,6 +101,24 @@ TRACE_EVENT(softirq_entry,
 );
 
 /**
+ * softirq_entry - called immediately before the softirq handler
+ * @h: pointer to struct softirq_action
+ * @vec: pointer to first struct softirq_action in softirq_vec array
+ *
+ * The @h parameter, contains a pointer to the struct softirq_action
+ * which has a pointer to the action handler that is called. By subtracting
+ * the @vec pointer from the @h pointer, we can determine the softirq
+ * number. Also, when used in combination with the softirq_exit tracepoint
+ * we can determine the softirq latency.
+ */
+DEFINE_EVENT(softirq, softirq_entry,
+
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+	TP_ARGS(h, vec)
+);
+
+/**
  * softirq_exit - called immediately after the softirq handler returns
  * @h: pointer to struct softirq_action
  * @vec: pointer to first struct softirq_action in softirq_vec array
@@ -122,22 +129,11 @@ TRACE_EVENT(softirq_entry,
  * combination with the softirq_entry tracepoint we can determine the softirq
  * latency.
  */
-TRACE_EVENT(softirq_exit,
+DEFINE_EVENT(softirq, softirq_exit,
 
 	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
 
-	TP_ARGS(h, vec),
-
-	TP_STRUCT__entry(
-		__field(	int,	vec			)
-	),
-
-	TP_fast_assign(
-		__entry->vec = (int)(h - vec);
-	),
-
-	TP_printk("vec=%d [action=%s]", __entry->vec,
-		  show_softirq_name(__entry->vec))
+	TP_ARGS(h, vec)
 );
 
 #endif /*  _TRACE_IRQ_H */
-- 
1.6.3


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

* [PATCH 4/9] tracing: Convert some workqueue events to DEFINE_EVENT
  2009-11-26  7:02 [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Li Zefan
                   ` (2 preceding siblings ...)
  2009-11-26  7:04 ` [PATCH 3/9] tracing: Convert softirq events to DEFINE_EVENT Li Zefan
@ 2009-11-26  7:05 ` Li Zefan
  2009-11-26  8:43   ` [tip:perf/core] " tip-bot for Li Zefan
  2009-11-26  7:05 ` [PATCH 5/9] tracing: Convert some power " Li Zefan
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 43+ messages in thread
From: Li Zefan @ 2009-11-26  7:05 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Steven Rostedt, Frederic Weisbecker, LKML

Use TRACE_EVENT_TEMPLATE to remove duplicate code:

   text    data     bss     dec     hex filename
  13171     800      72   14043    36db kernel/workqueue.o.old
  12243     800      68   13111    3337 kernel/workqueue.o

Two events are converted:

  workqueue: workqueue_insertion, workqueue_execution

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/trace/events/workqueue.h |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/include/trace/events/workqueue.h b/include/trace/events/workqueue.h
index e4612db..6da8d1b 100644
--- a/include/trace/events/workqueue.h
+++ b/include/trace/events/workqueue.h
@@ -8,7 +8,7 @@
 #include <linux/sched.h>
 #include <linux/tracepoint.h>
 
-TRACE_EVENT(workqueue_insertion,
+TRACE_EVENT_TEMPLATE(workqueue,
 
 	TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
 
@@ -30,26 +30,18 @@ TRACE_EVENT(workqueue_insertion,
 		__entry->thread_pid, __entry->func)
 );
 
-TRACE_EVENT(workqueue_execution,
+DEFINE_EVENT(workqueue, workqueue_insertion,
 
 	TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
 
-	TP_ARGS(wq_thread, work),
+	TP_ARGS(wq_thread, work)
+);
 
-	TP_STRUCT__entry(
-		__array(char,		thread_comm,	TASK_COMM_LEN)
-		__field(pid_t,		thread_pid)
-		__field(work_func_t,	func)
-	),
+DEFINE_EVENT(workqueue, workqueue_execution,
 
-	TP_fast_assign(
-		memcpy(__entry->thread_comm, wq_thread->comm, TASK_COMM_LEN);
-		__entry->thread_pid	= wq_thread->pid;
-		__entry->func		= work->func;
-	),
+	TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
 
-	TP_printk("thread=%s:%d func=%pf", __entry->thread_comm,
-		__entry->thread_pid, __entry->func)
+	TP_ARGS(wq_thread, work)
 );
 
 /* Trace the creation of one workqueue thread on a cpu */
-- 
1.6.3


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

* [PATCH 5/9] tracing: Convert some power events to DEFINE_EVENT
  2009-11-26  7:02 [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Li Zefan
                   ` (3 preceding siblings ...)
  2009-11-26  7:05 ` [PATCH 4/9] tracing: Convert some workqueue " Li Zefan
@ 2009-11-26  7:05 ` Li Zefan
  2009-11-26  8:43   ` [tip:perf/core] " tip-bot for Li Zefan
  2009-11-26  7:06 ` [PATCH 6/9] tracing: Convert some block " Li Zefan
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 43+ messages in thread
From: Li Zefan @ 2009-11-26  7:05 UTC (permalink / raw)
  To: Arjan van de Ven, Ingo Molnar; +Cc: Steven Rostedt, Frederic Weisbecker, LKML

Use TRACE_EVENT_TEMPLATE to remove duplicate code:

   text    data     bss     dec     hex filename
   4312     524      12    4848    12f0 kernel/trace/power-traces.o.old
   3455     524       8    3987     f93 kernel/trace/power-traces.o

Two events are converted:

  power: power_start, power_frequency

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/trace/events/power.h |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 9bb96e5..5cfa61a 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -16,7 +16,7 @@ enum {
 };
 #endif
 
-TRACE_EVENT(power_start,
+TRACE_EVENT_TEMPLATE(power,
 
 	TP_PROTO(unsigned int type, unsigned int state),
 
@@ -35,42 +35,36 @@ TRACE_EVENT(power_start,
 	TP_printk("type=%lu state=%lu", (unsigned long)__entry->type, (unsigned long)__entry->state)
 );
 
-TRACE_EVENT(power_end,
-
-	TP_PROTO(int dummy),
+DEFINE_EVENT(power, power_start,
 
-	TP_ARGS(dummy),
+	TP_PROTO(unsigned int type, unsigned int state),
 
-	TP_STRUCT__entry(
-		__field(	u64,		dummy		)
-	),
+	TP_ARGS(type, state)
+);
 
-	TP_fast_assign(
-		__entry->dummy = 0xffff;
-	),
+DEFINE_EVENT(power, power_frequency,
 
-	TP_printk("dummy=%lu", (unsigned long)__entry->dummy)
+	TP_PROTO(unsigned int type, unsigned int state),
 
+	TP_ARGS(type, state)
 );
 
+TRACE_EVENT(power_end,
 
-TRACE_EVENT(power_frequency,
-
-	TP_PROTO(unsigned int type, unsigned int state),
+	TP_PROTO(int dummy),
 
-	TP_ARGS(type, state),
+	TP_ARGS(dummy),
 
 	TP_STRUCT__entry(
-		__field(	u64,		type		)
-		__field(	u64,		state		)
+		__field(	u64,		dummy		)
 	),
 
 	TP_fast_assign(
-		__entry->type = type;
-		__entry->state = state;
+		__entry->dummy = 0xffff;
 	),
 
-	TP_printk("type=%lu state=%lu", (unsigned long)__entry->type, (unsigned long) __entry->state)
+	TP_printk("dummy=%lu", (unsigned long)__entry->dummy)
+
 );
 
 #endif /* _TRACE_POWER_H */
-- 
1.6.3



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

* [PATCH 6/9] tracing: Convert some block events to DEFINE_EVENT
  2009-11-26  7:02 [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Li Zefan
                   ` (4 preceding siblings ...)
  2009-11-26  7:05 ` [PATCH 5/9] tracing: Convert some power " Li Zefan
@ 2009-11-26  7:06 ` Li Zefan
  2009-11-26  8:36   ` Jens Axboe
  2009-11-26  8:43   ` [tip:perf/core] " tip-bot for Li Zefan
  2009-11-26  7:06 ` [PATCH 7/9] tracing: Convert some jbd2 " Li Zefan
                   ` (3 subsequent siblings)
  9 siblings, 2 replies; 43+ messages in thread
From: Li Zefan @ 2009-11-26  7:06 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Jens Axboe, Steven Rostedt, Frederic Weisbecker, LKML

use TRACE_EVENT_TEMPLATE to remove duplicate code:

   text    data     bss     dec     hex filename
  53570    3284     184   57038    dece block/blk-core.o.old
  43702    3284     144   47130    b81a block/blk-core.o

12 events are converted:

  block_rq: block_rq_insert, block_rq_issue
  block_rq_with_error: block_rq_{abort, requeue, complete}
  block_bio: block_bio_{backmerge, frontmerge, queue}
  block_get_rq: block_getrq, block_sleeprq
  block_unplug: block_unplug_timer, block_unplug_io

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/trace/events/block.h |  202 +++++++++---------------------------------
 1 files changed, 42 insertions(+), 160 deletions(-)

diff --git a/include/trace/events/block.h b/include/trace/events/block.h
index 00405b5..0dcb775 100644
--- a/include/trace/events/block.h
+++ b/include/trace/events/block.h
@@ -8,7 +8,7 @@
 #include <linux/blkdev.h>
 #include <linux/tracepoint.h>
 
-TRACE_EVENT(block_rq_abort,
+TRACE_EVENT_TEMPLATE(block_rq_with_error,
 
 	TP_PROTO(struct request_queue *q, struct request *rq),
 
@@ -40,41 +40,28 @@ TRACE_EVENT(block_rq_abort,
 		  __entry->nr_sector, __entry->errors)
 );
 
-TRACE_EVENT(block_rq_insert,
+DEFINE_EVENT(block_rq_with_error, block_rq_abort,
 
 	TP_PROTO(struct request_queue *q, struct request *rq),
 
-	TP_ARGS(q, rq),
+	TP_ARGS(q, rq)
+);
 
-	TP_STRUCT__entry(
-		__field(  dev_t,	dev			)
-		__field(  sector_t,	sector			)
-		__field(  unsigned int,	nr_sector		)
-		__field(  unsigned int,	bytes			)
-		__array(  char,		rwbs,	6		)
-		__array(  char,         comm,   TASK_COMM_LEN   )
-		__dynamic_array( char,	cmd,	blk_cmd_buf_len(rq)	)
-	),
+DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
 
-	TP_fast_assign(
-		__entry->dev	   = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
-		__entry->sector    = blk_pc_request(rq) ? 0 : blk_rq_pos(rq);
-		__entry->nr_sector = blk_pc_request(rq) ? 0 : blk_rq_sectors(rq);
-		__entry->bytes     = blk_pc_request(rq) ? blk_rq_bytes(rq) : 0;
+	TP_PROTO(struct request_queue *q, struct request *rq),
 
-		blk_fill_rwbs_rq(__entry->rwbs, rq);
-		blk_dump_cmd(__get_str(cmd), rq);
-		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
-	),
+	TP_ARGS(q, rq)
+);
 
-	TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
-		  MAJOR(__entry->dev), MINOR(__entry->dev),
-		  __entry->rwbs, __entry->bytes, __get_str(cmd),
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->comm)
+DEFINE_EVENT(block_rq_with_error, block_rq_complete,
+
+	TP_PROTO(struct request_queue *q, struct request *rq),
+
+	TP_ARGS(q, rq)
 );
 
-TRACE_EVENT(block_rq_issue,
+TRACE_EVENT_TEMPLATE(block_rq,
 
 	TP_PROTO(struct request_queue *q, struct request *rq),
 
@@ -86,7 +73,7 @@ TRACE_EVENT(block_rq_issue,
 		__field(  unsigned int,	nr_sector		)
 		__field(  unsigned int,	bytes			)
 		__array(  char,		rwbs,	6		)
-		__array(  char,		comm,   TASK_COMM_LEN   )
+		__array(  char,         comm,   TASK_COMM_LEN   )
 		__dynamic_array( char,	cmd,	blk_cmd_buf_len(rq)	)
 	),
 
@@ -108,68 +95,18 @@ TRACE_EVENT(block_rq_issue,
 		  __entry->nr_sector, __entry->comm)
 );
 
-TRACE_EVENT(block_rq_requeue,
+DEFINE_EVENT(block_rq, block_rq_insert,
 
 	TP_PROTO(struct request_queue *q, struct request *rq),
 
-	TP_ARGS(q, rq),
-
-	TP_STRUCT__entry(
-		__field(  dev_t,	dev			)
-		__field(  sector_t,	sector			)
-		__field(  unsigned int,	nr_sector		)
-		__field(  int,		errors			)
-		__array(  char,		rwbs,	6		)
-		__dynamic_array( char,	cmd,	blk_cmd_buf_len(rq)	)
-	),
-
-	TP_fast_assign(
-		__entry->dev	   = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
-		__entry->sector    = blk_pc_request(rq) ? 0 : blk_rq_pos(rq);
-		__entry->nr_sector = blk_pc_request(rq) ? 0 : blk_rq_sectors(rq);
-		__entry->errors	   = rq->errors;
-
-		blk_fill_rwbs_rq(__entry->rwbs, rq);
-		blk_dump_cmd(__get_str(cmd), rq);
-	),
-
-	TP_printk("%d,%d %s (%s) %llu + %u [%d]",
-		  MAJOR(__entry->dev), MINOR(__entry->dev),
-		  __entry->rwbs, __get_str(cmd),
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->errors)
+	TP_ARGS(q, rq)
 );
 
-TRACE_EVENT(block_rq_complete,
+DEFINE_EVENT(block_rq, block_rq_issue,
 
 	TP_PROTO(struct request_queue *q, struct request *rq),
 
-	TP_ARGS(q, rq),
-
-	TP_STRUCT__entry(
-		__field(  dev_t,	dev			)
-		__field(  sector_t,	sector			)
-		__field(  unsigned int,	nr_sector		)
-		__field(  int,		errors			)
-		__array(  char,		rwbs,	6		)
-		__dynamic_array( char,	cmd,	blk_cmd_buf_len(rq)	)
-	),
-
-	TP_fast_assign(
-		__entry->dev	   = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
-		__entry->sector    = blk_pc_request(rq) ? 0 : blk_rq_pos(rq);
-		__entry->nr_sector = blk_pc_request(rq) ? 0 : blk_rq_sectors(rq);
-		__entry->errors    = rq->errors;
-
-		blk_fill_rwbs_rq(__entry->rwbs, rq);
-		blk_dump_cmd(__get_str(cmd), rq);
-	),
-
-	TP_printk("%d,%d %s (%s) %llu + %u [%d]",
-		  MAJOR(__entry->dev), MINOR(__entry->dev),
-		  __entry->rwbs, __get_str(cmd),
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->errors)
+	TP_ARGS(q, rq)
 );
 
 TRACE_EVENT(block_bio_bounce,
@@ -228,7 +165,7 @@ TRACE_EVENT(block_bio_complete,
 		  __entry->nr_sector, __entry->error)
 );
 
-TRACE_EVENT(block_bio_backmerge,
+TRACE_EVENT_TEMPLATE(block_bio,
 
 	TP_PROTO(struct request_queue *q, struct bio *bio),
 
@@ -256,63 +193,28 @@ TRACE_EVENT(block_bio_backmerge,
 		  __entry->nr_sector, __entry->comm)
 );
 
-TRACE_EVENT(block_bio_frontmerge,
+DEFINE_EVENT(block_bio, block_bio_backmerge,
 
 	TP_PROTO(struct request_queue *q, struct bio *bio),
 
-	TP_ARGS(q, bio),
-
-	TP_STRUCT__entry(
-		__field( dev_t,		dev			)
-		__field( sector_t,	sector			)
-		__field( unsigned,	nr_sector		)
-		__array( char,		rwbs,	6		)
-		__array( char,		comm,	TASK_COMM_LEN	)
-	),
-
-	TP_fast_assign(
-		__entry->dev		= bio->bi_bdev->bd_dev;
-		__entry->sector		= bio->bi_sector;
-		__entry->nr_sector	= bio->bi_size >> 9;
-		blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
-		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
-	),
-
-	TP_printk("%d,%d %s %llu + %u [%s]",
-		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->comm)
+	TP_ARGS(q, bio)
 );
 
-TRACE_EVENT(block_bio_queue,
+DEFINE_EVENT(block_bio, block_bio_frontmerge,
 
 	TP_PROTO(struct request_queue *q, struct bio *bio),
 
-	TP_ARGS(q, bio),
+	TP_ARGS(q, bio)
+);
 
-	TP_STRUCT__entry(
-		__field( dev_t,		dev			)
-		__field( sector_t,	sector			)
-		__field( unsigned int,	nr_sector		)
-		__array( char,		rwbs,	6		)
-		__array( char,		comm,	TASK_COMM_LEN	)
-	),
+DEFINE_EVENT(block_bio, block_bio_queue,
 
-	TP_fast_assign(
-		__entry->dev		= bio->bi_bdev->bd_dev;
-		__entry->sector		= bio->bi_sector;
-		__entry->nr_sector	= bio->bi_size >> 9;
-		blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
-		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
-	),
+	TP_PROTO(struct request_queue *q, struct bio *bio),
 
-	TP_printk("%d,%d %s %llu + %u [%s]",
-		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->comm)
+	TP_ARGS(q, bio)
 );
 
-TRACE_EVENT(block_getrq,
+TRACE_EVENT_TEMPLATE(block_get_rq,
 
 	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
 
@@ -341,33 +243,18 @@ TRACE_EVENT(block_getrq,
 		  __entry->nr_sector, __entry->comm)
 );
 
-TRACE_EVENT(block_sleeprq,
+DEFINE_EVENT(block_get_rq, block_getrq,
 
 	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
 
-	TP_ARGS(q, bio, rw),
+	TP_ARGS(q, bio, rw)
+);
 
-	TP_STRUCT__entry(
-		__field( dev_t,		dev			)
-		__field( sector_t,	sector			)
-		__field( unsigned int,	nr_sector		)
-		__array( char,		rwbs,	6		)
-		__array( char,		comm,	TASK_COMM_LEN	)
-	),
+DEFINE_EVENT(block_get_rq, block_sleeprq,
 
-	TP_fast_assign(
-		__entry->dev		= bio ? bio->bi_bdev->bd_dev : 0;
-		__entry->sector		= bio ? bio->bi_sector : 0;
-		__entry->nr_sector	= bio ? bio->bi_size >> 9 : 0;
-		blk_fill_rwbs(__entry->rwbs,
-			    bio ? bio->bi_rw : 0, __entry->nr_sector);
-		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
-	),
+	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
 
-	TP_printk("%d,%d %s %llu + %u [%s]",
-		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->comm)
+	TP_ARGS(q, bio, rw)
 );
 
 TRACE_EVENT(block_plug,
@@ -387,7 +274,7 @@ TRACE_EVENT(block_plug,
 	TP_printk("[%s]", __entry->comm)
 );
 
-TRACE_EVENT(block_unplug_timer,
+TRACE_EVENT_TEMPLATE(block_unplug,
 
 	TP_PROTO(struct request_queue *q),
 
@@ -406,23 +293,18 @@ TRACE_EVENT(block_unplug_timer,
 	TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
 );
 
-TRACE_EVENT(block_unplug_io,
+DEFINE_EVENT(block_unplug, block_unplug_timer,
 
 	TP_PROTO(struct request_queue *q),
 
-	TP_ARGS(q),
+	TP_ARGS(q)
+);
 
-	TP_STRUCT__entry(
-		__field( int,		nr_rq			)
-		__array( char,		comm,	TASK_COMM_LEN	)
-	),
+DEFINE_EVENT(block_unplug, block_unplug_io,
 
-	TP_fast_assign(
-		__entry->nr_rq	= q->rq.count[READ] + q->rq.count[WRITE];
-		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
-	),
+	TP_PROTO(struct request_queue *q),
 
-	TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
+	TP_ARGS(q)
 );
 
 TRACE_EVENT(block_split,
-- 
1.6.3


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

* [PATCH 7/9] tracing: Convert some jbd2 events to DEFINE_EVENT
  2009-11-26  7:02 [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Li Zefan
                   ` (5 preceding siblings ...)
  2009-11-26  7:06 ` [PATCH 6/9] tracing: Convert some block " Li Zefan
@ 2009-11-26  7:06 ` Li Zefan
  2009-11-26  8:44   ` [tip:perf/core] " tip-bot for Li Zefan
  2009-11-26  7:07 ` [PATCH 8/9] tracing: Convert some ext4 events to DEFINE_TRACE Li Zefan
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 43+ messages in thread
From: Li Zefan @ 2009-11-26  7:06 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Theodore Ts'o, Steven Rostedt, Frederic Weisbecker, LKML

Use TRACE_EVENT_TEMPLATE to remove duplicate code:

   text    data     bss     dec     hex filename
  34903    1693     448   37044    90b4 fs/jbd2/journal.o.old
  31931    1693     416   34040    84f8 fs/jbd2/journal.o

Four events are converted:

  jbd2_commit: jbd2_start_commit,
               jbd2_commit_{locking, flushing, logging}

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/trace/events/jbd2.h |   63 +++++++-----------------------------------
 1 files changed, 11 insertions(+), 52 deletions(-)

diff --git a/include/trace/events/jbd2.h b/include/trace/events/jbd2.h
index 3c60b75..a1abcf4 100644
--- a/include/trace/events/jbd2.h
+++ b/include/trace/events/jbd2.h
@@ -30,7 +30,7 @@ TRACE_EVENT(jbd2_checkpoint,
 		  jbd2_dev_to_name(__entry->dev), __entry->result)
 );
 
-TRACE_EVENT(jbd2_start_commit,
+TRACE_EVENT_TEMPLATE(jbd2_commit,
 
 	TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
 
@@ -53,73 +53,32 @@ TRACE_EVENT(jbd2_start_commit,
 		  __entry->sync_commit)
 );
 
-TRACE_EVENT(jbd2_commit_locking,
+DEFINE_EVENT(jbd2_commit, jbd2_start_commit,
 
 	TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
 
-	TP_ARGS(journal, commit_transaction),
-
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	char,	sync_commit		  )
-		__field(	int,	transaction		  )
-	),
-
-	TP_fast_assign(
-		__entry->dev		= journal->j_fs_dev->bd_dev;
-		__entry->sync_commit = commit_transaction->t_synchronous_commit;
-		__entry->transaction	= commit_transaction->t_tid;
-	),
-
-	TP_printk("dev %s transaction %d sync %d",
-		  jbd2_dev_to_name(__entry->dev), __entry->transaction,
-		  __entry->sync_commit)
+	TP_ARGS(journal, commit_transaction)
 );
 
-TRACE_EVENT(jbd2_commit_flushing,
+DEFINE_EVENT(jbd2_commit, jbd2_commit_locking,
 
 	TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
 
-	TP_ARGS(journal, commit_transaction),
-
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	char,	sync_commit		  )
-		__field(	int,	transaction		  )
-	),
-
-	TP_fast_assign(
-		__entry->dev		= journal->j_fs_dev->bd_dev;
-		__entry->sync_commit = commit_transaction->t_synchronous_commit;
-		__entry->transaction	= commit_transaction->t_tid;
-	),
-
-	TP_printk("dev %s transaction %d sync %d",
-		  jbd2_dev_to_name(__entry->dev), __entry->transaction,
-		  __entry->sync_commit)
+	TP_ARGS(journal, commit_transaction)
 );
 
-TRACE_EVENT(jbd2_commit_logging,
+DEFINE_EVENT(jbd2_commit, jbd2_commit_flushing,
 
 	TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
 
-	TP_ARGS(journal, commit_transaction),
+	TP_ARGS(journal, commit_transaction)
+);
 
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	char,	sync_commit		  )
-		__field(	int,	transaction		  )
-	),
+DEFINE_EVENT(jbd2_commit, jbd2_commit_logging,
 
-	TP_fast_assign(
-		__entry->dev		= journal->j_fs_dev->bd_dev;
-		__entry->sync_commit = commit_transaction->t_synchronous_commit;
-		__entry->transaction	= commit_transaction->t_tid;
-	),
+	TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
 
-	TP_printk("dev %s transaction %d sync %d",
-		  jbd2_dev_to_name(__entry->dev), __entry->transaction,
-		  __entry->sync_commit)
+	TP_ARGS(journal, commit_transaction)
 );
 
 TRACE_EVENT(jbd2_end_commit,
-- 
1.6.3


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

* [PATCH 8/9] tracing: Convert some ext4 events to DEFINE_TRACE
  2009-11-26  7:02 [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Li Zefan
                   ` (6 preceding siblings ...)
  2009-11-26  7:06 ` [PATCH 7/9] tracing: Convert some jbd2 " Li Zefan
@ 2009-11-26  7:07 ` Li Zefan
  2009-11-26  8:44   ` [tip:perf/core] " tip-bot for Li Zefan
  2009-11-26  7:08 ` [PATCH 9/9] tracing: Restore original format of sched events Li Zefan
  2009-11-26  7:32 ` [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Steven Rostedt
  9 siblings, 1 reply; 43+ messages in thread
From: Li Zefan @ 2009-11-26  7:07 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Theodore Ts'o, Steven Rostedt, Frederic Weisbecker, LKML

Use TRACE_EVENT_TEMPLATE to remove duplicate code:

   text    data     bss     dec     hex filename
 294695    6104     340  301139   49853 fs/ext4/ext4.o.old
 289983    6104     324  296411   485db fs/ext4/ext4.o

5 events are convertd:

  ext4__write_begin: ext4_write_begin, ext4_da_write_begin
  ext4__write_end: ext4_{ordered, writeback, journalled}_write_end

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/trace/events/ext4.h |  129 ++++++++++++-------------------------------
 1 files changed, 35 insertions(+), 94 deletions(-)

diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index d09550b..b5bbd3b 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -90,7 +90,7 @@ TRACE_EVENT(ext4_allocate_inode,
 		  (unsigned long) __entry->dir, __entry->mode)
 );
 
-TRACE_EVENT(ext4_write_begin,
+TRACE_EVENT_TEMPLATE(ext4__write_begin,
 
 	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
 		 unsigned int flags),
@@ -118,7 +118,23 @@ TRACE_EVENT(ext4_write_begin,
 		  __entry->pos, __entry->len, __entry->flags)
 );
 
-TRACE_EVENT(ext4_ordered_write_end,
+DEFINE_EVENT(ext4__write_begin, ext4_write_begin,
+
+	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+		 unsigned int flags),
+
+	TP_ARGS(inode, pos, len, flags)
+);
+
+DEFINE_EVENT(ext4__write_begin, ext4_da_write_begin,
+
+	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+		 unsigned int flags),
+
+	TP_ARGS(inode, pos, len, flags)
+);
+
+TRACE_EVENT_TEMPLATE(ext4__write_end,
 	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
 			unsigned int copied),
 
@@ -145,57 +161,36 @@ TRACE_EVENT(ext4_ordered_write_end,
 		  __entry->pos, __entry->len, __entry->copied)
 );
 
-TRACE_EVENT(ext4_writeback_write_end,
+DEFINE_EVENT(ext4__write_end, ext4_ordered_write_end,
+
 	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
 		 unsigned int copied),
 
-	TP_ARGS(inode, pos, len, copied),
+	TP_ARGS(inode, pos, len, copied)
+);
 
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	ino_t,	ino			)
-		__field(	loff_t,	pos			)
-		__field(	unsigned int, len		)
-		__field(	unsigned int, copied		)
-	),
+DEFINE_EVENT(ext4__write_end, ext4_writeback_write_end,
 
-	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
-		__entry->ino	= inode->i_ino;
-		__entry->pos	= pos;
-		__entry->len	= len;
-		__entry->copied	= copied;
-	),
+	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+		 unsigned int copied),
 
-	TP_printk("dev %s ino %lu pos %llu len %u copied %u",
-		  jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino,
-		  __entry->pos, __entry->len, __entry->copied)
+	TP_ARGS(inode, pos, len, copied)
 );
 
-TRACE_EVENT(ext4_journalled_write_end,
+DEFINE_EVENT(ext4__write_end, ext4_journalled_write_end,
+
 	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
 		 unsigned int copied),
-	TP_ARGS(inode, pos, len, copied),
 
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	ino_t,	ino			)
-		__field(	loff_t,	pos			)
-		__field(	unsigned int, len		)
-		__field(	unsigned int, copied		)
-	),
+	TP_ARGS(inode, pos, len, copied)
+);
 
-	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
-		__entry->ino	= inode->i_ino;
-		__entry->pos	= pos;
-		__entry->len	= len;
-		__entry->copied	= copied;
-	),
+DEFINE_EVENT(ext4__write_end, ext4_da_write_end,
 
-	TP_printk("dev %s ino %lu pos %llu len %u copied %u",
-		  jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino,
-		  __entry->pos, __entry->len, __entry->copied)
+	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+		 unsigned int copied),
+
+	TP_ARGS(inode, pos, len, copied)
 );
 
 TRACE_EVENT(ext4_writepage,
@@ -337,60 +332,6 @@ TRACE_EVENT(ext4_da_writepages_result,
 		  (unsigned long) __entry->writeback_index)
 );
 
-TRACE_EVENT(ext4_da_write_begin,
-	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
-			unsigned int flags),
-
-	TP_ARGS(inode, pos, len, flags),
-
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	ino_t,	ino			)
-		__field(	loff_t,	pos			)
-		__field(	unsigned int, len		)
-		__field(	unsigned int, flags		)
-	),
-
-	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
-		__entry->ino	= inode->i_ino;
-		__entry->pos	= pos;
-		__entry->len	= len;
-		__entry->flags	= flags;
-	),
-
-	TP_printk("dev %s ino %lu pos %llu len %u flags %u",
-		  jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino,
-		  __entry->pos, __entry->len, __entry->flags)
-);
-
-TRACE_EVENT(ext4_da_write_end,
-	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
-			unsigned int copied),
-
-	TP_ARGS(inode, pos, len, copied),
-
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	ino_t,	ino			)
-		__field(	loff_t,	pos			)
-		__field(	unsigned int, len		)
-		__field(	unsigned int, copied		)
-	),
-
-	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
-		__entry->ino	= inode->i_ino;
-		__entry->pos	= pos;
-		__entry->len	= len;
-		__entry->copied	= copied;
-	),
-
-	TP_printk("dev %s ino %lu pos %llu len %u copied %u",
-		  jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino,
-		  __entry->pos, __entry->len, __entry->copied)
-);
-
 TRACE_EVENT(ext4_discard_blocks,
 	TP_PROTO(struct super_block *sb, unsigned long long blk,
 			unsigned long long count),
-- 
1.6.3


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

* [PATCH 9/9] tracing: Restore original format of sched events
  2009-11-26  7:02 [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Li Zefan
                   ` (7 preceding siblings ...)
  2009-11-26  7:07 ` [PATCH 8/9] tracing: Convert some ext4 events to DEFINE_TRACE Li Zefan
@ 2009-11-26  7:08 ` Li Zefan
  2009-11-26  8:44   ` [tip:perf/core] " tip-bot for Li Zefan
  2009-11-26  7:32 ` [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Steven Rostedt
  9 siblings, 1 reply; 43+ messages in thread
From: Li Zefan @ 2009-11-26  7:08 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Steven Rostedt, Frederic Weisbecker, LKML

The original format for sched_stat_iowait and sched_stat_sleep:

  $ cat events/sched/sched_stat_iowait/format
  ...
  print fmt: "comm=%s pid=%d delay=%Lu [ns]", ...
  $ cat events/sched/sched_stat_sleep/format
  ...
  print fmt: "comm=%s pid=%d delay=%Lu [ns]", ...

But commit commit 75ec29ab848a7e92a41aaafaeb33d1afbc839be4
("tracing: Convert some sched trace events to DEFINE_EVENT and _PRINT")
broke the format:

  $ cat events/sched/sched_stat_iowait/format
  print fmt: "task: %s:%d iowait: %Lu [ns]", ...
  $ cat events/sched/sched_stat_sleep/format
  print fmt: "task: %s:%d sleep: %Lu [ns]", ...

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/trace/events/sched.h |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 238f74b..7f67d27 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -355,23 +355,17 @@ DEFINE_EVENT(sched_stat_template, sched_stat_wait,
  * Tracepoint for accounting sleep time (time the task is not runnable,
  * including iowait, see below).
  */
-DEFINE_EVENT_PRINT(sched_stat_template, sched_stat_sleep,
-		   TP_PROTO(struct task_struct *tsk, u64 delay),
-		   TP_ARGS(tsk, delay),
-		   TP_printk("task: %s:%d sleep: %Lu [ns]",
-			     __entry->comm, __entry->pid,
-			     (unsigned long long)__entry->delay));
+DEFINE_EVENT(sched_stat_template, sched_stat_sleep,
+	     TP_PROTO(struct task_struct *tsk, u64 delay),
+	     TP_ARGS(tsk, delay));
 
 /*
  * Tracepoint for accounting iowait time (time the task is not runnable
  * due to waiting on IO to complete).
  */
-DEFINE_EVENT_PRINT(sched_stat_template, sched_stat_iowait,
-		   TP_PROTO(struct task_struct *tsk, u64 delay),
-		   TP_ARGS(tsk, delay),
-		   TP_printk("task: %s:%d iowait: %Lu [ns]",
-			     __entry->comm, __entry->pid,
-			     (unsigned long long)__entry->delay));
+DEFINE_EVENT(sched_stat_template, sched_stat_iowait,
+	     TP_PROTO(struct task_struct *tsk, u64 delay),
+	     TP_ARGS(tsk, delay));
 
 /*
  * Tracepoint for accounting runtime (time the task is executing
-- 
1.6.3


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

* Re: [PATCH 2/9] tracing: Convert some kmem events to DEFINE_EVENT
  2009-11-26  7:04 ` [PATCH 2/9] tracing: Convert some kmem " Li Zefan
@ 2009-11-26  7:24   ` Pekka Enberg
  2009-11-26  7:38     ` Steven Rostedt
  2009-11-26  7:57     ` Ingo Molnar
  2009-11-26  8:16   ` [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS() tip-bot for Ingo Molnar
                     ` (2 subsequent siblings)
  3 siblings, 2 replies; 43+ messages in thread
From: Pekka Enberg @ 2009-11-26  7:24 UTC (permalink / raw)
  To: Li Zefan
  Cc: Ingo Molnar, Steven Rostedt, Frederic Weisbecker, LKML, Mel Gorman

Li Zefan kirjoitti:
> Use TRACE_EVENT_TEMPLATE to remove duplicate code:
> 
>    text    data     bss     dec     hex filename
>  333987   69800   27228  431015   693a7 mm/built-in.o.old
>  330030   69800   27228  427058   68432 mm/built-in.o
> 
> 8 events are converted:
> 
>   kmem_alloc: kmalloc, kmem_cache_alloc
>   kmem_alloc_node: kmalloc_node, kmem_cache_alloc_node
>   kmem_free: kfree, kmem_cache_free
>   mm_page: mm_page_alloc_zone_locked, mm_page_pcpu_drain
> 
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

I have no idea what TRACE_EVENT_TEMPLATE is but the space savings are 
convincing enough! I assume this is going into -tip?

Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>

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

* Re: [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE
  2009-11-26  7:02 [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Li Zefan
                   ` (8 preceding siblings ...)
  2009-11-26  7:08 ` [PATCH 9/9] tracing: Restore original format of sched events Li Zefan
@ 2009-11-26  7:32 ` Steven Rostedt
  2009-11-26  7:59   ` Ingo Molnar
  9 siblings, 1 reply; 43+ messages in thread
From: Steven Rostedt @ 2009-11-26  7:32 UTC (permalink / raw)
  To: Li Zefan; +Cc: Ingo Molnar, Frederic Weisbecker, LKML

On Thu, 2009-11-26 at 15:02 +0800, Li Zefan wrote:
> Convert some trace events defined in include/trace/events/*.h
> to DEFINE_TRACE and DEFINE_TRACE_PRINT.
> 
> This reduces hundreds of code lines, and shrinks the size
> of object files.
> 
> Tested by comparing the formats of each trace_event before
> and after patching.
> 
> This patchset is based on -tip tree, but I've conformed the
> ext4 bits won't conflict with ext4 tree.

Thanks Li!

Ingo or Frederic,

Can you pull these in and test them. I'm about to celebrate my turkey
dinner, and I wont be back until Monday.

-- Steve



> ---
>  include/trace/events/block.h     |  202 ++++++++------------------------------
>  include/trace/events/ext4.h      |  129 +++++++------------------
>  include/trace/events/irq.h       |   46 ++++-----
>  include/trace/events/jbd2.h      |   63 ++----------
>  include/trace/events/kmem.h      |  130 ++++++++-----------------
>  include/trace/events/module.h    |   22 ++---
>  include/trace/events/power.h     |   36 +++----
>  include/trace/events/sched.h     |   18 +---
>  include/trace/events/workqueue.h |   22 ++---
>  mm/page_alloc.c                  |    4 +-
>  mm/util.c                        |    3 -
>  11 files changed, 187 insertions(+), 488 deletions(-)
> 


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

* Re: [PATCH 2/9] tracing: Convert some kmem events to DEFINE_EVENT
  2009-11-26  7:24   ` Pekka Enberg
@ 2009-11-26  7:38     ` Steven Rostedt
  2009-11-26  7:57     ` Ingo Molnar
  1 sibling, 0 replies; 43+ messages in thread
From: Steven Rostedt @ 2009-11-26  7:38 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: Li Zefan, Ingo Molnar, Frederic Weisbecker, LKML, Mel Gorman

On Thu, 2009-11-26 at 09:24 +0200, Pekka Enberg wrote:

> I have no idea what TRACE_EVENT_TEMPLATE is but the space savings are 
> convincing enough! I assume this is going into -tip?

TRACE_EVENT_TEMPLATE acts just like TRACE_EVENT but it does not create
the trace point. It does create general functions described by the
template. These are the functions to record data and how to print that
data, and show its format to userspace.

DEFINE_EVENT is used to hook an actual trace point up with the functions
created by the template.

There are a lot of events that are almost identical except for their
names. Using TRACE_EVENT() itself will create the functions to record
the data, print it, and show the format for each event, even though most
of these events are identical except for the name.

Christoph Hellwig was killed by this, since he had hundreds of
TRACE_EVENTS all with the same data. After converting it to the
templates, he saved a hell of a lot of space.

-- Steve



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

* Re: [PATCH 2/9] tracing: Convert some kmem events to DEFINE_EVENT
  2009-11-26  7:24   ` Pekka Enberg
  2009-11-26  7:38     ` Steven Rostedt
@ 2009-11-26  7:57     ` Ingo Molnar
  2009-11-26  8:29       ` Steven Rostedt
  1 sibling, 1 reply; 43+ messages in thread
From: Ingo Molnar @ 2009-11-26  7:57 UTC (permalink / raw)
  To: Pekka Enberg
  Cc: Li Zefan, Steven Rostedt, Frederic Weisbecker, LKML, Mel Gorman


* Pekka Enberg <penberg@cs.helsinki.fi> wrote:

> Li Zefan kirjoitti:
> >Use TRACE_EVENT_TEMPLATE to remove duplicate code:
> >
> >   text    data     bss     dec     hex filename
> > 333987   69800   27228  431015   693a7 mm/built-in.o.old
> > 330030   69800   27228  427058   68432 mm/built-in.o
> >
> >8 events are converted:
> >
> >  kmem_alloc: kmalloc, kmem_cache_alloc
> >  kmem_alloc_node: kmalloc_node, kmem_cache_alloc_node
> >  kmem_free: kfree, kmem_cache_free
> >  mm_page: mm_page_alloc_zone_locked, mm_page_pcpu_drain
> >
> >Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> 
> I have no idea what TRACE_EVENT_TEMPLATE is [...]

See these recent commits in tip:perf/core:

 75ec29a: tracing: Convert some sched trace events to DEFINE_EVENT and _PRINT
 e5bc972: tracing: Create new DEFINE_EVENT_PRINT
 ff038f5: tracing: Create new TRACE_EVENT_TEMPLATE

This introduces the new TRACE_EVENT_TEMPLATE + DEFINE_EVENT construct 
that allows one to 'clone' existing tracepoints into a new tracepoint 
that have the same parameters/format but differing callsites.

The existing TRACE_EVENT construct is there too (unchanged), it's 
equivalent to TRACE_EVENT_TEMPLATE()+DEFINE_EVENT().

It basically introduces a 'class'/'template' of tracepoints - which can 
then be used to create real tracepoints.

Btw., the fact that it wasnt entirely obvious for you from the patch 
what it does, there's one rename we should do, to have more consistent 
and more self-explanatory naming:

  DECLARE_EVENT_CLASS(class)

    DEFINE_EVENT(class, event1)
    DEFINE_EVENT(class, event2)
    DEFINE_EVENT(class, event3)

  DEFINE_SINGLE_EVENT(single_event)

Naming the 'standalone' variant like that signals this difference and 
encourages people to create classes/groups of events instead of creating 
many singular events.

> [...] but the space savings are convincing enough! I assume this is 
> going into -tip?

Yeah, tip:perf/core, with your ack.

> Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>

Thanks,

	Ingo

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

* Re: [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE
  2009-11-26  7:32 ` [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Steven Rostedt
@ 2009-11-26  7:59   ` Ingo Molnar
  0 siblings, 0 replies; 43+ messages in thread
From: Ingo Molnar @ 2009-11-26  7:59 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Li Zefan, Frederic Weisbecker, LKML


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

> On Thu, 2009-11-26 at 15:02 +0800, Li Zefan wrote:
> > Convert some trace events defined in include/trace/events/*.h
> > to DEFINE_TRACE and DEFINE_TRACE_PRINT.
> > 
> > This reduces hundreds of code lines, and shrinks the size
> > of object files.
> > 
> > Tested by comparing the formats of each trace_event before
> > and after patching.
> > 
> > This patchset is based on -tip tree, but I've conformed the
> > ext4 bits won't conflict with ext4 tree.
> 
> Thanks Li!
> 
> Ingo or Frederic,
> 
> Can you pull these in and test them. I'm about to celebrate my turkey 
> dinner, and I wont be back until Monday.

Yep, i'm on it.

	Ingo

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

* [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
  2009-11-26  7:04 ` [PATCH 2/9] tracing: Convert some kmem " Li Zefan
  2009-11-26  7:24   ` Pekka Enberg
@ 2009-11-26  8:16   ` tip-bot for Ingo Molnar
  2009-11-26  8:33     ` Steven Rostedt
  2009-11-26  8:42   ` [tip:perf/core] tracing: Convert some kmem events to DEFINE_EVENT tip-bot for Li Zefan
  2009-11-26 12:34   ` [tip:perf/core] tracing: Fix kmem event exports tip-bot for Ingo Molnar
  3 siblings, 1 reply; 43+ messages in thread
From: tip-bot for Ingo Molnar @ 2009-11-26  8:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, penberg, fweisbec, rostedt, tglx, mingo

Commit-ID:  091ad3658e3c76c5fb05f65bfb64a0246f8f31b5
Gitweb:     http://git.kernel.org/tip/091ad3658e3c76c5fb05f65bfb64a0246f8f31b5
Author:     Ingo Molnar <mingo@elte.hu>
AuthorDate: Thu, 26 Nov 2009 09:04:55 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 09:04:55 +0100

events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

It is not quite obvious at first sight what TRACE_EVENT_TEMPLATE
does: does it define an event as well beyond defining a template?

To clarify this, rename it to DECLARE_EVENT_CLASS, which follows
the various 'DECLARE_*()' idioms we already have in the kernel:

  DECLARE_EVENT_CLASS(class)

    DEFINE_EVENT(class, event1)
    DEFINE_EVENT(class, event2)
    DEFINE_EVENT(class, event3)

To complete this logic we should also rename TRACE_EVENT() to:

  DEFINE_SINGLE_EVENT(single_event)

... but in a more quiet moment of the kernel cycle.

Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4B0E286A.2000405@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/linux/tracepoint.h   |    2 +-
 include/trace/define_trace.h |    2 +-
 include/trace/events/sched.h |    6 ++--
 include/trace/ftrace.h       |   46 +++++++++++++++++++++---------------------
 4 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 7063383..f59604e 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -280,7 +280,7 @@ static inline void tracepoint_synchronize_unregister(void)
  * TRACE_EVENT_FN to perform any (un)registration work.
  */
 
-#define TRACE_EVENT_TEMPLATE(name, proto, args, tstruct, assign, print)
+#define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
 #define DEFINE_EVENT(template, name, proto, args)		\
 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 #define DEFINE_EVENT_PRINT(template, name, proto, args, print)	\
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h
index 5d7d855..5acfb1e 100644
--- a/include/trace/define_trace.h
+++ b/include/trace/define_trace.h
@@ -71,7 +71,7 @@
 
 #undef TRACE_EVENT
 #undef TRACE_EVENT_FN
-#undef TRACE_EVENT_TEMPLATE
+#undef DECLARE_EVENT_CLASS
 #undef DEFINE_EVENT
 #undef DEFINE_EVENT_PRINT
 #undef TRACE_HEADER_MULTI_READ
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 238f74b..5ce7950 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -83,7 +83,7 @@ TRACE_EVENT(sched_wait_task,
  * (NOTE: the 'rq' argument is not used by generic trace events,
  *        but used by the latency tracer plugin. )
  */
-TRACE_EVENT_TEMPLATE(sched_wakeup_template,
+DECLARE_EVENT_CLASS(sched_wakeup_template,
 
 	TP_PROTO(struct rq *rq, struct task_struct *p, int success),
 
@@ -197,7 +197,7 @@ TRACE_EVENT(sched_migrate_task,
 		  __entry->orig_cpu, __entry->dest_cpu)
 );
 
-TRACE_EVENT_TEMPLATE(sched_process_template,
+DECLARE_EVENT_CLASS(sched_process_template,
 
 	TP_PROTO(struct task_struct *p),
 
@@ -316,7 +316,7 @@ TRACE_EVENT(sched_signal_send,
  * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
  *     adding sched_stat support to SCHED_FIFO/RR would be welcome.
  */
-TRACE_EVENT_TEMPLATE(sched_stat_template,
+DECLARE_EVENT_CLASS(sched_stat_template,
 
 	TP_PROTO(struct task_struct *tsk, u64 delay),
 
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index b046177..2c9c073 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -19,17 +19,17 @@
 #include <linux/ftrace_event.h>
 
 /*
- * TRACE_EVENT_TEMPLATE can be used to add a generic function
+ * DECLARE_EVENT_CLASS can be used to add a generic function
  * handlers for events. That is, if all events have the same
  * parameters and just have distinct trace points.
  * Each tracepoint can be defined with DEFINE_EVENT and that
- * will map the TRACE_EVENT_TEMPLATE to the tracepoint.
+ * will map the DECLARE_EVENT_CLASS to the tracepoint.
  *
  * TRACE_EVENT is a one to one mapping between tracepoint and template.
  */
 #undef TRACE_EVENT
 #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
-	TRACE_EVENT_TEMPLATE(name,			       \
+	DECLARE_EVENT_CLASS(name,			       \
 			     PARAMS(proto),		       \
 			     PARAMS(args),		       \
 			     PARAMS(tstruct),		       \
@@ -56,8 +56,8 @@
 #undef TP_STRUCT__entry
 #define TP_STRUCT__entry(args...) args
 
-#undef TRACE_EVENT_TEMPLATE
-#define TRACE_EVENT_TEMPLATE(name, proto, args, tstruct, assign, print)	\
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)	\
 	struct ftrace_raw_##name {					\
 		struct trace_entry	ent;				\
 		tstruct							\
@@ -115,8 +115,8 @@
 #undef __string
 #define __string(item, src) __dynamic_array(char, item, -1)
 
-#undef TRACE_EVENT_TEMPLATE
-#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print)	\
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
 	struct ftrace_data_offsets_##call {				\
 		tstruct;						\
 	};
@@ -203,8 +203,8 @@
 #undef TP_perf_assign
 #define TP_perf_assign(args...)
 
-#undef TRACE_EVENT_TEMPLATE
-#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, func, print)	\
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print)	\
 static int								\
 ftrace_format_setup_##call(struct ftrace_event_call *unused,		\
 			   struct trace_seq *s)				\
@@ -321,8 +321,8 @@ ftrace_format_##name(struct ftrace_event_call *unused,			\
 		ftrace_print_symbols_seq(p, value, symbols);		\
 	})
 
-#undef TRACE_EVENT_TEMPLATE
-#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print)	\
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
 static enum print_line_t						\
 ftrace_raw_output_id_##call(int event_id, const char *name,		\
 			    struct trace_iterator *iter, int flags)	\
@@ -428,8 +428,8 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags)	\
 #undef __string
 #define __string(item, src) __dynamic_array(char, item, -1)
 
-#undef TRACE_EVENT_TEMPLATE
-#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, func, print)	\
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print)	\
 static int								\
 ftrace_define_fields_##call(struct ftrace_event_call *event_call)	\
 {									\
@@ -480,8 +480,8 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call)	\
 #undef __string
 #define __string(item, src) __dynamic_array(char, item, strlen(src) + 1)
 
-#undef TRACE_EVENT_TEMPLATE
-#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print)	\
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
 static inline int ftrace_get_offsets_##call(				\
 	struct ftrace_data_offsets_##call *__data_offsets, proto)       \
 {									\
@@ -521,8 +521,8 @@ static inline int ftrace_get_offsets_##call(				\
  *
  */
 
-#undef TRACE_EVENT_TEMPLATE
-#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print)
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)
 
 #undef DEFINE_EVENT
 #define DEFINE_EVENT(template, name, proto, args)			\
@@ -681,8 +681,8 @@ static void ftrace_profile_disable_##name(struct ftrace_event_call *unused)\
 #define __assign_str(dst, src)						\
 	strcpy(__get_str(dst), src);
 
-#undef TRACE_EVENT_TEMPLATE
-#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print)	\
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
 									\
 static void ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \
 				       proto)				\
@@ -764,8 +764,8 @@ static int ftrace_raw_init_event_##call(struct ftrace_event_call *unused)\
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
-#undef TRACE_EVENT_TEMPLATE
-#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print)
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)
 
 #undef DEFINE_EVENT
 #define DEFINE_EVENT(template, call, proto, args)			\
@@ -885,8 +885,8 @@ __attribute__((section("_ftrace_events"))) event_##call = {		\
 #undef __perf_count
 #define __perf_count(c) __count = (c)
 
-#undef TRACE_EVENT_TEMPLATE
-#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print)	\
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
 static void								\
 ftrace_profile_templ_##call(struct ftrace_event_call *event_call,	\
 			    proto)					\

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

* Re: [PATCH 2/9] tracing: Convert some kmem events to DEFINE_EVENT
  2009-11-26  7:57     ` Ingo Molnar
@ 2009-11-26  8:29       ` Steven Rostedt
  0 siblings, 0 replies; 43+ messages in thread
From: Steven Rostedt @ 2009-11-26  8:29 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Pekka Enberg, Li Zefan, Frederic Weisbecker, LKML, Mel Gorman

On Thu, 2009-11-26 at 08:57 +0100, Ingo Molnar wrote:
> * Pekka Enberg <penberg@cs.helsinki.fi> wrote:
> 
> > Li Zefan kirjoitti:
> > >Use TRACE_EVENT_TEMPLATE to remove duplicate code:
> > >
> > >   text    data     bss     dec     hex filename
> > > 333987   69800   27228  431015   693a7 mm/built-in.o.old
> > > 330030   69800   27228  427058   68432 mm/built-in.o
> > >
> > >8 events are converted:
> > >
> > >  kmem_alloc: kmalloc, kmem_cache_alloc
> > >  kmem_alloc_node: kmalloc_node, kmem_cache_alloc_node
> > >  kmem_free: kfree, kmem_cache_free
> > >  mm_page: mm_page_alloc_zone_locked, mm_page_pcpu_drain
> > >
> > >Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> > 
> > I have no idea what TRACE_EVENT_TEMPLATE is [...]

> 
> Btw., the fact that it wasnt entirely obvious for you from the patch 
> what it does, there's one rename we should do, to have more consistent 
> and more self-explanatory naming:
> 
>   DECLARE_EVENT_CLASS(class)
> 
>     DEFINE_EVENT(class, event1)
>     DEFINE_EVENT(class, event2)
>     DEFINE_EVENT(class, event3)
> 
>   DEFINE_SINGLE_EVENT(single_event)
> 
> Naming the 'standalone' variant like that signals this difference and 
> encourages people to create classes/groups of events instead of creating 
> many singular events.

I'm not really attached to the names, but I wouldn't go by it not being
obvious for Pekka as a reason for changing it. In the context of the
change log, if it were to say:

>Use DECLARE_EVENT_CLASS to remove duplicate code:
>
>   text    data     bss     dec     hex filename
> 333987   69800   27228  431015   693a7 mm/built-in.o.old
> 330030   69800   27228  427058   68432 mm/built-in.o
>
>8 events are converted:
>
>  kmem_alloc: kmalloc, kmem_cache_alloc
>  kmem_alloc_node: kmalloc_node, kmem_cache_alloc_node
>  kmem_free: kfree, kmem_cache_free
>  mm_page: mm_page_alloc_zone_locked, mm_page_pcpu_drain
>

I'm not sure it would make it any more obvious to what the
class/template does. ;-)

-- Steve



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

* Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
  2009-11-26  8:16   ` [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS() tip-bot for Ingo Molnar
@ 2009-11-26  8:33     ` Steven Rostedt
  2009-11-26  8:40       ` Ingo Molnar
  0 siblings, 1 reply; 43+ messages in thread
From: Steven Rostedt @ 2009-11-26  8:33 UTC (permalink / raw)
  To: mingo, hpa, linux-kernel, fweisbec, penberg, tglx, mingo
  Cc: linux-tip-commits

On Thu, 2009-11-26 at 08:16 +0000, tip-bot for Ingo Molnar wrote:
> Commit-ID:  091ad3658e3c76c5fb05f65bfb64a0246f8f31b5
> Gitweb:     http://git.kernel.org/tip/091ad3658e3c76c5fb05f65bfb64a0246f8f31b5
> Author:     Ingo Molnar <mingo@elte.hu>
> AuthorDate: Thu, 26 Nov 2009 09:04:55 +0100
> Committer:  Ingo Molnar <mingo@elte.hu>
> CommitDate: Thu, 26 Nov 2009 09:04:55 +0100
> 
> events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
> 
> It is not quite obvious at first sight what TRACE_EVENT_TEMPLATE
> does: does it define an event as well beyond defining a template?
> 
> To clarify this, rename it to DECLARE_EVENT_CLASS, which follows
> the various 'DECLARE_*()' idioms we already have in the kernel:
> 
>   DECLARE_EVENT_CLASS(class)
> 
>     DEFINE_EVENT(class, event1)
>     DEFINE_EVENT(class, event2)
>     DEFINE_EVENT(class, event3)
> 
> To complete this logic we should also rename TRACE_EVENT() to:
> 
>   DEFINE_SINGLE_EVENT(single_event)
> 
> ... but in a more quiet moment of the kernel cycle.


I would like to hear what others think about this change before we go
ahead and implement it. A lot of developers have just learned about
TRACE_EVENT and now it just disappeared. Well, not really, but in the
sense of ' find linux.git -name '*.[ch]' | xargs grep TRACE_EVENT' it no
longer exists.

-- Steve



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

* Re: [PATCH 6/9] tracing: Convert some block events to DEFINE_EVENT
  2009-11-26  7:06 ` [PATCH 6/9] tracing: Convert some block " Li Zefan
@ 2009-11-26  8:36   ` Jens Axboe
  2009-11-26  8:44     ` Ingo Molnar
  2009-11-26  8:43   ` [tip:perf/core] " tip-bot for Li Zefan
  1 sibling, 1 reply; 43+ messages in thread
From: Jens Axboe @ 2009-11-26  8:36 UTC (permalink / raw)
  To: Li Zefan; +Cc: Ingo Molnar, Steven Rostedt, Frederic Weisbecker, LKML

On Thu, Nov 26 2009, Li Zefan wrote:
> use TRACE_EVENT_TEMPLATE to remove duplicate code:
> 
>    text    data     bss     dec     hex filename
>   53570    3284     184   57038    dece block/blk-core.o.old
>   43702    3284     144   47130    b81a block/blk-core.o

Nice! When I played with the writeback tracing, I did notice that code
bloat does get pretty severe quickly.

I have applied this to for-2.6.33, thanks a lot.

-- 
Jens Axboe


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

* Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
  2009-11-26  8:33     ` Steven Rostedt
@ 2009-11-26  8:40       ` Ingo Molnar
  2009-11-26 14:45         ` Steven Rostedt
  0 siblings, 1 reply; 43+ messages in thread
From: Ingo Molnar @ 2009-11-26  8:40 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: mingo, hpa, linux-kernel, fweisbec, penberg, tglx, linux-tip-commits


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

> On Thu, 2009-11-26 at 08:16 +0000, tip-bot for Ingo Molnar wrote:
> > Commit-ID:  091ad3658e3c76c5fb05f65bfb64a0246f8f31b5
> > Gitweb:     http://git.kernel.org/tip/091ad3658e3c76c5fb05f65bfb64a0246f8f31b5
> > Author:     Ingo Molnar <mingo@elte.hu>
> > AuthorDate: Thu, 26 Nov 2009 09:04:55 +0100
> > Committer:  Ingo Molnar <mingo@elte.hu>
> > CommitDate: Thu, 26 Nov 2009 09:04:55 +0100
> > 
> > events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
> > 
> > It is not quite obvious at first sight what TRACE_EVENT_TEMPLATE
> > does: does it define an event as well beyond defining a template?
> > 
> > To clarify this, rename it to DECLARE_EVENT_CLASS, which follows
> > the various 'DECLARE_*()' idioms we already have in the kernel:
> > 
> >   DECLARE_EVENT_CLASS(class)
> > 
> >     DEFINE_EVENT(class, event1)
> >     DEFINE_EVENT(class, event2)
> >     DEFINE_EVENT(class, event3)
> > 
> > To complete this logic we should also rename TRACE_EVENT() to:
> > 
> >   DEFINE_SINGLE_EVENT(single_event)
> > 
> > ... but in a more quiet moment of the kernel cycle.
> 
> 
> I would like to hear what others think about this change before we go 
> ahead and implement it.

You mean TRACE_EVENT() -> DEFINE_SINGLE_EVENT()? Sure, we want todo it 
in a more quiet moment of the kernel cycle, not now.

(TRACE_EVENT_TEMPLATE OTOH has existed for just a few days so it's not a 
problem.)

> A lot of developers have just learned about TRACE_EVENT and now it 
> just disappeared. Well, not really, but in the sense of ' find 
> linux.git -name '*.[ch]' | xargs grep TRACE_EVENT' it no longer 
> exists.

A second problem with the TRACE_EVENT name is that it's not just for 
tracing - we dont necessarily 'trace' events here. We can use the event 
callbacks to collect pure counts:

| aldebaran> perf stat -e sched:sched_wakeup ./hackbench 10
| Time: 0.093
|
|  Performance counter stats for './hackbench 10':
|
|           15481  sched:sched_wakeup      
|
|     0.107390574  seconds time elapsed

etc.

A third problem is that the name 'TRACE_EVENT' does not tell us what is 
being done. Do we declare it? Do we also define it?

DEFINE_SINGLE_EVENT() solves all these problems:

 - It's obvious what it does

 - It suggests users of it that there's another non-single-event 
   facility, gently nudging them towards the use of the more efficient
   DEFINE_EVENT_CLASS() + DEFINE_EVENT() method.

 - It fits nicely into the rest of the naming scheme.

	Ingo

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

* [tip:perf/core] tracing: Convert module refcnt events to DEFINE_EVENT
  2009-11-26  7:03 ` [PATCH 1/9] tracing: Convert module refcnt events to DEFINE_EVENT Li Zefan
@ 2009-11-26  8:42   ` tip-bot for Li Zefan
  0 siblings, 0 replies; 43+ messages in thread
From: tip-bot for Li Zefan @ 2009-11-26  8:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, lizf, fweisbec, rostedt, tglx, mingo

Commit-ID:  925684d6d589e40e41007edf47c69e729d911263
Gitweb:     http://git.kernel.org/tip/925684d6d589e40e41007edf47c69e729d911263
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 26 Nov 2009 15:03:23 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 09:14:02 +0100

tracing: Convert module refcnt events to DEFINE_EVENT

Use DECLARE_EVENT_CLASS to remove duplicate code:

   text    data     bss     dec     hex filename
  29854    1980     128   31962    7cda kernel/module.o.old
  28750    1980     128   30858    788a kernel/module.o

Two events are converted:

  module_refcnt: module_get, module_put

No change in functionality.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4B0E283B.3010508@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/trace/events/module.h |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/include/trace/events/module.h b/include/trace/events/module.h
index 84160fb..4b0f48b 100644
--- a/include/trace/events/module.h
+++ b/include/trace/events/module.h
@@ -51,7 +51,7 @@ TRACE_EVENT(module_free,
 	TP_printk("%s", __get_str(name))
 );
 
-TRACE_EVENT(module_get,
+DECLARE_EVENT_CLASS(module_refcnt,
 
 	TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
 
@@ -73,26 +73,18 @@ TRACE_EVENT(module_get,
 		  __get_str(name), (void *)__entry->ip, __entry->refcnt)
 );
 
-TRACE_EVENT(module_put,
+DEFINE_EVENT(module_refcnt, module_get,
 
 	TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
 
-	TP_ARGS(mod, ip, refcnt),
+	TP_ARGS(mod, ip, refcnt)
+);
 
-	TP_STRUCT__entry(
-		__field(	unsigned long,	ip		)
-		__field(	int,		refcnt		)
-		__string(	name,		mod->name	)
-	),
+DEFINE_EVENT(module_refcnt, module_put,
 
-	TP_fast_assign(
-		__entry->ip	= ip;
-		__entry->refcnt	= refcnt;
-		__assign_str(name, mod->name);
-	),
+	TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
 
-	TP_printk("%s call_site=%pf refcnt=%d",
-		  __get_str(name), (void *)__entry->ip, __entry->refcnt)
+	TP_ARGS(mod, ip, refcnt)
 );
 
 TRACE_EVENT(module_request,

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

* [tip:perf/core] tracing: Convert some kmem events to DEFINE_EVENT
  2009-11-26  7:04 ` [PATCH 2/9] tracing: Convert some kmem " Li Zefan
  2009-11-26  7:24   ` Pekka Enberg
  2009-11-26  8:16   ` [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS() tip-bot for Ingo Molnar
@ 2009-11-26  8:42   ` tip-bot for Li Zefan
  2009-11-26 12:34   ` [tip:perf/core] tracing: Fix kmem event exports tip-bot for Ingo Molnar
  3 siblings, 0 replies; 43+ messages in thread
From: tip-bot for Li Zefan @ 2009-11-26  8:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, penberg, lizf, mel, fweisbec, rostedt,
	tglx, mingo

Commit-ID:  53d0422c2d10808fddb2c30859193bfea164c7e3
Gitweb:     http://git.kernel.org/tip/53d0422c2d10808fddb2c30859193bfea164c7e3
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 26 Nov 2009 15:04:10 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 09:14:02 +0100

tracing: Convert some kmem events to DEFINE_EVENT

Use DECLARE_EVENT_CLASS to remove duplicate code:

   text    data     bss     dec     hex filename
 333987   69800   27228  431015   693a7 mm/built-in.o.old
 330030   69800   27228  427058   68432 mm/built-in.o

8 events are converted:

  kmem_alloc: kmalloc, kmem_cache_alloc
  kmem_alloc_node: kmalloc_node, kmem_cache_alloc_node
  kmem_free: kfree, kmem_cache_free
  mm_page: mm_page_alloc_zone_locked, mm_page_pcpu_drain

No change in functionality.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mel Gorman <mel@csn.ul.ie>
LKML-Reference: <4B0E286A.2000405@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/trace/events/kmem.h |  130 +++++++++++++-----------------------------
 mm/page_alloc.c             |    4 +-
 mm/util.c                   |    3 -
 3 files changed, 43 insertions(+), 94 deletions(-)

diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index eaf46bd..3adca0c 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -44,7 +44,7 @@
 	{(unsigned long)__GFP_MOVABLE,		"GFP_MOVABLE"}		\
 	) : "GFP_NOWAIT"
 
-TRACE_EVENT(kmalloc,
+DECLARE_EVENT_CLASS(kmem_alloc,
 
 	TP_PROTO(unsigned long call_site,
 		 const void *ptr,
@@ -78,41 +78,23 @@ TRACE_EVENT(kmalloc,
 		show_gfp_flags(__entry->gfp_flags))
 );
 
-TRACE_EVENT(kmem_cache_alloc,
+DEFINE_EVENT(kmem_alloc, kmalloc,
 
-	TP_PROTO(unsigned long call_site,
-		 const void *ptr,
-		 size_t bytes_req,
-		 size_t bytes_alloc,
-		 gfp_t gfp_flags),
+	TP_PROTO(unsigned long call_site, const void *ptr,
+		 size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
 
-	TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags),
+	TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
+);
 
-	TP_STRUCT__entry(
-		__field(	unsigned long,	call_site	)
-		__field(	const void *,	ptr		)
-		__field(	size_t,		bytes_req	)
-		__field(	size_t,		bytes_alloc	)
-		__field(	gfp_t,		gfp_flags	)
-	),
+DEFINE_EVENT(kmem_alloc, kmem_cache_alloc,
 
-	TP_fast_assign(
-		__entry->call_site	= call_site;
-		__entry->ptr		= ptr;
-		__entry->bytes_req	= bytes_req;
-		__entry->bytes_alloc	= bytes_alloc;
-		__entry->gfp_flags	= gfp_flags;
-	),
+	TP_PROTO(unsigned long call_site, const void *ptr,
+		 size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
 
-	TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
-		__entry->call_site,
-		__entry->ptr,
-		__entry->bytes_req,
-		__entry->bytes_alloc,
-		show_gfp_flags(__entry->gfp_flags))
+	TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
 );
 
-TRACE_EVENT(kmalloc_node,
+DECLARE_EVENT_CLASS(kmem_alloc_node,
 
 	TP_PROTO(unsigned long call_site,
 		 const void *ptr,
@@ -150,45 +132,25 @@ TRACE_EVENT(kmalloc_node,
 		__entry->node)
 );
 
-TRACE_EVENT(kmem_cache_alloc_node,
+DEFINE_EVENT(kmem_alloc_node, kmalloc_node,
 
-	TP_PROTO(unsigned long call_site,
-		 const void *ptr,
-		 size_t bytes_req,
-		 size_t bytes_alloc,
-		 gfp_t gfp_flags,
-		 int node),
+	TP_PROTO(unsigned long call_site, const void *ptr,
+		 size_t bytes_req, size_t bytes_alloc,
+		 gfp_t gfp_flags, int node),
 
-	TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node),
+	TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
+);
 
-	TP_STRUCT__entry(
-		__field(	unsigned long,	call_site	)
-		__field(	const void *,	ptr		)
-		__field(	size_t,		bytes_req	)
-		__field(	size_t,		bytes_alloc	)
-		__field(	gfp_t,		gfp_flags	)
-		__field(	int,		node		)
-	),
+DEFINE_EVENT(kmem_alloc_node, kmem_cache_alloc_node,
 
-	TP_fast_assign(
-		__entry->call_site	= call_site;
-		__entry->ptr		= ptr;
-		__entry->bytes_req	= bytes_req;
-		__entry->bytes_alloc	= bytes_alloc;
-		__entry->gfp_flags	= gfp_flags;
-		__entry->node		= node;
-	),
+	TP_PROTO(unsigned long call_site, const void *ptr,
+		 size_t bytes_req, size_t bytes_alloc,
+		 gfp_t gfp_flags, int node),
 
-	TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
-		__entry->call_site,
-		__entry->ptr,
-		__entry->bytes_req,
-		__entry->bytes_alloc,
-		show_gfp_flags(__entry->gfp_flags),
-		__entry->node)
+	TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
 );
 
-TRACE_EVENT(kfree,
+DECLARE_EVENT_CLASS(kmem_free,
 
 	TP_PROTO(unsigned long call_site, const void *ptr),
 
@@ -207,23 +169,18 @@ TRACE_EVENT(kfree,
 	TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
 );
 
-TRACE_EVENT(kmem_cache_free,
+DEFINE_EVENT(kmem_free, kfree,
 
 	TP_PROTO(unsigned long call_site, const void *ptr),
 
-	TP_ARGS(call_site, ptr),
+	TP_ARGS(call_site, ptr)
+);
 
-	TP_STRUCT__entry(
-		__field(	unsigned long,	call_site	)
-		__field(	const void *,	ptr		)
-	),
+DEFINE_EVENT(kmem_free, kmem_cache_free,
 
-	TP_fast_assign(
-		__entry->call_site	= call_site;
-		__entry->ptr		= ptr;
-	),
+	TP_PROTO(unsigned long call_site, const void *ptr),
 
-	TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
+	TP_ARGS(call_site, ptr)
 );
 
 TRACE_EVENT(mm_page_free_direct,
@@ -299,7 +256,7 @@ TRACE_EVENT(mm_page_alloc,
 		show_gfp_flags(__entry->gfp_flags))
 );
 
-TRACE_EVENT(mm_page_alloc_zone_locked,
+DECLARE_EVENT_CLASS(mm_page,
 
 	TP_PROTO(struct page *page, unsigned int order, int migratetype),
 
@@ -325,29 +282,22 @@ TRACE_EVENT(mm_page_alloc_zone_locked,
 		__entry->order == 0)
 );
 
-TRACE_EVENT(mm_page_pcpu_drain,
+DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked,
 
-	TP_PROTO(struct page *page, int order, int migratetype),
+	TP_PROTO(struct page *page, unsigned int order, int migratetype),
 
-	TP_ARGS(page, order, migratetype),
+	TP_ARGS(page, order, migratetype)
+);
 
-	TP_STRUCT__entry(
-		__field(	struct page *,	page		)
-		__field(	int,		order		)
-		__field(	int,		migratetype	)
-	),
+DEFINE_EVENT_PRINT(mm_page, mm_page_pcpu_drain,
 
-	TP_fast_assign(
-		__entry->page		= page;
-		__entry->order		= order;
-		__entry->migratetype	= migratetype;
-	),
+	TP_PROTO(struct page *page, unsigned int order, int migratetype),
+
+	TP_ARGS(page, order, migratetype),
 
 	TP_printk("page=%p pfn=%lu order=%d migratetype=%d",
-		__entry->page,
-		page_to_pfn(__entry->page),
-		__entry->order,
-		__entry->migratetype)
+		__entry->page, page_to_pfn(__entry->page),
+		__entry->order, __entry->migratetype)
 );
 
 TRACE_EVENT(mm_page_alloc_extfrag,
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2bc2ac6..bdb22f5 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -48,12 +48,14 @@
 #include <linux/page_cgroup.h>
 #include <linux/debugobjects.h>
 #include <linux/kmemleak.h>
-#include <trace/events/kmem.h>
 
 #include <asm/tlbflush.h>
 #include <asm/div64.h>
 #include "internal.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/kmem.h>
+
 /*
  * Array of node states.
  */
diff --git a/mm/util.c b/mm/util.c
index 7c35ad9..15d1975 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -6,9 +6,6 @@
 #include <linux/sched.h>
 #include <asm/uaccess.h>
 
-#define CREATE_TRACE_POINTS
-#include <trace/events/kmem.h>
-
 /**
  * kstrdup - allocate space for and copy an existing string
  * @s: the string to duplicate

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

* [tip:perf/core] tracing: Convert softirq events to DEFINE_EVENT
  2009-11-26  7:04 ` [PATCH 3/9] tracing: Convert softirq events to DEFINE_EVENT Li Zefan
@ 2009-11-26  8:43   ` tip-bot for Li Zefan
  0 siblings, 0 replies; 43+ messages in thread
From: tip-bot for Li Zefan @ 2009-11-26  8:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, fweisbec, rostedt, lizf, tglx, mingo

Commit-ID:  c467307c1a812c3150b27a68c2b2d3397bb40a4f
Gitweb:     http://git.kernel.org/tip/c467307c1a812c3150b27a68c2b2d3397bb40a4f
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 26 Nov 2009 15:04:31 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 09:14:03 +0100

tracing: Convert softirq events to DEFINE_EVENT

Use DECLARE_EVENT_CLASS to remove duplicate code:

   text    data     bss     dec     hex filename
  12781     952      36   13769    35c9 kernel/softirq.o.old
  11981     952      32   12965    32a5 kernel/softirq.o

Two events are converted:

  softirq: softirq_entry, softirq_exit

No change in functionality.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4B0E287F.4030708@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/trace/events/irq.h |   46 ++++++++++++++++++++-----------------------
 1 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
index dcfcd44..0e4cfb6 100644
--- a/include/trace/events/irq.h
+++ b/include/trace/events/irq.h
@@ -82,18 +82,7 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
-/**
- * softirq_entry - called immediately before the softirq handler
- * @h: pointer to struct softirq_action
- * @vec: pointer to first struct softirq_action in softirq_vec array
- *
- * The @h parameter, contains a pointer to the struct softirq_action
- * which has a pointer to the action handler that is called. By subtracting
- * the @vec pointer from the @h pointer, we can determine the softirq
- * number. Also, when used in combination with the softirq_exit tracepoint
- * we can determine the softirq latency.
- */
-TRACE_EVENT(softirq_entry,
+DECLARE_EVENT_CLASS(softirq,
 
 	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
 
@@ -112,6 +101,24 @@ TRACE_EVENT(softirq_entry,
 );
 
 /**
+ * softirq_entry - called immediately before the softirq handler
+ * @h: pointer to struct softirq_action
+ * @vec: pointer to first struct softirq_action in softirq_vec array
+ *
+ * The @h parameter, contains a pointer to the struct softirq_action
+ * which has a pointer to the action handler that is called. By subtracting
+ * the @vec pointer from the @h pointer, we can determine the softirq
+ * number. Also, when used in combination with the softirq_exit tracepoint
+ * we can determine the softirq latency.
+ */
+DEFINE_EVENT(softirq, softirq_entry,
+
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+	TP_ARGS(h, vec)
+);
+
+/**
  * softirq_exit - called immediately after the softirq handler returns
  * @h: pointer to struct softirq_action
  * @vec: pointer to first struct softirq_action in softirq_vec array
@@ -122,22 +129,11 @@ TRACE_EVENT(softirq_entry,
  * combination with the softirq_entry tracepoint we can determine the softirq
  * latency.
  */
-TRACE_EVENT(softirq_exit,
+DEFINE_EVENT(softirq, softirq_exit,
 
 	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
 
-	TP_ARGS(h, vec),
-
-	TP_STRUCT__entry(
-		__field(	int,	vec			)
-	),
-
-	TP_fast_assign(
-		__entry->vec = (int)(h - vec);
-	),
-
-	TP_printk("vec=%d [action=%s]", __entry->vec,
-		  show_softirq_name(__entry->vec))
+	TP_ARGS(h, vec)
 );
 
 #endif /*  _TRACE_IRQ_H */

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

* [tip:perf/core] tracing: Convert some workqueue events to DEFINE_EVENT
  2009-11-26  7:05 ` [PATCH 4/9] tracing: Convert some workqueue " Li Zefan
@ 2009-11-26  8:43   ` tip-bot for Li Zefan
  0 siblings, 0 replies; 43+ messages in thread
From: tip-bot for Li Zefan @ 2009-11-26  8:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, fweisbec, rostedt, lizf, tglx, mingo

Commit-ID:  382ece710bf88b08440b598731361e5a47582b62
Gitweb:     http://git.kernel.org/tip/382ece710bf88b08440b598731361e5a47582b62
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 26 Nov 2009 15:05:03 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 09:14:03 +0100

tracing: Convert some workqueue events to DEFINE_EVENT

Use DECLARE_EVENT_CLASS to remove duplicate code:

   text    data     bss     dec     hex filename
  13171     800      72   14043    36db kernel/workqueue.o.old
  12243     800      68   13111    3337 kernel/workqueue.o

Two events are converted:

  workqueue: workqueue_insertion, workqueue_execution

No change in functionality.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4B0E289F.5010104@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/trace/events/workqueue.h |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/include/trace/events/workqueue.h b/include/trace/events/workqueue.h
index e4612db..d6c9744 100644
--- a/include/trace/events/workqueue.h
+++ b/include/trace/events/workqueue.h
@@ -8,7 +8,7 @@
 #include <linux/sched.h>
 #include <linux/tracepoint.h>
 
-TRACE_EVENT(workqueue_insertion,
+DECLARE_EVENT_CLASS(workqueue,
 
 	TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
 
@@ -30,26 +30,18 @@ TRACE_EVENT(workqueue_insertion,
 		__entry->thread_pid, __entry->func)
 );
 
-TRACE_EVENT(workqueue_execution,
+DEFINE_EVENT(workqueue, workqueue_insertion,
 
 	TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
 
-	TP_ARGS(wq_thread, work),
+	TP_ARGS(wq_thread, work)
+);
 
-	TP_STRUCT__entry(
-		__array(char,		thread_comm,	TASK_COMM_LEN)
-		__field(pid_t,		thread_pid)
-		__field(work_func_t,	func)
-	),
+DEFINE_EVENT(workqueue, workqueue_execution,
 
-	TP_fast_assign(
-		memcpy(__entry->thread_comm, wq_thread->comm, TASK_COMM_LEN);
-		__entry->thread_pid	= wq_thread->pid;
-		__entry->func		= work->func;
-	),
+	TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
 
-	TP_printk("thread=%s:%d func=%pf", __entry->thread_comm,
-		__entry->thread_pid, __entry->func)
+	TP_ARGS(wq_thread, work)
 );
 
 /* Trace the creation of one workqueue thread on a cpu */

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

* [tip:perf/core] tracing: Convert some power events to DEFINE_EVENT
  2009-11-26  7:05 ` [PATCH 5/9] tracing: Convert some power " Li Zefan
@ 2009-11-26  8:43   ` tip-bot for Li Zefan
  0 siblings, 0 replies; 43+ messages in thread
From: tip-bot for Li Zefan @ 2009-11-26  8:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, lizf, arjan, fweisbec, rostedt, tglx, mingo

Commit-ID:  7703466b4c0a21b88d701882bef0d45bcb0a0281
Gitweb:     http://git.kernel.org/tip/7703466b4c0a21b88d701882bef0d45bcb0a0281
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 26 Nov 2009 15:05:38 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 09:14:03 +0100

tracing: Convert some power events to DEFINE_EVENT

Use DECLARE_EVENT_CLASS to remove duplicate code:

   text    data     bss     dec     hex filename
   4312     524      12    4848    12f0 kernel/trace/power-traces.o.old
   3455     524       8    3987     f93 kernel/trace/power-traces.o

Two events are converted:

  power: power_start, power_frequency

No change in functionality.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arjan van de Ven <arjan@infradead.org>
LKML-Reference: <4B0E28C2.1090906@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/trace/events/power.h |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 9bb96e5..c4efe9b 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -16,7 +16,7 @@ enum {
 };
 #endif
 
-TRACE_EVENT(power_start,
+DECLARE_EVENT_CLASS(power,
 
 	TP_PROTO(unsigned int type, unsigned int state),
 
@@ -35,42 +35,36 @@ TRACE_EVENT(power_start,
 	TP_printk("type=%lu state=%lu", (unsigned long)__entry->type, (unsigned long)__entry->state)
 );
 
-TRACE_EVENT(power_end,
-
-	TP_PROTO(int dummy),
+DEFINE_EVENT(power, power_start,
 
-	TP_ARGS(dummy),
+	TP_PROTO(unsigned int type, unsigned int state),
 
-	TP_STRUCT__entry(
-		__field(	u64,		dummy		)
-	),
+	TP_ARGS(type, state)
+);
 
-	TP_fast_assign(
-		__entry->dummy = 0xffff;
-	),
+DEFINE_EVENT(power, power_frequency,
 
-	TP_printk("dummy=%lu", (unsigned long)__entry->dummy)
+	TP_PROTO(unsigned int type, unsigned int state),
 
+	TP_ARGS(type, state)
 );
 
+TRACE_EVENT(power_end,
 
-TRACE_EVENT(power_frequency,
-
-	TP_PROTO(unsigned int type, unsigned int state),
+	TP_PROTO(int dummy),
 
-	TP_ARGS(type, state),
+	TP_ARGS(dummy),
 
 	TP_STRUCT__entry(
-		__field(	u64,		type		)
-		__field(	u64,		state		)
+		__field(	u64,		dummy		)
 	),
 
 	TP_fast_assign(
-		__entry->type = type;
-		__entry->state = state;
+		__entry->dummy = 0xffff;
 	),
 
-	TP_printk("type=%lu state=%lu", (unsigned long)__entry->type, (unsigned long) __entry->state)
+	TP_printk("dummy=%lu", (unsigned long)__entry->dummy)
+
 );
 
 #endif /* _TRACE_POWER_H */

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

* [tip:perf/core] tracing: Convert some block events to DEFINE_EVENT
  2009-11-26  7:06 ` [PATCH 6/9] tracing: Convert some block " Li Zefan
  2009-11-26  8:36   ` Jens Axboe
@ 2009-11-26  8:43   ` tip-bot for Li Zefan
  1 sibling, 0 replies; 43+ messages in thread
From: tip-bot for Li Zefan @ 2009-11-26  8:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, lizf, jens.axboe, fweisbec, rostedt,
	tglx, mingo

Commit-ID:  77ca1e0294f25fc26053ba14353e703158acef26
Gitweb:     http://git.kernel.org/tip/77ca1e0294f25fc26053ba14353e703158acef26
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 26 Nov 2009 15:06:14 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 09:14:04 +0100

tracing: Convert some block events to DEFINE_EVENT

use DECLARE_EVENT_CLASS to remove duplicate code:

   text    data     bss     dec     hex filename
  53570    3284     184   57038    dece block/blk-core.o.old
  43702    3284     144   47130    b81a block/blk-core.o

12 events are converted:

  block_rq: block_rq_insert, block_rq_issue
  block_rq_with_error: block_rq_{abort, requeue, complete}
  block_bio: block_bio_{backmerge, frontmerge, queue}
  block_get_rq: block_getrq, block_sleeprq
  block_unplug: block_unplug_timer, block_unplug_io

No change in functionality.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4B0E28E6.7060609@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/trace/events/block.h |  202 +++++++++---------------------------------
 1 files changed, 42 insertions(+), 160 deletions(-)

diff --git a/include/trace/events/block.h b/include/trace/events/block.h
index 00405b5..5fb7273 100644
--- a/include/trace/events/block.h
+++ b/include/trace/events/block.h
@@ -8,7 +8,7 @@
 #include <linux/blkdev.h>
 #include <linux/tracepoint.h>
 
-TRACE_EVENT(block_rq_abort,
+DECLARE_EVENT_CLASS(block_rq_with_error,
 
 	TP_PROTO(struct request_queue *q, struct request *rq),
 
@@ -40,41 +40,28 @@ TRACE_EVENT(block_rq_abort,
 		  __entry->nr_sector, __entry->errors)
 );
 
-TRACE_EVENT(block_rq_insert,
+DEFINE_EVENT(block_rq_with_error, block_rq_abort,
 
 	TP_PROTO(struct request_queue *q, struct request *rq),
 
-	TP_ARGS(q, rq),
+	TP_ARGS(q, rq)
+);
 
-	TP_STRUCT__entry(
-		__field(  dev_t,	dev			)
-		__field(  sector_t,	sector			)
-		__field(  unsigned int,	nr_sector		)
-		__field(  unsigned int,	bytes			)
-		__array(  char,		rwbs,	6		)
-		__array(  char,         comm,   TASK_COMM_LEN   )
-		__dynamic_array( char,	cmd,	blk_cmd_buf_len(rq)	)
-	),
+DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
 
-	TP_fast_assign(
-		__entry->dev	   = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
-		__entry->sector    = blk_pc_request(rq) ? 0 : blk_rq_pos(rq);
-		__entry->nr_sector = blk_pc_request(rq) ? 0 : blk_rq_sectors(rq);
-		__entry->bytes     = blk_pc_request(rq) ? blk_rq_bytes(rq) : 0;
+	TP_PROTO(struct request_queue *q, struct request *rq),
 
-		blk_fill_rwbs_rq(__entry->rwbs, rq);
-		blk_dump_cmd(__get_str(cmd), rq);
-		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
-	),
+	TP_ARGS(q, rq)
+);
 
-	TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
-		  MAJOR(__entry->dev), MINOR(__entry->dev),
-		  __entry->rwbs, __entry->bytes, __get_str(cmd),
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->comm)
+DEFINE_EVENT(block_rq_with_error, block_rq_complete,
+
+	TP_PROTO(struct request_queue *q, struct request *rq),
+
+	TP_ARGS(q, rq)
 );
 
-TRACE_EVENT(block_rq_issue,
+DECLARE_EVENT_CLASS(block_rq,
 
 	TP_PROTO(struct request_queue *q, struct request *rq),
 
@@ -86,7 +73,7 @@ TRACE_EVENT(block_rq_issue,
 		__field(  unsigned int,	nr_sector		)
 		__field(  unsigned int,	bytes			)
 		__array(  char,		rwbs,	6		)
-		__array(  char,		comm,   TASK_COMM_LEN   )
+		__array(  char,         comm,   TASK_COMM_LEN   )
 		__dynamic_array( char,	cmd,	blk_cmd_buf_len(rq)	)
 	),
 
@@ -108,68 +95,18 @@ TRACE_EVENT(block_rq_issue,
 		  __entry->nr_sector, __entry->comm)
 );
 
-TRACE_EVENT(block_rq_requeue,
+DEFINE_EVENT(block_rq, block_rq_insert,
 
 	TP_PROTO(struct request_queue *q, struct request *rq),
 
-	TP_ARGS(q, rq),
-
-	TP_STRUCT__entry(
-		__field(  dev_t,	dev			)
-		__field(  sector_t,	sector			)
-		__field(  unsigned int,	nr_sector		)
-		__field(  int,		errors			)
-		__array(  char,		rwbs,	6		)
-		__dynamic_array( char,	cmd,	blk_cmd_buf_len(rq)	)
-	),
-
-	TP_fast_assign(
-		__entry->dev	   = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
-		__entry->sector    = blk_pc_request(rq) ? 0 : blk_rq_pos(rq);
-		__entry->nr_sector = blk_pc_request(rq) ? 0 : blk_rq_sectors(rq);
-		__entry->errors	   = rq->errors;
-
-		blk_fill_rwbs_rq(__entry->rwbs, rq);
-		blk_dump_cmd(__get_str(cmd), rq);
-	),
-
-	TP_printk("%d,%d %s (%s) %llu + %u [%d]",
-		  MAJOR(__entry->dev), MINOR(__entry->dev),
-		  __entry->rwbs, __get_str(cmd),
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->errors)
+	TP_ARGS(q, rq)
 );
 
-TRACE_EVENT(block_rq_complete,
+DEFINE_EVENT(block_rq, block_rq_issue,
 
 	TP_PROTO(struct request_queue *q, struct request *rq),
 
-	TP_ARGS(q, rq),
-
-	TP_STRUCT__entry(
-		__field(  dev_t,	dev			)
-		__field(  sector_t,	sector			)
-		__field(  unsigned int,	nr_sector		)
-		__field(  int,		errors			)
-		__array(  char,		rwbs,	6		)
-		__dynamic_array( char,	cmd,	blk_cmd_buf_len(rq)	)
-	),
-
-	TP_fast_assign(
-		__entry->dev	   = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
-		__entry->sector    = blk_pc_request(rq) ? 0 : blk_rq_pos(rq);
-		__entry->nr_sector = blk_pc_request(rq) ? 0 : blk_rq_sectors(rq);
-		__entry->errors    = rq->errors;
-
-		blk_fill_rwbs_rq(__entry->rwbs, rq);
-		blk_dump_cmd(__get_str(cmd), rq);
-	),
-
-	TP_printk("%d,%d %s (%s) %llu + %u [%d]",
-		  MAJOR(__entry->dev), MINOR(__entry->dev),
-		  __entry->rwbs, __get_str(cmd),
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->errors)
+	TP_ARGS(q, rq)
 );
 
 TRACE_EVENT(block_bio_bounce,
@@ -228,7 +165,7 @@ TRACE_EVENT(block_bio_complete,
 		  __entry->nr_sector, __entry->error)
 );
 
-TRACE_EVENT(block_bio_backmerge,
+DECLARE_EVENT_CLASS(block_bio,
 
 	TP_PROTO(struct request_queue *q, struct bio *bio),
 
@@ -256,63 +193,28 @@ TRACE_EVENT(block_bio_backmerge,
 		  __entry->nr_sector, __entry->comm)
 );
 
-TRACE_EVENT(block_bio_frontmerge,
+DEFINE_EVENT(block_bio, block_bio_backmerge,
 
 	TP_PROTO(struct request_queue *q, struct bio *bio),
 
-	TP_ARGS(q, bio),
-
-	TP_STRUCT__entry(
-		__field( dev_t,		dev			)
-		__field( sector_t,	sector			)
-		__field( unsigned,	nr_sector		)
-		__array( char,		rwbs,	6		)
-		__array( char,		comm,	TASK_COMM_LEN	)
-	),
-
-	TP_fast_assign(
-		__entry->dev		= bio->bi_bdev->bd_dev;
-		__entry->sector		= bio->bi_sector;
-		__entry->nr_sector	= bio->bi_size >> 9;
-		blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
-		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
-	),
-
-	TP_printk("%d,%d %s %llu + %u [%s]",
-		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->comm)
+	TP_ARGS(q, bio)
 );
 
-TRACE_EVENT(block_bio_queue,
+DEFINE_EVENT(block_bio, block_bio_frontmerge,
 
 	TP_PROTO(struct request_queue *q, struct bio *bio),
 
-	TP_ARGS(q, bio),
+	TP_ARGS(q, bio)
+);
 
-	TP_STRUCT__entry(
-		__field( dev_t,		dev			)
-		__field( sector_t,	sector			)
-		__field( unsigned int,	nr_sector		)
-		__array( char,		rwbs,	6		)
-		__array( char,		comm,	TASK_COMM_LEN	)
-	),
+DEFINE_EVENT(block_bio, block_bio_queue,
 
-	TP_fast_assign(
-		__entry->dev		= bio->bi_bdev->bd_dev;
-		__entry->sector		= bio->bi_sector;
-		__entry->nr_sector	= bio->bi_size >> 9;
-		blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
-		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
-	),
+	TP_PROTO(struct request_queue *q, struct bio *bio),
 
-	TP_printk("%d,%d %s %llu + %u [%s]",
-		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->comm)
+	TP_ARGS(q, bio)
 );
 
-TRACE_EVENT(block_getrq,
+DECLARE_EVENT_CLASS(block_get_rq,
 
 	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
 
@@ -341,33 +243,18 @@ TRACE_EVENT(block_getrq,
 		  __entry->nr_sector, __entry->comm)
 );
 
-TRACE_EVENT(block_sleeprq,
+DEFINE_EVENT(block_get_rq, block_getrq,
 
 	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
 
-	TP_ARGS(q, bio, rw),
+	TP_ARGS(q, bio, rw)
+);
 
-	TP_STRUCT__entry(
-		__field( dev_t,		dev			)
-		__field( sector_t,	sector			)
-		__field( unsigned int,	nr_sector		)
-		__array( char,		rwbs,	6		)
-		__array( char,		comm,	TASK_COMM_LEN	)
-	),
+DEFINE_EVENT(block_get_rq, block_sleeprq,
 
-	TP_fast_assign(
-		__entry->dev		= bio ? bio->bi_bdev->bd_dev : 0;
-		__entry->sector		= bio ? bio->bi_sector : 0;
-		__entry->nr_sector	= bio ? bio->bi_size >> 9 : 0;
-		blk_fill_rwbs(__entry->rwbs,
-			    bio ? bio->bi_rw : 0, __entry->nr_sector);
-		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
-	),
+	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
 
-	TP_printk("%d,%d %s %llu + %u [%s]",
-		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->comm)
+	TP_ARGS(q, bio, rw)
 );
 
 TRACE_EVENT(block_plug,
@@ -387,7 +274,7 @@ TRACE_EVENT(block_plug,
 	TP_printk("[%s]", __entry->comm)
 );
 
-TRACE_EVENT(block_unplug_timer,
+DECLARE_EVENT_CLASS(block_unplug,
 
 	TP_PROTO(struct request_queue *q),
 
@@ -406,23 +293,18 @@ TRACE_EVENT(block_unplug_timer,
 	TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
 );
 
-TRACE_EVENT(block_unplug_io,
+DEFINE_EVENT(block_unplug, block_unplug_timer,
 
 	TP_PROTO(struct request_queue *q),
 
-	TP_ARGS(q),
+	TP_ARGS(q)
+);
 
-	TP_STRUCT__entry(
-		__field( int,		nr_rq			)
-		__array( char,		comm,	TASK_COMM_LEN	)
-	),
+DEFINE_EVENT(block_unplug, block_unplug_io,
 
-	TP_fast_assign(
-		__entry->nr_rq	= q->rq.count[READ] + q->rq.count[WRITE];
-		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
-	),
+	TP_PROTO(struct request_queue *q),
 
-	TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
+	TP_ARGS(q)
 );
 
 TRACE_EVENT(block_split,

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

* [tip:perf/core] tracing: Convert some jbd2 events to DEFINE_EVENT
  2009-11-26  7:06 ` [PATCH 7/9] tracing: Convert some jbd2 " Li Zefan
@ 2009-11-26  8:44   ` tip-bot for Li Zefan
  0 siblings, 0 replies; 43+ messages in thread
From: tip-bot for Li Zefan @ 2009-11-26  8:44 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, lizf, tytso, fweisbec, rostedt, tglx, mingo

Commit-ID:  071688f36e7eba3e37b2fc48e35bfdab99b80b4d
Gitweb:     http://git.kernel.org/tip/071688f36e7eba3e37b2fc48e35bfdab99b80b4d
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 26 Nov 2009 15:06:55 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 09:14:04 +0100

tracing: Convert some jbd2 events to DEFINE_EVENT

Use DECLARE_EVENT_CLASS to remove duplicate code:

   text    data     bss     dec     hex filename
  34903    1693     448   37044    90b4 fs/jbd2/journal.o.old
  31931    1693     416   34040    84f8 fs/jbd2/journal.o

Four events are converted:

  jbd2_commit: jbd2_start_commit,
               jbd2_commit_{locking, flushing, logging}

No change in functionality.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4B0E290F.7030909@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/trace/events/jbd2.h |   63 +++++++-----------------------------------
 1 files changed, 11 insertions(+), 52 deletions(-)

diff --git a/include/trace/events/jbd2.h b/include/trace/events/jbd2.h
index 3c60b75..96b370a 100644
--- a/include/trace/events/jbd2.h
+++ b/include/trace/events/jbd2.h
@@ -30,7 +30,7 @@ TRACE_EVENT(jbd2_checkpoint,
 		  jbd2_dev_to_name(__entry->dev), __entry->result)
 );
 
-TRACE_EVENT(jbd2_start_commit,
+DECLARE_EVENT_CLASS(jbd2_commit,
 
 	TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
 
@@ -53,73 +53,32 @@ TRACE_EVENT(jbd2_start_commit,
 		  __entry->sync_commit)
 );
 
-TRACE_EVENT(jbd2_commit_locking,
+DEFINE_EVENT(jbd2_commit, jbd2_start_commit,
 
 	TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
 
-	TP_ARGS(journal, commit_transaction),
-
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	char,	sync_commit		  )
-		__field(	int,	transaction		  )
-	),
-
-	TP_fast_assign(
-		__entry->dev		= journal->j_fs_dev->bd_dev;
-		__entry->sync_commit = commit_transaction->t_synchronous_commit;
-		__entry->transaction	= commit_transaction->t_tid;
-	),
-
-	TP_printk("dev %s transaction %d sync %d",
-		  jbd2_dev_to_name(__entry->dev), __entry->transaction,
-		  __entry->sync_commit)
+	TP_ARGS(journal, commit_transaction)
 );
 
-TRACE_EVENT(jbd2_commit_flushing,
+DEFINE_EVENT(jbd2_commit, jbd2_commit_locking,
 
 	TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
 
-	TP_ARGS(journal, commit_transaction),
-
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	char,	sync_commit		  )
-		__field(	int,	transaction		  )
-	),
-
-	TP_fast_assign(
-		__entry->dev		= journal->j_fs_dev->bd_dev;
-		__entry->sync_commit = commit_transaction->t_synchronous_commit;
-		__entry->transaction	= commit_transaction->t_tid;
-	),
-
-	TP_printk("dev %s transaction %d sync %d",
-		  jbd2_dev_to_name(__entry->dev), __entry->transaction,
-		  __entry->sync_commit)
+	TP_ARGS(journal, commit_transaction)
 );
 
-TRACE_EVENT(jbd2_commit_logging,
+DEFINE_EVENT(jbd2_commit, jbd2_commit_flushing,
 
 	TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
 
-	TP_ARGS(journal, commit_transaction),
+	TP_ARGS(journal, commit_transaction)
+);
 
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	char,	sync_commit		  )
-		__field(	int,	transaction		  )
-	),
+DEFINE_EVENT(jbd2_commit, jbd2_commit_logging,
 
-	TP_fast_assign(
-		__entry->dev		= journal->j_fs_dev->bd_dev;
-		__entry->sync_commit = commit_transaction->t_synchronous_commit;
-		__entry->transaction	= commit_transaction->t_tid;
-	),
+	TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
 
-	TP_printk("dev %s transaction %d sync %d",
-		  jbd2_dev_to_name(__entry->dev), __entry->transaction,
-		  __entry->sync_commit)
+	TP_ARGS(journal, commit_transaction)
 );
 
 TRACE_EVENT(jbd2_end_commit,

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

* [tip:perf/core] tracing: Convert some ext4 events to DEFINE_TRACE
  2009-11-26  7:07 ` [PATCH 8/9] tracing: Convert some ext4 events to DEFINE_TRACE Li Zefan
@ 2009-11-26  8:44   ` tip-bot for Li Zefan
  0 siblings, 0 replies; 43+ messages in thread
From: tip-bot for Li Zefan @ 2009-11-26  8:44 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, lizf, tytso, fweisbec, rostedt, tglx, mingo

Commit-ID:  b5eb34c3592545c756e50d882c08417eb60740a7
Gitweb:     http://git.kernel.org/tip/b5eb34c3592545c756e50d882c08417eb60740a7
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 26 Nov 2009 15:07:36 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 09:14:05 +0100

tracing: Convert some ext4 events to DEFINE_TRACE

Use DECLARE_EVENT_CLASS to remove duplicate code:

   text    data     bss     dec     hex filename
 294695    6104     340  301139   49853 fs/ext4/ext4.o.old
 289983    6104     324  296411   485db fs/ext4/ext4.o

5 events are convertd:

  ext4__write_begin: ext4_write_begin, ext4_da_write_begin
  ext4__write_end: ext4_{ordered, writeback, journalled}_write_end

No change in functionality.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4B0E2938.2040708@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/trace/events/ext4.h |  129 ++++++++++++-------------------------------
 1 files changed, 35 insertions(+), 94 deletions(-)

diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index d09550b..318f765 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -90,7 +90,7 @@ TRACE_EVENT(ext4_allocate_inode,
 		  (unsigned long) __entry->dir, __entry->mode)
 );
 
-TRACE_EVENT(ext4_write_begin,
+DECLARE_EVENT_CLASS(ext4__write_begin,
 
 	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
 		 unsigned int flags),
@@ -118,7 +118,23 @@ TRACE_EVENT(ext4_write_begin,
 		  __entry->pos, __entry->len, __entry->flags)
 );
 
-TRACE_EVENT(ext4_ordered_write_end,
+DEFINE_EVENT(ext4__write_begin, ext4_write_begin,
+
+	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+		 unsigned int flags),
+
+	TP_ARGS(inode, pos, len, flags)
+);
+
+DEFINE_EVENT(ext4__write_begin, ext4_da_write_begin,
+
+	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+		 unsigned int flags),
+
+	TP_ARGS(inode, pos, len, flags)
+);
+
+DECLARE_EVENT_CLASS(ext4__write_end,
 	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
 			unsigned int copied),
 
@@ -145,57 +161,36 @@ TRACE_EVENT(ext4_ordered_write_end,
 		  __entry->pos, __entry->len, __entry->copied)
 );
 
-TRACE_EVENT(ext4_writeback_write_end,
+DEFINE_EVENT(ext4__write_end, ext4_ordered_write_end,
+
 	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
 		 unsigned int copied),
 
-	TP_ARGS(inode, pos, len, copied),
+	TP_ARGS(inode, pos, len, copied)
+);
 
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	ino_t,	ino			)
-		__field(	loff_t,	pos			)
-		__field(	unsigned int, len		)
-		__field(	unsigned int, copied		)
-	),
+DEFINE_EVENT(ext4__write_end, ext4_writeback_write_end,
 
-	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
-		__entry->ino	= inode->i_ino;
-		__entry->pos	= pos;
-		__entry->len	= len;
-		__entry->copied	= copied;
-	),
+	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+		 unsigned int copied),
 
-	TP_printk("dev %s ino %lu pos %llu len %u copied %u",
-		  jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino,
-		  __entry->pos, __entry->len, __entry->copied)
+	TP_ARGS(inode, pos, len, copied)
 );
 
-TRACE_EVENT(ext4_journalled_write_end,
+DEFINE_EVENT(ext4__write_end, ext4_journalled_write_end,
+
 	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
 		 unsigned int copied),
-	TP_ARGS(inode, pos, len, copied),
 
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	ino_t,	ino			)
-		__field(	loff_t,	pos			)
-		__field(	unsigned int, len		)
-		__field(	unsigned int, copied		)
-	),
+	TP_ARGS(inode, pos, len, copied)
+);
 
-	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
-		__entry->ino	= inode->i_ino;
-		__entry->pos	= pos;
-		__entry->len	= len;
-		__entry->copied	= copied;
-	),
+DEFINE_EVENT(ext4__write_end, ext4_da_write_end,
 
-	TP_printk("dev %s ino %lu pos %llu len %u copied %u",
-		  jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino,
-		  __entry->pos, __entry->len, __entry->copied)
+	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+		 unsigned int copied),
+
+	TP_ARGS(inode, pos, len, copied)
 );
 
 TRACE_EVENT(ext4_writepage,
@@ -337,60 +332,6 @@ TRACE_EVENT(ext4_da_writepages_result,
 		  (unsigned long) __entry->writeback_index)
 );
 
-TRACE_EVENT(ext4_da_write_begin,
-	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
-			unsigned int flags),
-
-	TP_ARGS(inode, pos, len, flags),
-
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	ino_t,	ino			)
-		__field(	loff_t,	pos			)
-		__field(	unsigned int, len		)
-		__field(	unsigned int, flags		)
-	),
-
-	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
-		__entry->ino	= inode->i_ino;
-		__entry->pos	= pos;
-		__entry->len	= len;
-		__entry->flags	= flags;
-	),
-
-	TP_printk("dev %s ino %lu pos %llu len %u flags %u",
-		  jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino,
-		  __entry->pos, __entry->len, __entry->flags)
-);
-
-TRACE_EVENT(ext4_da_write_end,
-	TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
-			unsigned int copied),
-
-	TP_ARGS(inode, pos, len, copied),
-
-	TP_STRUCT__entry(
-		__field(	dev_t,	dev			)
-		__field(	ino_t,	ino			)
-		__field(	loff_t,	pos			)
-		__field(	unsigned int, len		)
-		__field(	unsigned int, copied		)
-	),
-
-	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
-		__entry->ino	= inode->i_ino;
-		__entry->pos	= pos;
-		__entry->len	= len;
-		__entry->copied	= copied;
-	),
-
-	TP_printk("dev %s ino %lu pos %llu len %u copied %u",
-		  jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino,
-		  __entry->pos, __entry->len, __entry->copied)
-);
-
 TRACE_EVENT(ext4_discard_blocks,
 	TP_PROTO(struct super_block *sb, unsigned long long blk,
 			unsigned long long count),

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

* [tip:perf/core] tracing: Restore original format of sched events
  2009-11-26  7:08 ` [PATCH 9/9] tracing: Restore original format of sched events Li Zefan
@ 2009-11-26  8:44   ` tip-bot for Li Zefan
  0 siblings, 0 replies; 43+ messages in thread
From: tip-bot for Li Zefan @ 2009-11-26  8:44 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, fweisbec, rostedt, lizf, tglx, mingo

Commit-ID:  470dda7417f284b9cfc96560b2acd98df63798a2
Gitweb:     http://git.kernel.org/tip/470dda7417f284b9cfc96560b2acd98df63798a2
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 26 Nov 2009 15:08:01 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 09:14:05 +0100

tracing: Restore original format of sched events

The original format for sched_stat_iowait and sched_stat_sleep:

  $ cat events/sched/sched_stat_iowait/format
  ...
  print fmt: "comm=%s pid=%d delay=%Lu [ns]", ...
  $ cat events/sched/sched_stat_sleep/format
  ...
  print fmt: "comm=%s pid=%d delay=%Lu [ns]", ...

But commit commit 75ec29ab848a7e92a41aaafaeb33d1afbc839be4
("tracing: Convert some sched trace events to DEFINE_EVENT and
_PRINT") broke the format:

  $ cat events/sched/sched_stat_iowait/format
  print fmt: "task: %s:%d iowait: %Lu [ns]", ...
  $ cat events/sched/sched_stat_sleep/format
  print fmt: "task: %s:%d sleep: %Lu [ns]", ...

No change in functionality.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4B0E2951.9050800@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/trace/events/sched.h |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 5ce7950..9d316b2 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -355,23 +355,17 @@ DEFINE_EVENT(sched_stat_template, sched_stat_wait,
  * Tracepoint for accounting sleep time (time the task is not runnable,
  * including iowait, see below).
  */
-DEFINE_EVENT_PRINT(sched_stat_template, sched_stat_sleep,
-		   TP_PROTO(struct task_struct *tsk, u64 delay),
-		   TP_ARGS(tsk, delay),
-		   TP_printk("task: %s:%d sleep: %Lu [ns]",
-			     __entry->comm, __entry->pid,
-			     (unsigned long long)__entry->delay));
+DEFINE_EVENT(sched_stat_template, sched_stat_sleep,
+	     TP_PROTO(struct task_struct *tsk, u64 delay),
+	     TP_ARGS(tsk, delay));
 
 /*
  * Tracepoint for accounting iowait time (time the task is not runnable
  * due to waiting on IO to complete).
  */
-DEFINE_EVENT_PRINT(sched_stat_template, sched_stat_iowait,
-		   TP_PROTO(struct task_struct *tsk, u64 delay),
-		   TP_ARGS(tsk, delay),
-		   TP_printk("task: %s:%d iowait: %Lu [ns]",
-			     __entry->comm, __entry->pid,
-			     (unsigned long long)__entry->delay));
+DEFINE_EVENT(sched_stat_template, sched_stat_iowait,
+	     TP_PROTO(struct task_struct *tsk, u64 delay),
+	     TP_ARGS(tsk, delay));
 
 /*
  * Tracepoint for accounting runtime (time the task is executing

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

* Re: [PATCH 6/9] tracing: Convert some block events to DEFINE_EVENT
  2009-11-26  8:36   ` Jens Axboe
@ 2009-11-26  8:44     ` Ingo Molnar
  2009-11-26  8:47       ` Jens Axboe
  0 siblings, 1 reply; 43+ messages in thread
From: Ingo Molnar @ 2009-11-26  8:44 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Li Zefan, Steven Rostedt, Frederic Weisbecker, LKML


* Jens Axboe <jens.axboe@oracle.com> wrote:

> On Thu, Nov 26 2009, Li Zefan wrote:
> > use TRACE_EVENT_TEMPLATE to remove duplicate code:
> > 
> >    text    data     bss     dec     hex filename
> >   53570    3284     184   57038    dece block/blk-core.o.old
> >   43702    3284     144   47130    b81a block/blk-core.o
> 
> Nice! When I played with the writeback tracing, I did notice that code
> bloat does get pretty severe quickly.
> 
> I have applied this to for-2.6.33, thanks a lot.

Note that it wont build in your tree, because the TRACE_EVENT_TEMPLATE / 
DEFINE_EVENT facility this relies on is not upstream yet.

The events are not affected in any way (and block/* is not modified) - 
it's just a more efficient representation of the same. I've applied them 
to -tip, to keep the facility and dependent updates in a single place.

	Ingo

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

* Re: [PATCH 6/9] tracing: Convert some block events to DEFINE_EVENT
  2009-11-26  8:44     ` Ingo Molnar
@ 2009-11-26  8:47       ` Jens Axboe
  2009-11-26  8:50         ` Ingo Molnar
  0 siblings, 1 reply; 43+ messages in thread
From: Jens Axboe @ 2009-11-26  8:47 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Li Zefan, Steven Rostedt, Frederic Weisbecker, LKML

On Thu, Nov 26 2009, Ingo Molnar wrote:
> 
> * Jens Axboe <jens.axboe@oracle.com> wrote:
> 
> > On Thu, Nov 26 2009, Li Zefan wrote:
> > > use TRACE_EVENT_TEMPLATE to remove duplicate code:
> > > 
> > >    text    data     bss     dec     hex filename
> > >   53570    3284     184   57038    dece block/blk-core.o.old
> > >   43702    3284     144   47130    b81a block/blk-core.o
> > 
> > Nice! When I played with the writeback tracing, I did notice that code
> > bloat does get pretty severe quickly.
> > 
> > I have applied this to for-2.6.33, thanks a lot.
> 
> Note that it wont build in your tree, because the TRACE_EVENT_TEMPLATE / 
> DEFINE_EVENT facility this relies on is not upstream yet.
> 
> The events are not affected in any way (and block/* is not modified) - 
> it's just a more efficient representation of the same. I've applied them 
> to -tip, to keep the facility and dependent updates in a single place.

OK, lets merge them through -tip then. You can add my acked-by.

-- 
Jens Axboe


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

* Re: [PATCH 6/9] tracing: Convert some block events to DEFINE_EVENT
  2009-11-26  8:47       ` Jens Axboe
@ 2009-11-26  8:50         ` Ingo Molnar
  2009-11-26  8:52           ` Jens Axboe
  0 siblings, 1 reply; 43+ messages in thread
From: Ingo Molnar @ 2009-11-26  8:50 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Li Zefan, Steven Rostedt, Frederic Weisbecker, LKML


* Jens Axboe <jens.axboe@oracle.com> wrote:

> On Thu, Nov 26 2009, Ingo Molnar wrote:
> > 
> > * Jens Axboe <jens.axboe@oracle.com> wrote:
> > 
> > > On Thu, Nov 26 2009, Li Zefan wrote:
> > > > use TRACE_EVENT_TEMPLATE to remove duplicate code:
> > > > 
> > > >    text    data     bss     dec     hex filename
> > > >   53570    3284     184   57038    dece block/blk-core.o.old
> > > >   43702    3284     144   47130    b81a block/blk-core.o
> > > 
> > > Nice! When I played with the writeback tracing, I did notice that code
> > > bloat does get pretty severe quickly.
> > > 
> > > I have applied this to for-2.6.33, thanks a lot.
> > 
> > Note that it wont build in your tree, because the TRACE_EVENT_TEMPLATE / 
> > DEFINE_EVENT facility this relies on is not upstream yet.
> > 
> > The events are not affected in any way (and block/* is not modified) - 
> > it's just a more efficient representation of the same. I've applied them 
> > to -tip, to keep the facility and dependent updates in a single place.
> 
> OK, lets merge them through -tip then. You can add my acked-by.

Thanks Jens!

Do you have any pending (or planned) changes to 
include/trace/events/block.h in the block tree that might cause 
problems?

We can pick those up too (and resolve any conflicts) to reduce the 
surface of friction.

Thanks,

	Ingo

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

* Re: [PATCH 6/9] tracing: Convert some block events to DEFINE_EVENT
  2009-11-26  8:50         ` Ingo Molnar
@ 2009-11-26  8:52           ` Jens Axboe
  0 siblings, 0 replies; 43+ messages in thread
From: Jens Axboe @ 2009-11-26  8:52 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Li Zefan, Steven Rostedt, Frederic Weisbecker, LKML

On Thu, Nov 26 2009, Ingo Molnar wrote:
> 
> * Jens Axboe <jens.axboe@oracle.com> wrote:
> 
> > On Thu, Nov 26 2009, Ingo Molnar wrote:
> > > 
> > > * Jens Axboe <jens.axboe@oracle.com> wrote:
> > > 
> > > > On Thu, Nov 26 2009, Li Zefan wrote:
> > > > > use TRACE_EVENT_TEMPLATE to remove duplicate code:
> > > > > 
> > > > >    text    data     bss     dec     hex filename
> > > > >   53570    3284     184   57038    dece block/blk-core.o.old
> > > > >   43702    3284     144   47130    b81a block/blk-core.o
> > > > 
> > > > Nice! When I played with the writeback tracing, I did notice that code
> > > > bloat does get pretty severe quickly.
> > > > 
> > > > I have applied this to for-2.6.33, thanks a lot.
> > > 
> > > Note that it wont build in your tree, because the TRACE_EVENT_TEMPLATE / 
> > > DEFINE_EVENT facility this relies on is not upstream yet.
> > > 
> > > The events are not affected in any way (and block/* is not modified) - 
> > > it's just a more efficient representation of the same. I've applied them 
> > > to -tip, to keep the facility and dependent updates in a single place.
> > 
> > OK, lets merge them through -tip then. You can add my acked-by.
> 
> Thanks Jens!
> 
> Do you have any pending (or planned) changes to 
> include/trace/events/block.h in the block tree that might cause 
> problems?
> 
> We can pick those up too (and resolve any conflicts) to reduce the 
> surface of friction.

Nope, I don't have any block tracing bits pending for 2.6.33, so we wont
have merge issues there.

-- 
Jens Axboe


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

* [tip:perf/core] tracing: Fix kmem event exports
  2009-11-26  7:04 ` [PATCH 2/9] tracing: Convert some kmem " Li Zefan
                     ` (2 preceding siblings ...)
  2009-11-26  8:42   ` [tip:perf/core] tracing: Convert some kmem events to DEFINE_EVENT tip-bot for Li Zefan
@ 2009-11-26 12:34   ` tip-bot for Ingo Molnar
  3 siblings, 0 replies; 43+ messages in thread
From: tip-bot for Ingo Molnar @ 2009-11-26 12:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, penberg, lizf, mel, fweisbec, rostedt,
	tglx, mingo

Commit-ID:  4d795fb17a02a87e35782773b88b7a63acfbeaae
Gitweb:     http://git.kernel.org/tip/4d795fb17a02a87e35782773b88b7a63acfbeaae
Author:     Ingo Molnar <mingo@elte.hu>
AuthorDate: Thu, 26 Nov 2009 13:11:46 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 13:17:43 +0100

tracing: Fix kmem event exports

Commit 53d0422 ("tracing: Convert some kmem events to DEFINE_EVENT")
moved the kmem tracepoint creation from util.c to page_alloc.c,
but forgot to move the exports.

Move them back.

Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mel Gorman <mel@csn.ul.ie>
LKML-Reference: <4B0E286A.2000405@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 mm/page_alloc.c |    4 +---
 mm/util.c       |    3 +++
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index bdb22f5..2bc2ac6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -48,14 +48,12 @@
 #include <linux/page_cgroup.h>
 #include <linux/debugobjects.h>
 #include <linux/kmemleak.h>
+#include <trace/events/kmem.h>
 
 #include <asm/tlbflush.h>
 #include <asm/div64.h>
 #include "internal.h"
 
-#define CREATE_TRACE_POINTS
-#include <trace/events/kmem.h>
-
 /*
  * Array of node states.
  */
diff --git a/mm/util.c b/mm/util.c
index 15d1975..7c35ad9 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -6,6 +6,9 @@
 #include <linux/sched.h>
 #include <asm/uaccess.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/kmem.h>
+
 /**
  * kstrdup - allocate space for and copy an existing string
  * @s: the string to duplicate

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

* Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
  2009-11-26  8:40       ` Ingo Molnar
@ 2009-11-26 14:45         ` Steven Rostedt
  2009-11-26 17:55           ` Frederic Weisbecker
  0 siblings, 1 reply; 43+ messages in thread
From: Steven Rostedt @ 2009-11-26 14:45 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: mingo, hpa, linux-kernel, fweisbec, penberg, tglx, linux-tip-commits

On Thu, 2009-11-26 at 09:40 +0100, Ingo Molnar wrote:
> * Steven Rostedt <rostedt@goodmis.org> wrote:
> 

> > I would like to hear what others think about this change before we go 
> > ahead and implement it.
> 
> You mean TRACE_EVENT() -> DEFINE_SINGLE_EVENT()? Sure, we want todo it 
> in a more quiet moment of the kernel cycle, not now.
> 
> (TRACE_EVENT_TEMPLATE OTOH has existed for just a few days so it's not a 
> problem.)

Yes the template name is new, I'm not talking about that on
particularly.

> 
> > A lot of developers have just learned about TRACE_EVENT and now it 
> > just disappeared. Well, not really, but in the sense of ' find 
> > linux.git -name '*.[ch]' | xargs grep TRACE_EVENT' it no longer 
> > exists.
> 
> A second problem with the TRACE_EVENT name is that it's not just for 
> tracing - we dont necessarily 'trace' events here. We can use the event 
> callbacks to collect pure counts:

Then we might as well rename the "trace_*" all over the kernel.

> 
> | aldebaran> perf stat -e sched:sched_wakeup ./hackbench 10
> | Time: 0.093
> |
> |  Performance counter stats for './hackbench 10':
> |
> |           15481  sched:sched_wakeup      
> |
> |     0.107390574  seconds time elapsed
> 
> etc.

Right, because it hooked into a trace_point.

> 
> A third problem is that the name 'TRACE_EVENT' does not tell us what is 
> being done. Do we declare it? Do we also define it?

That's exactly the point. It does both. I actually tried to avoid the
"DEFINE/DECLARE" because it becomes confusing to what it does. The
TRACE_EVENT macros are obviously unique in the kernel. There are
"DECLARE_*" and "DEFINE_*" all over the kernel. And they have an obvious
meaning. DECLARE_* is used to set up a declaration for a header.
DEFINE_* creates the instance.  But TRACE_EVENT will default declare
event, but when CREATE_TRACE_POINTS is set, it defines the instances. Oh
we should rename that to CREATE_EVENTS?

> 
> DEFINE_SINGLE_EVENT() solves all these problems:
> 
>  - It's obvious what it does
> 
>  - It suggests users of it that there's another non-single-event 
>    facility, gently nudging them towards the use of the more efficient
>    DEFINE_EVENT_CLASS() + DEFINE_EVENT() method.
> 
>  - It fits nicely into the rest of the naming scheme.

Like I said earlier, I'm not really attached to the name. Except that
there's already a lot of documentation (I've given tutorials about it)
using the TRACE_EVENT name. But who am I to decide?

-- Steve



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

* Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
  2009-11-26 14:45         ` Steven Rostedt
@ 2009-11-26 17:55           ` Frederic Weisbecker
  2009-11-26 18:12             ` Ingo Molnar
  0 siblings, 1 reply; 43+ messages in thread
From: Frederic Weisbecker @ 2009-11-26 17:55 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Ingo Molnar, mingo, hpa, linux-kernel, penberg, tglx, linux-tip-commits

On Thu, Nov 26, 2009 at 09:45:30AM -0500, Steven Rostedt wrote:
> On Thu, 2009-11-26 at 09:40 +0100, Ingo Molnar wrote:
> > * Steven Rostedt <rostedt@goodmis.org> wrote:
> > 
> 
> > > I would like to hear what others think about this change before we go 
> > > ahead and implement it.
> > 
> > You mean TRACE_EVENT() -> DEFINE_SINGLE_EVENT()? Sure, we want todo it 
> > in a more quiet moment of the kernel cycle, not now.
> > 
> > (TRACE_EVENT_TEMPLATE OTOH has existed for just a few days so it's not a 
> > problem.)
> 
> Yes the template name is new, I'm not talking about that on
> particularly.


I personally don't mind much about the name, especially
between class and template. Both make equally sense to me.

But DECLARE sounds like a misnomer here (like DEFINE_EVENT
somehow) as TRACE_EVENT, DEFINE_EVENT and TRACE_EVENT_TEMPLATE
all behave either as a declaration or a definition, depending
on the CREATE_TRACE_POINT macro.

Also, considering the arising question of notifiers and TRACE_EVENT
that are starting to collide in that we have two event callbacks
subsystems that could be gathered in one, I guess TRACE_EVENT will
become too general in the future.

If we consider improving the TRACE_EVENT to support tracing (like
it does already) but also blocking notifiers, atomic notifiers, etc...
by migrating the notifier code to TRACE_EVENT,
then the name should probably be reconsidered as a more general thing.

KERNEL_EVENT ? NOTIFY_EVENT ?

And then the CPP callbacks we are currently using for tracing should
probably be renamed as they won't concern the notifier callbacks.

TP_printk could be renamed as TRACE_print, TP_fast_assing could be
TRACE_fast_assign, etc...

 
> > 
> > > A lot of developers have just learned about TRACE_EVENT and now it 
> > > just disappeared. Well, not really, but in the sense of ' find 
> > > linux.git -name '*.[ch]' | xargs grep TRACE_EVENT' it no longer 
> > > exists.
> > 
> > A second problem with the TRACE_EVENT name is that it's not just for 
> > tracing - we dont necessarily 'trace' events here. We can use the event 
> > callbacks to collect pure counts:
> 
> Then we might as well rename the "trace_*" all over the kernel.


I think this should be kept. Although if notifier goes migrated in
TRACE_EVENT, having notify_event() would gather the two meanings of
trace_* and notify_*

 
> > DEFINE_SINGLE_EVENT() solves all these problems:
> > 
> >  - It's obvious what it does
> > 
> >  - It suggests users of it that there's another non-single-event 
> >    facility, gently nudging them towards the use of the more efficient
> >    DEFINE_EVENT_CLASS() + DEFINE_EVENT() method.
> > 
> >  - It fits nicely into the rest of the naming scheme.
> 
> Like I said earlier, I'm not really attached to the name. Except that
> there's already a lot of documentation (I've given tutorials about it)
> using the TRACE_EVENT name. But who am I to decide?


Not that I like much DEFINE_SINGLE_EVENT(), because DEFINE is ambiguous
and SINGLE too (single can indeed be interpreted as something that doesn't
need a class, but is also confusing as it suggests that DEFINE_EVENT defines
several events in once), but I think a tutorial shouldn't paralyze a
subsystem progression.

Why not having BUILD_EVENT_CLASS(), BUILD_EVENT_FROM_CLASS(), and BUILD_EVENT() ?

That said, TRACE_EVENT() can still remain as an alias.


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

* Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
  2009-11-26 17:55           ` Frederic Weisbecker
@ 2009-11-26 18:12             ` Ingo Molnar
  2009-11-26 19:12               ` Steven Rostedt
  0 siblings, 1 reply; 43+ messages in thread
From: Ingo Molnar @ 2009-11-26 18:12 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Steven Rostedt, mingo, hpa, linux-kernel, penberg, tglx,
	linux-tip-commits


* Frederic Weisbecker <fweisbec@gmail.com> wrote:

> On Thu, Nov 26, 2009 at 09:45:30AM -0500, Steven Rostedt wrote:
> > On Thu, 2009-11-26 at 09:40 +0100, Ingo Molnar wrote:
> > > * Steven Rostedt <rostedt@goodmis.org> wrote:
> > > 
> > 
> > > > I would like to hear what others think about this change before we go 
> > > > ahead and implement it.
> > > 
> > > You mean TRACE_EVENT() -> DEFINE_SINGLE_EVENT()? Sure, we want todo it 
> > > in a more quiet moment of the kernel cycle, not now.
> > > 
> > > (TRACE_EVENT_TEMPLATE OTOH has existed for just a few days so it's not a 
> > > problem.)
> > 
> > Yes the template name is new, I'm not talking about that on
> > particularly.
> 
> I personally don't mind much about the name, especially between class 
> and template. Both make equally sense to me.
> 
> But DECLARE sounds like a misnomer here (like DEFINE_EVENT somehow) as 
> TRACE_EVENT, DEFINE_EVENT and TRACE_EVENT_TEMPLATE all behave either 
> as a declaration or a definition, depending on the CREATE_TRACE_POINT 
> macro.

DECLARE_EVENT_CLASS() doesnt really define an event visible to the user 
yet though. It defines functions internally (to be used by the real 
definition of the event) - but not visible externally really.

So the real 'definition' of an event happens with DEFINE_EVENT() - in 
the logical model of this.

So the logical model is clear:

   DECLARE_EVENT_CLASS(class);

    DEFINE_EVENT(class, event1);
    DEFINE_EVENT(class, event2);
    DEFINE_EVENT(class, event3);
    ...

  # later:
  # DEFINE_STANDALONE_EVENT(event)

And the logical model is what matters: that's what developers will use. 
They'll use these constructs based on the logical model, nobody sane 
will look into the CPP magic ;-)

And yes, we occasionally have to revisit our naming choices - especially 
when mistakes/misnomers become apparent.

Thanks,

	Ingo

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

* Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
  2009-11-26 18:12             ` Ingo Molnar
@ 2009-11-26 19:12               ` Steven Rostedt
  2009-11-26 19:20                 ` Ingo Molnar
  0 siblings, 1 reply; 43+ messages in thread
From: Steven Rostedt @ 2009-11-26 19:12 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Frederic Weisbecker, mingo, hpa, linux-kernel, penberg, tglx,
	linux-tip-commits, Christoph Hellwig

(added Christoph since he was the one to recommend the template
creation)

On Thu, 2009-11-26 at 19:12 +0100, Ingo Molnar wrote:
> * Frederic Weisbecker <fweisbec@gmail.com> wrote:

> DECLARE_EVENT_CLASS() doesnt really define an event visible to the user 
> yet though. It defines functions internally (to be used by the real 
> definition of the event) - but not visible externally really.
> 
> So the real 'definition' of an event happens with DEFINE_EVENT() - in 
> the logical model of this.
> 
> So the logical model is clear:
> 
>    DECLARE_EVENT_CLASS(class);
> 
>     DEFINE_EVENT(class, event1);
>     DEFINE_EVENT(class, event2);
>     DEFINE_EVENT(class, event3);
>     ...
> 
>   # later:
>   # DEFINE_STANDALONE_EVENT(event)

I think that name sounds even uglier than DEFINE_SINGLE_EVENT :-/

I'm fine with the DECLARE_EVENT_CLASS and DEFINE_EVENT, but I'm unsure
what to rename TRACE_EVENT as. I know its still pretty new, but it's
being used quite a bit. So it should take some extra thought.

I guess DEFINE_EVENT_CLASS is probably not good, although this would be
the combination of DECLARE_EVENT_CLASS and DEFINE_EVENT which it
actually is.

DECLARE_DEFINE_EVENT?  *naw*

DEFINE_DECLARED_EVENT?

Or we could go with DECLARE_EVENT(), DECLARE_EVENT_CLASS() and
DEFINE_EVENT_CLASS_INSTANCE()?


> 
> And the logical model is what matters: that's what developers will use. 
> They'll use these constructs based on the logical model, nobody sane 
> will look into the CPP magic ;-)
> 
> And yes, we occasionally have to revisit our naming choices - especially 
> when mistakes/misnomers become apparent.

Agreed, but lets discuss it before we commit it to a non-rebase branch.

-- Steve



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

* Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
  2009-11-26 19:12               ` Steven Rostedt
@ 2009-11-26 19:20                 ` Ingo Molnar
  2009-11-26 19:44                   ` Steven Rostedt
  0 siblings, 1 reply; 43+ messages in thread
From: Ingo Molnar @ 2009-11-26 19:20 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Frederic Weisbecker, mingo, hpa, linux-kernel, penberg, tglx,
	linux-tip-commits, Christoph Hellwig


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

> (added Christoph since he was the one to recommend the template 
> creation)
>
> On Thu, 2009-11-26 at 19:12 +0100, Ingo Molnar wrote:
> > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> 
> > DECLARE_EVENT_CLASS() doesnt really define an event visible to the user 
> > yet though. It defines functions internally (to be used by the real 
> > definition of the event) - but not visible externally really.
> > 
> > So the real 'definition' of an event happens with DEFINE_EVENT() - in 
> > the logical model of this.
> > 
> > So the logical model is clear:
> > 
> >    DECLARE_EVENT_CLASS(class);
> > 
> >     DEFINE_EVENT(class, event1);
> >     DEFINE_EVENT(class, event2);
> >     DEFINE_EVENT(class, event3);
> >     ...
> > 
> >   # later:
> >   # DEFINE_STANDALONE_EVENT(event)
> 
> I think that name sounds even uglier than DEFINE_SINGLE_EVENT :-/
>
> I'm fine with the DECLARE_EVENT_CLASS and DEFINE_EVENT, but I'm unsure 
> what to rename TRACE_EVENT as. I know its still pretty new, but it's 
> being used quite a bit. So it should take some extra thought.
> 
> I guess DEFINE_EVENT_CLASS is probably not good, although this would 
> be the combination of DECLARE_EVENT_CLASS and DEFINE_EVENT which it 
> actually is.
> 
> DECLARE_DEFINE_EVENT?  *naw*
> 
> DEFINE_DECLARED_EVENT?
> 
> Or we could go with DECLARE_EVENT(), DECLARE_EVENT_CLASS() and 
> DEFINE_EVENT_CLASS_INSTANCE()?

I think the most common one should be the shortest, and the most common 
one will be DEFINE_EVENT() - that's short enough already IMO.

I think we generally want to encourage the creation of classes of 
events, not myriads of standalone events, each with their own call 
signature, record format and printouts.

In that sense making the TRACE_EVENT() one longer would achieve that 
goal of discouraging its over-use: DEFINE_SINGLE_EVENT() tells the 
developer that it's an event of it's kind.

	Ingo

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

* Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
  2009-11-26 19:20                 ` Ingo Molnar
@ 2009-11-26 19:44                   ` Steven Rostedt
  2009-11-26 19:47                     ` Steven Rostedt
  2009-11-26 23:13                     ` Frederic Weisbecker
  0 siblings, 2 replies; 43+ messages in thread
From: Steven Rostedt @ 2009-11-26 19:44 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Frederic Weisbecker, mingo, hpa, linux-kernel, penberg, tglx,
	linux-tip-commits, Christoph Hellwig

On Thu, 2009-11-26 at 20:20 +0100, Ingo Molnar wrote:
> * Steven Rostedt <rostedt@goodmis.org> wrote:

> > DECLARE_DEFINE_EVENT?  *naw*
> > 
> > DEFINE_DECLARED_EVENT?
> > 
> > Or we could go with DECLARE_EVENT(), DECLARE_EVENT_CLASS() and 
> > DEFINE_EVENT_CLASS_INSTANCE()?
> 
> I think the most common one should be the shortest, and the most common 
> one will be DEFINE_EVENT() - that's short enough already IMO.

The above were ideas for replacing TRACE_EVENT, not the current
DEFINE_EVENT.

> 
> I think we generally want to encourage the creation of classes of 
> events, not myriads of standalone events, each with their own call 
> signature, record format and printouts.
> 
> In that sense making the TRACE_EVENT() one longer would achieve that 
> goal of discouraging its over-use: DEFINE_SINGLE_EVENT() tells the 
> developer that it's an event of it's kind.

But I do agree with Frederic that this can be a little confusing, since
it makes it sound like DEFINE_EVENT is for multiple events.

What about saying exactly what it does?

DECLARE_AND_DEFINE_EVENT()


Come to think of it, since current TRACE_EVENT is now just:

#define TRACE_EVENT() \
	TRACE_EVENT_TEMPLATE() \
	DEFINE_EVENT

This may make the most sense. I haven't tried it, but I believe that you
could even base other events off of the TRACE_EVENT. That is:

TRACE_EVENT(x, ...);

DEFINE_EVENT(x, y, ...);

And y would use x as its class.

So going back to your scheme of DECLARE_EVENT_CLASS(), it may make sense
to have DECLARE_AND_DEFINE_EVENT().


DECLARE_EVENT_CLASS(class, ...);
DEFINE_EVENT(class, foo, ...);

DECLARE_AND_DEFINE_EVENT(bar, ...);

DEFINE_EVENT(bar, zoo, ...);


May work.

-- Steve



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

* Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
  2009-11-26 19:44                   ` Steven Rostedt
@ 2009-11-26 19:47                     ` Steven Rostedt
  2009-11-26 23:13                     ` Frederic Weisbecker
  1 sibling, 0 replies; 43+ messages in thread
From: Steven Rostedt @ 2009-11-26 19:47 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Frederic Weisbecker, mingo, hpa, linux-kernel, penberg, tglx,
	linux-tip-commits, Christoph Hellwig

On Thu, 2009-11-26 at 14:44 -0500, Steven Rostedt wrote:

> Come to think of it, since current TRACE_EVENT is now just:
> 
> #define TRACE_EVENT() \
> 	TRACE_EVENT_TEMPLATE() \
> 	DEFINE_EVENT
> 
> This may make the most sense. I haven't tried it, but I believe that you
> could even base other events off of the TRACE_EVENT. That is:
> 
> TRACE_EVENT(x, ...);
> 
> DEFINE_EVENT(x, y, ...);
> 
> And y would use x as its class.
> 
> So going back to your scheme of DECLARE_EVENT_CLASS(), it may make sense
> to have DECLARE_AND_DEFINE_EVENT().
> 
> 
> DECLARE_EVENT_CLASS(class, ...);
> DEFINE_EVENT(class, foo, ...);
> 
> DECLARE_AND_DEFINE_EVENT(bar, ...);

Perhaps being the most descriptive to what it does:

	DECLARE_CLASS_AND_DEFINE_EVENT() ?

-- Steve

> 
> DEFINE_EVENT(bar, zoo, ...);
> 



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

* Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
  2009-11-26 19:44                   ` Steven Rostedt
  2009-11-26 19:47                     ` Steven Rostedt
@ 2009-11-26 23:13                     ` Frederic Weisbecker
  2009-11-27  3:52                       ` Steven Rostedt
  1 sibling, 1 reply; 43+ messages in thread
From: Frederic Weisbecker @ 2009-11-26 23:13 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Ingo Molnar, mingo, hpa, linux-kernel, penberg, tglx,
	linux-tip-commits, Christoph Hellwig

On Thu, Nov 26, 2009 at 02:44:27PM -0500, Steven Rostedt wrote:
> On Thu, 2009-11-26 at 20:20 +0100, Ingo Molnar wrote:
> > I think we generally want to encourage the creation of classes of 
> > events, not myriads of standalone events, each with their own call 
> > signature, record format and printouts.
> > 
> > In that sense making the TRACE_EVENT() one longer would achieve that 
> > goal of discouraging its over-use: DEFINE_SINGLE_EVENT() tells the 
> > developer that it's an event of it's kind.
> 
> But I do agree with Frederic that this can be a little confusing, since
> it makes it sound like DEFINE_EVENT is for multiple events.
> 
> What about saying exactly what it does?
> 
> DECLARE_AND_DEFINE_EVENT()


It tells so much that it is confusing :)

 
> 
> Come to think of it, since current TRACE_EVENT is now just:
> 
> #define TRACE_EVENT() \
> 	TRACE_EVENT_TEMPLATE() \
> 	DEFINE_EVENT
> 
> This may make the most sense. I haven't tried it, but I believe that you
> could even base other events off of the TRACE_EVENT. That is:
> 
> TRACE_EVENT(x, ...);
> 
> DEFINE_EVENT(x, y, ...);
> 
> And y would use x as its class.
> 
> So going back to your scheme of DECLARE_EVENT_CLASS(), it may make sense
> to have DECLARE_AND_DEFINE_EVENT().
> 
> 
> DECLARE_EVENT_CLASS(class, ...);
> DEFINE_EVENT(class, foo, ...);
> 
> DECLARE_AND_DEFINE_EVENT(bar, ...);



Yep, or DEFINE_EVENT_NOCLASS.



> DEFINE_EVENT(bar, zoo, ...);
> 
> 
> May work.
> 
> -- Steve
> 
> 


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

* Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()
  2009-11-26 23:13                     ` Frederic Weisbecker
@ 2009-11-27  3:52                       ` Steven Rostedt
  0 siblings, 0 replies; 43+ messages in thread
From: Steven Rostedt @ 2009-11-27  3:52 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Ingo Molnar, mingo, hpa, linux-kernel, penberg, tglx,
	linux-tip-commits, Christoph Hellwig

On Fri, 2009-11-27 at 00:13 +0100, Frederic Weisbecker wrote:

> > 
> > But I do agree with Frederic that this can be a little confusing, since
> > it makes it sound like DEFINE_EVENT is for multiple events.
> > 
> > What about saying exactly what it does?
> > 
> > DECLARE_AND_DEFINE_EVENT()
> 
> 
> It tells so much that it is confusing :)

Information overload huh? ;-)

> 
>  
> > 
> > Come to think of it, since current TRACE_EVENT is now just:
> > 
> > #define TRACE_EVENT() \
> > 	TRACE_EVENT_TEMPLATE() \
> > 	DEFINE_EVENT
> > 
> > This may make the most sense. I haven't tried it, but I believe that you
> > could even base other events off of the TRACE_EVENT. That is:
> > 
> > TRACE_EVENT(x, ...);
> > 
> > DEFINE_EVENT(x, y, ...);
> > 
> > And y would use x as its class.
> > 
> > So going back to your scheme of DECLARE_EVENT_CLASS(), it may make sense
> > to have DECLARE_AND_DEFINE_EVENT().
> > 
> > 
> > DECLARE_EVENT_CLASS(class, ...);
> > DEFINE_EVENT(class, foo, ...);
> > 
> > DECLARE_AND_DEFINE_EVENT(bar, ...);
> 
> 
> 
> Yep, or DEFINE_EVENT_NOCLASS.

Well it may not be upper class, but I wouldn't say it has no class ;-)

But seriously, that is more misleading. It is a class. Remember, that
TRACE_EVENT is both a class and a define. With the new names for
template trace_event is:

#define TRACE_EVENT(name, ...) \
	DECLARE_EVENT_CLASS(name, ...); \
	DEFINE_EVENT(name, name, ...);

So TRACE_EVENT really is a DECLARE_CLASS_AND_DEFINE_EVENT(name, ...);

-- Steve

> 
> 
> 
> > DEFINE_EVENT(bar, zoo, ...);
> > 
> > 
> > May work.
> > 
> > -- Steve
> > 
> > 
> 


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

end of thread, other threads:[~2009-11-27  3:52 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-26  7:02 [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Li Zefan
2009-11-26  7:03 ` [PATCH 1/9] tracing: Convert module refcnt events to DEFINE_EVENT Li Zefan
2009-11-26  8:42   ` [tip:perf/core] " tip-bot for Li Zefan
2009-11-26  7:04 ` [PATCH 2/9] tracing: Convert some kmem " Li Zefan
2009-11-26  7:24   ` Pekka Enberg
2009-11-26  7:38     ` Steven Rostedt
2009-11-26  7:57     ` Ingo Molnar
2009-11-26  8:29       ` Steven Rostedt
2009-11-26  8:16   ` [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS() tip-bot for Ingo Molnar
2009-11-26  8:33     ` Steven Rostedt
2009-11-26  8:40       ` Ingo Molnar
2009-11-26 14:45         ` Steven Rostedt
2009-11-26 17:55           ` Frederic Weisbecker
2009-11-26 18:12             ` Ingo Molnar
2009-11-26 19:12               ` Steven Rostedt
2009-11-26 19:20                 ` Ingo Molnar
2009-11-26 19:44                   ` Steven Rostedt
2009-11-26 19:47                     ` Steven Rostedt
2009-11-26 23:13                     ` Frederic Weisbecker
2009-11-27  3:52                       ` Steven Rostedt
2009-11-26  8:42   ` [tip:perf/core] tracing: Convert some kmem events to DEFINE_EVENT tip-bot for Li Zefan
2009-11-26 12:34   ` [tip:perf/core] tracing: Fix kmem event exports tip-bot for Ingo Molnar
2009-11-26  7:04 ` [PATCH 3/9] tracing: Convert softirq events to DEFINE_EVENT Li Zefan
2009-11-26  8:43   ` [tip:perf/core] " tip-bot for Li Zefan
2009-11-26  7:05 ` [PATCH 4/9] tracing: Convert some workqueue " Li Zefan
2009-11-26  8:43   ` [tip:perf/core] " tip-bot for Li Zefan
2009-11-26  7:05 ` [PATCH 5/9] tracing: Convert some power " Li Zefan
2009-11-26  8:43   ` [tip:perf/core] " tip-bot for Li Zefan
2009-11-26  7:06 ` [PATCH 6/9] tracing: Convert some block " Li Zefan
2009-11-26  8:36   ` Jens Axboe
2009-11-26  8:44     ` Ingo Molnar
2009-11-26  8:47       ` Jens Axboe
2009-11-26  8:50         ` Ingo Molnar
2009-11-26  8:52           ` Jens Axboe
2009-11-26  8:43   ` [tip:perf/core] " tip-bot for Li Zefan
2009-11-26  7:06 ` [PATCH 7/9] tracing: Convert some jbd2 " Li Zefan
2009-11-26  8:44   ` [tip:perf/core] " tip-bot for Li Zefan
2009-11-26  7:07 ` [PATCH 8/9] tracing: Convert some ext4 events to DEFINE_TRACE Li Zefan
2009-11-26  8:44   ` [tip:perf/core] " tip-bot for Li Zefan
2009-11-26  7:08 ` [PATCH 9/9] tracing: Restore original format of sched events Li Zefan
2009-11-26  8:44   ` [tip:perf/core] " tip-bot for Li Zefan
2009-11-26  7:32 ` [PATCH 0/9] tracing: Convert some trace events to DEFINE_TRACE Steven Rostedt
2009-11-26  7:59   ` 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.