Skip to contentSkip to conversation

tracing: Convert some trace events to DEFINE_TRACE

PATCH Applied Li Zefan 6 participants 43 messages Nov 26, 2009 – Nov 27, 2009

Subsystems (6)
lore
Share & tools
lore

Li Zefan

author
#0 lore raw

cover tracing: Convert some trace events to DEFINE_TRACE

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(-)
author
#1 lore raw

PATCH 1/9 tracing: Convert module refcnt events to DEFINE_EVENT

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

---
 include/trace/events/module.h |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)
include/trace/events/module.h +7 -15
index 84160fb..32c28db 100644
@@ -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,
Signature · 1 line
1.6.3
#2 lore raw

[tip:perf/core] tracing: Convert module refcnt events to DEFINE_EVENT

Commit-ID:  925684d6d589e40e41007edf47c69e729d911263
Gitweb:     http://git.kernel.org/tip/925684d6d589e40e41007edf47c69e729d911263
Author:     Li Zefan <[email protected]>
AuthorDate: Thu, 26 Nov 2009 15:03:23 +0800
Committer:  Ingo Molnar <[email protected]>
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.

Cc Rusty Russell <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <[email protected]>

---
 include/trace/events/module.h |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)
include/trace/events/module.h +7 -15
index 84160fb..4b0f48b 100644
@@ -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,
author
#3 lore raw

PATCH 2/9 tracing: Convert some kmem events to DEFINE_EVENT

In reply to Li Zefan

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

---
 include/trace/events/kmem.h |  130 +++++++++++++-----------------------------
 mm/page_alloc.c             |    4 +-
 mm/util.c                   |    3 -
 3 files changed, 43 insertions(+), 94 deletions(-)
include/trace/events/kmem.h +40 -90
index eaf46bd..af3e2ec 100644
@@ -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,
mm/page_alloc.c +3 -1
index 2bc2ac6..bdb22f5 100644
@@ -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.
  */
mm/util.c +0 -3
index 7c35ad9..15d1975 100644
@@ -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
Signature · 1 line
1.6.3
Acked-by on v1 2/9
#4 lore raw

Re: [PATCH 2/9] tracing: Convert some kmem events to DEFINE_EVENT

Li Zefan kirjoitti:

Quoted 6 lines

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
Quoted 8 lines

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 have no idea what TRACE_EVENT_TEMPLATE is but the space savings are convincing enough! I assume this is going into -tip?

maintainer
#5 lore raw

Re: [PATCH 2/9] tracing: Convert some kmem events to DEFINE_EVENT

Quoted 2 lines · Pekka Enberg

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

#6 lore raw

Re: [PATCH 2/9] tracing: Convert some kmem events to DEFINE_EVENT

In reply to Pekka Enberg
Quoted 9 lines · Pekka Enberg

Li Zefan kirjoitti:

Quoted 8 lines

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:

Quoted 8 lines
Quoted 6 lines

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 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.

Quoted 2 lines

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

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

Quoted 1 line

Thanks,

Ingo

maintainer
#7 lore raw

Re: [PATCH 2/9] tracing: Convert some kmem events to DEFINE_EVENT

Quoted 31 lines · Ingo Molnar
Quoted 9 lines · Pekka Enberg

Li Zefan kirjoitti:

Quoted 8 lines

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:

Quoted 8 lines
Quoted 6 lines

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

Quoted 5 lines

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:

Quoted 6 lines

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
Quoted 7 lines

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

#8 lore raw

[tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

In reply to Li Zefan
Commit-ID:  091ad3658e3c76c5fb05f65bfb64a0246f8f31b5
Gitweb:     http://git.kernel.org/tip/091ad3658e3c76c5fb05f65bfb64a0246f8f31b5
Author:     Ingo Molnar <[email protected]>
AuthorDate: Thu, 26 Nov 2009 09:04:55 +0100
Committer:  Ingo Molnar <[email protected]>
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 <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>

---
 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(-)
include/linux/tracepoint.h +1 -1
index 7063383..f59604e 100644
@@ -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)	\
include/trace/define_trace.h +1 -1
index 5d7d855..5acfb1e 100644
@@ -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
include/trace/events/sched.h +3 -3
index 238f74b..5ce7950 100644
@@ -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),
 
include/trace/ftrace.h +23 -23

120 lines not on this page · raw message

maintainer
#9 lore raw

Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

Quoted 21 lines · tip-bot for Ingo Molnar
Commit-ID:  091ad3658e3c76c5fb05f65bfb64a0246f8f31b5
Gitweb:     http://git.kernel.org/tip/091ad3658e3c76c5fb05f65bfb64a0246f8f31b5
Author:     Ingo Molnar <[email protected]>
AuthorDate: Thu, 26 Nov 2009 09:04:55 +0100
Committer:  Ingo Molnar <[email protected]>
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)

Quoted 5 lines

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

#10 lore raw

Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

Quoted 24 lines · Steven Rostedt
Quoted 23 lines · tip-bot for Ingo Molnar
Commit-ID:  091ad3658e3c76c5fb05f65bfb64a0246f8f31b5
Gitweb:     http://git.kernel.org/tip/091ad3658e3c76c5fb05f65bfb64a0246f8f31b5
Author:     Ingo Molnar <[email protected]>
AuthorDate: Thu, 26 Nov 2009 09:04:55 +0100
Committer:  Ingo Molnar <[email protected]>
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:

Quoted 7 lines
Quoted 3 lines

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

Quoted 4 lines

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

maintainer
#11 lore raw

Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

Quoted 11 lines · Ingo Molnar
Quoted 2 lines · Steven Rostedt

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.

Quoted 9 lines
Quoted 5 lines

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.

Quoted 11 lines
| 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.

Quoted 3 lines

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?

Quoted 10 lines

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

#12 lore raw

Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

Quoted 7 lines · Steven Rostedt
Quoted 6 lines · Ingo Molnar
Quoted 2 lines · Steven Rostedt

I would like to hear what others think about this change before we go ahead and implement it.

Quoted 8 lines
Quoted 5 lines

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...

Quoted 11 lines
Quoted 9 lines
Quoted 5 lines

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_*

Quoted 8 lines
Quoted 8 lines

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.

Quoted 5 lines
Quoted 1 line

- 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.

#13 lore raw

Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

Quoted 17 lines · Frederic Weisbecker
Quoted 7 lines · Steven Rostedt
Quoted 6 lines · Ingo Molnar
Quoted 2 lines · Steven Rostedt

I would like to hear what others think about this change before we go ahead and implement it.

Quoted 8 lines
Quoted 5 lines

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.

Quoted 7 lines

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

maintainer
#14 lore raw

Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

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

Quoted 13 lines · Ingo Molnar

* Frederic Weisbecker <[email protected]> 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);
Quoted 7 lines
    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()?

Quoted 7 lines

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

#15 lore raw

Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

Quoted 35 lines · Steven Rostedt

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

Quoted 13 lines · Ingo Molnar

* Frederic Weisbecker <[email protected]> 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);
Quoted 7 lines
    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.

Quoted 6 lines

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

maintainer
#16 lore raw

Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

Quoted 11 lines · Ingo Molnar
Quoted 6 lines · Steven Rostedt

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.

Quoted 8 lines

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

maintainer
#17 lore raw

Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

Quoted 15 lines · Steven Rostedt

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.

Quoted 8 lines

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

Quoted 3 lines

DEFINE_EVENT(bar, zoo, ...);

#18 lore raw

Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

In reply to Steven Rostedt
Quoted 9 lines · Steven Rostedt
Quoted 7 lines · Ingo Molnar

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.

Quoted 6 lines

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

Quoted 16 lines

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.

Quoted 8 lines

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.

Quoted 8 lines

DEFINE_EVENT(bar, zoo, ...);

May work.

-- Steve

maintainer
#19 lore raw

Re: [tip:perf/core] events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS()

Quoted 10 lines · Frederic Weisbecker
Quoted 7 lines

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

Quoted 22 lines
Quoted 22 lines

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().

Quoted 8 lines
Quoted 4 lines

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

Quoted 12 lines
Quoted 11 lines

DEFINE_EVENT(bar, zoo, ...);

May work.

-- Steve

#20 lore raw

[tip:perf/core] tracing: Convert some kmem events to DEFINE_EVENT

In reply to Li Zefan
Commit-ID:  53d0422c2d10808fddb2c30859193bfea164c7e3
Gitweb:     http://git.kernel.org/tip/53d0422c2d10808fddb2c30859193bfea164c7e3
Author:     Li Zefan <[email protected]>
AuthorDate: Thu, 26 Nov 2009 15:04:10 +0800
Committer:  Ingo Molnar <[email protected]>
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.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Mel Gorman <[email protected]>

LKML-Reference: <[email protected]>

---
 include/trace/events/kmem.h |  130 +++++++++++++-----------------------------
 mm/page_alloc.c             |    4 +-
 mm/util.c                   |    3 -
 3 files changed, 43 insertions(+), 94 deletions(-)
include/trace/events/kmem.h +40 -90
index eaf46bd..3adca0c 100644
@@ -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,
mm/page_alloc.c +3 -1
index 2bc2ac6..bdb22f5 100644
@@ -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.
  */
mm/util.c +0 -3
index 7c35ad9..15d1975 100644
@@ -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
#21 lore raw

[tip:perf/core] tracing: Fix kmem event exports

In reply to Li Zefan
Commit-ID:  4d795fb17a02a87e35782773b88b7a63acfbeaae
Gitweb:     http://git.kernel.org/tip/4d795fb17a02a87e35782773b88b7a63acfbeaae
Author:     Ingo Molnar <[email protected]>
AuthorDate: Thu, 26 Nov 2009 13:11:46 +0100
Committer:  Ingo Molnar <[email protected]>
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 <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Mel Gorman <[email protected]>
LKML-Reference: <[email protected]>

---
 mm/page_alloc.c |    4 +---
 mm/util.c       |    3 +++
 2 files changed, 4 insertions(+), 3 deletions(-)
mm/page_alloc.c +1 -3
index bdb22f5..2bc2ac6 100644
@@ -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.
  */
mm/util.c +3 -0
index 15d1975..7c35ad9 100644
@@ -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
author
#22 lore raw

PATCH 3/9 tracing: Convert softirq events to DEFINE_EVENT

In reply to Li Zefan

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

---
 include/trace/events/irq.h |   46 ++++++++++++++++++++-----------------------
 1 files changed, 21 insertions(+), 25 deletions(-)
include/trace/events/irq.h +21 -25
index dcfcd44..f8a94d7 100644
@@ -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 */
Signature · 1 line
1.6.3
#23 lore raw

[tip:perf/core] tracing: Convert softirq events to DEFINE_EVENT

Commit-ID:  c467307c1a812c3150b27a68c2b2d3397bb40a4f
Gitweb:     http://git.kernel.org/tip/c467307c1a812c3150b27a68c2b2d3397bb40a4f
Author:     Li Zefan <[email protected]>
AuthorDate: Thu, 26 Nov 2009 15:04:31 +0800
Committer:  Ingo Molnar <[email protected]>
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.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <[email protected]>

---
 include/trace/events/irq.h |   46 ++++++++++++++++++++-----------------------
 1 files changed, 21 insertions(+), 25 deletions(-)
include/trace/events/irq.h +21 -25
index dcfcd44..0e4cfb6 100644
@@ -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 */
author
#24 lore raw

PATCH 4/9 tracing: Convert some workqueue events to DEFINE_EVENT

In reply to Li Zefan

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

---
 include/trace/events/workqueue.h |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)
include/trace/events/workqueue.h +7 -15
index e4612db..6da8d1b 100644
@@ -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 */
Signature · 1 line
1.6.3
#25 lore raw

[tip:perf/core] tracing: Convert some workqueue events to DEFINE_EVENT

Commit-ID:  382ece710bf88b08440b598731361e5a47582b62
Gitweb:     http://git.kernel.org/tip/382ece710bf88b08440b598731361e5a47582b62
Author:     Li Zefan <[email protected]>
AuthorDate: Thu, 26 Nov 2009 15:05:03 +0800
Committer:  Ingo Molnar <[email protected]>
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.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <[email protected]>

---
 include/trace/events/workqueue.h |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)
include/trace/events/workqueue.h +7 -15
index e4612db..d6c9744 100644
@@ -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 */
author
#26 lore raw

PATCH 5/9 tracing: Convert some power events to DEFINE_EVENT

In reply to Li Zefan

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

---
 include/trace/events/power.h |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)
include/trace/events/power.h +15 -21
index 9bb96e5..5cfa61a 100644
@@ -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 */
Signature · 1 line
1.6.3
#27 lore raw

[tip:perf/core] tracing: Convert some power events to DEFINE_EVENT

Commit-ID:  7703466b4c0a21b88d701882bef0d45bcb0a0281
Gitweb:     http://git.kernel.org/tip/7703466b4c0a21b88d701882bef0d45bcb0a0281
Author:     Li Zefan <[email protected]>
AuthorDate: Thu, 26 Nov 2009 15:05:38 +0800
Committer:  Ingo Molnar <[email protected]>
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.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Arjan van de Ven <[email protected]>

LKML-Reference: <[email protected]>

---
 include/trace/events/power.h |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)
include/trace/events/power.h +15 -21
index 9bb96e5..c4efe9b 100644
@@ -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 */
author
#28 lore raw

PATCH 6/9 tracing: Convert some block events to DEFINE_EVENT

In reply to Li Zefan

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

---
 include/trace/events/block.h |  202 +++++++++---------------------------------
 1 files changed, 42 insertions(+), 160 deletions(-)
include/trace/events/block.h +42 -160
index 00405b5..0dcb775 100644
@@ -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,
Signature · 1 line
1.6.3
Applied
#29 lore raw

Re: [PATCH 6/9] tracing: Convert some block events to DEFINE_EVENT

Quoted 5 lines · Li Zefan

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.

Signature · 1 line
Jens Axboe
#30 lore raw

Re: [PATCH 6/9] tracing: Convert some block events to DEFINE_EVENT

Quoted 11 lines · Jens Axboe
Quoted 5 lines · Li Zefan

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

#31 lore raw

Re: [PATCH 6/9] tracing: Convert some block events to DEFINE_EVENT

Quoted 13 lines · Ingo Molnar
Quoted 10 lines · Jens Axboe
Quoted 5 lines · Li Zefan

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.

Quoted 8 lines
Quoted 1 line

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.

Signature · 1 line
Jens Axboe
#32 lore raw

Re: [PATCH 6/9] tracing: Convert some block events to DEFINE_EVENT

Quoted 16 lines · Jens Axboe
Quoted 15 lines · Ingo Molnar
Quoted 11 lines · Jens Axboe
Quoted 5 lines · Li Zefan

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.

Quoted 8 lines
Quoted 6 lines

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

#33 lore raw

Re: [PATCH 6/9] tracing: Convert some block events to DEFINE_EVENT

Quoted 28 lines · Ingo Molnar
Quoted 16 lines · Jens Axboe
Quoted 15 lines · Ingo Molnar
Quoted 11 lines · Jens Axboe
Quoted 5 lines · Li Zefan

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.

Quoted 8 lines
Quoted 6 lines

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.

Quoted 8 lines

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.

Signature · 1 line
Jens Axboe
#34 lore raw

[tip:perf/core] tracing: Convert some block events to DEFINE_EVENT

In reply to Li Zefan
Commit-ID:  77ca1e0294f25fc26053ba14353e703158acef26
Gitweb:     http://git.kernel.org/tip/77ca1e0294f25fc26053ba14353e703158acef26
Author:     Li Zefan <[email protected]>
AuthorDate: Thu, 26 Nov 2009 15:06:14 +0800
Committer:  Ingo Molnar <[email protected]>
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.

Cc Jens Axboe <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <[email protected]>

---
 include/trace/events/block.h |  202 +++++++++---------------------------------
 1 files changed, 42 insertions(+), 160 deletions(-)
include/trace/events/block.h +42 -160
index 00405b5..5fb7273 100644
@@ -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,
author
#35 lore raw

PATCH 7/9 tracing: Convert some jbd2 events to DEFINE_EVENT

In reply to Li Zefan

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}
---
 include/trace/events/jbd2.h |   63 +++++++-----------------------------------
 1 files changed, 11 insertions(+), 52 deletions(-)
include/trace/events/jbd2.h +11 -52
index 3c60b75..a1abcf4 100644
@@ -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,
Signature · 1 line
1.6.3
#36 lore raw

[tip:perf/core] tracing: Convert some jbd2 events to DEFINE_EVENT

Commit-ID:  071688f36e7eba3e37b2fc48e35bfdab99b80b4d
Gitweb:     http://git.kernel.org/tip/071688f36e7eba3e37b2fc48e35bfdab99b80b4d
Author:     Li Zefan <[email protected]>
AuthorDate: Thu, 26 Nov 2009 15:06:55 +0800
Committer:  Ingo Molnar <[email protected]>
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.

Cc Theodore Ts'o <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <[email protected]>

---
 include/trace/events/jbd2.h |   63 +++++++-----------------------------------
 1 files changed, 11 insertions(+), 52 deletions(-)
include/trace/events/jbd2.h +11 -52
index 3c60b75..96b370a 100644
@@ -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,
author
#37 lore raw

PATCH 8/9 tracing: Convert some ext4 events to DEFINE_TRACE

In reply to Li Zefan

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

---
 include/trace/events/ext4.h |  129 ++++++++++++-------------------------------
 1 files changed, 35 insertions(+), 94 deletions(-)
include/trace/events/ext4.h +35 -94
index d09550b..b5bbd3b 100644
@@ -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),
Signature · 1 line
1.6.3
#38 lore raw

[tip:perf/core] tracing: Convert some ext4 events to DEFINE_TRACE

Commit-ID:  b5eb34c3592545c756e50d882c08417eb60740a7
Gitweb:     http://git.kernel.org/tip/b5eb34c3592545c756e50d882c08417eb60740a7
Author:     Li Zefan <[email protected]>
AuthorDate: Thu, 26 Nov 2009 15:07:36 +0800
Committer:  Ingo Molnar <[email protected]>
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.

Cc Theodore Ts'o <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <[email protected]>

---
 include/trace/events/ext4.h |  129 ++++++++++++-------------------------------
 1 files changed, 35 insertions(+), 94 deletions(-)
include/trace/events/ext4.h +35 -94
index d09550b..318f765 100644
@@ -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),
author
#39 lore raw

PATCH 9/9 tracing: Restore original format of sched events

In reply to Li Zefan

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]", ...
---
 include/trace/events/sched.h |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)
include/trace/events/sched.h +6 -12
index 238f74b..7f67d27 100644
@@ -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
Signature · 1 line
1.6.3
#40 lore raw

[tip:perf/core] tracing: Restore original format of sched events

Commit-ID:  470dda7417f284b9cfc96560b2acd98df63798a2
Gitweb:     http://git.kernel.org/tip/470dda7417f284b9cfc96560b2acd98df63798a2
Author:     Li Zefan <[email protected]>
AuthorDate: Thu, 26 Nov 2009 15:08:01 +0800
Committer:  Ingo Molnar <[email protected]>
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.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <[email protected]>

---
 include/trace/events/sched.h |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)
include/trace/events/sched.h +6 -12
index 5ce7950..9d316b2 100644
@@ -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
maintainer
#41 lore raw
In reply to Li Zefan
Quoted 11 lines · Li Zefan

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

Quoted 14 lines
---
 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(-)
#42 lore raw
Quoted 13 lines · Steven Rostedt
Quoted 11 lines · Li Zefan

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.

Quoted 6 lines

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