Skip to contentSkip to conversation

ftrace: Separate include/trace/kmemtrace.h to kmemtrace part and tracepoint part

PATCH Applied Zhaolei 4 participants 9 messages Apr 10, 2009 – Apr 13, 2009

Subsystems (3)
lore
Share & tools
lore

Zhaolei

author
#0 lore raw

PATCH 1/2 ftrace: Separate include/trace/kmemtrace.h to kmemtrace part and tracepoint part

Current kmemtrace.h is used both as header file of kmemtrace and kmem's tracepoints definition.
Tracepoints' definition file may be used by other code, and should only have definition of tracepoint.

We can separate include/trace/kmemtrace.h into 2 files:
include/linux/kmemtrace.h: header file for kmemtrace
include/trace/kmem.h: definition of kmem tracepoints

---
 include/linux/kmemtrace.h             |   25 +++++++++++++++++++++++++
 include/linux/slab_def.h              |    2 +-
 include/linux/slub_def.h              |    2 +-
 include/trace/{kmemtrace.h => kmem.h} |   25 +++----------------------
 init/main.c                           |    2 +-
 kernel/trace/kmemtrace.c              |    2 +-
 kernel/trace/trace.h                  |    2 +-
 mm/slab.c                             |    2 +-
 mm/slob.c                             |    2 +-
 mm/slub.c                             |    2 +-
 10 files changed, 36 insertions(+), 30 deletions(-)
 create mode 100644 include/linux/kmemtrace.h
 rename include/trace/{kmemtrace.h => kmem.h} (78%)
include/linux/kmemtrace.h new file +25 -0
new file mode 100644
index 0000000..15c45a2
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2008 Eduard - Gabriel Munteanu
+ *
+ * This file is released under GPL version 2.
+ */
+
+#ifndef _LINUX_KMEMTRACE_H
+#define _LINUX_KMEMTRACE_H
+
+#ifdef __KERNEL__
+
+#include <trace/kmem.h>
+
+#ifdef CONFIG_KMEMTRACE
+extern void kmemtrace_init(void);
+#else
+static inline void kmemtrace_init(void)
+{
+}
+#endif
+
+#endif /* __KERNEL__ */
+
+#endif /* _LINUX_KMEMTRACE_H */
+
include/linux/slab_def.h +1 -1
index 1a78b7a..850d057 100644
@@ -14,7 +14,7 @@
 #include <asm/page.h>		/* kmalloc_sizes.h needs PAGE_SIZE */
 #include <asm/cache.h>		/* kmalloc_sizes.h needs L1_CACHE_BYTES */
 #include <linux/compiler.h>
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 
 /*
  * struct kmem_cache
include/linux/slub_def.h +1 -1
index 5046f90..be5d40c 100644
@@ -10,7 +10,7 @@
 #include <linux/gfp.h>
 #include <linux/workqueue.h>
 #include <linux/kobject.h>
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 
 enum stat_item {
 	ALLOC_FASTPATH,		/* Allocation from cpu slab */
include/trace/kmem.h renamed from include/trace/kmemtrace.h +3 -22
similarity index 78%
rename from include/trace/kmemtrace.h
rename to include/trace/kmem.h
index 28ee69f..24d2519 100644
@@ -1,25 +1,9 @@
-/*
- * Copyright (C) 2008 Eduard - Gabriel Munteanu
- *
- * This file is released under GPL version 2.
- */
-
-#ifndef _LINUX_KMEMTRACE_H
-#define _LINUX_KMEMTRACE_H
-
-#ifdef __KERNEL__
+#ifndef _TRACE_KMEM_H
+#define _TRACE_KMEM_H
 
 #include <linux/tracepoint.h>
 #include <linux/types.h>
 
-#ifdef CONFIG_KMEMTRACE
-extern void kmemtrace_init(void);
-#else
-static inline void kmemtrace_init(void)
-{
-}
-#endif
-
 DECLARE_TRACE(kmalloc,
 	      TP_PROTO(unsigned long call_site,
 		      const void *ptr,
@@ -57,7 +41,4 @@ DECLARE_TRACE(kmem_cache_free,
 	      TP_PROTO(unsigned long call_site, const void *ptr),
 	      TP_ARGS(call_site, ptr));
 
-#endif /* __KERNEL__ */
-
-#endif /* _LINUX_KMEMTRACE_H */
-
+#endif /* _TRACE_KMEM_H */
init/main.c +1 -1
index ed702d9..694a563 100644
@@ -65,6 +65,7 @@
 #include <linux/kmemcheck.h>
 #include <linux/ftrace.h>
 #include <linux/async.h>
+#include <linux/kmemtrace.h>
 #include <trace/boot.h>
 
 #include <asm/io.h>
@@ -72,7 +73,6 @@
 #include <asm/setup.h>
 #include <asm/sections.h>
 #include <asm/cacheflush.h>
-#include <trace/kmemtrace.h>
 
 #ifdef CONFIG_X86_LOCAL_APIC
 #include <asm/smp.h>
kernel/trace/kmemtrace.c +1 -1
index 91cd0a5..86cdf67 100644
@@ -12,7 +12,7 @@
 #include <linux/dcache.h>
 #include <linux/fs.h>
 
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 
 #include "trace_output.h"
 #include "trace.h"
kernel/trace/trace.h +1 -1
index ee23ea2..ce6bdc4 100644
@@ -9,7 +9,7 @@
 #include <linux/mmiotrace.h>
 #include <linux/ftrace.h>
 #include <trace/boot.h>
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 #include <trace/power.h>
 
 enum trace_type {
mm/slab.c +1 -1
index 6bf8a95..762acc2 100644
@@ -102,7 +102,7 @@
 #include	<linux/cpu.h>
 #include	<linux/sysctl.h>
 #include	<linux/module.h>
-#include	<trace/kmemtrace.h>
+#include	<linux/kmemtrace.h>
 #include	<linux/rcupdate.h>
 #include	<linux/string.h>
 #include	<linux/uaccess.h>
mm/slob.c +1 -1
index a2d4ab3..494f05f 100644
@@ -65,7 +65,7 @@
 #include <linux/module.h>
 #include <linux/rcupdate.h>
 #include <linux/list.h>
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 #include <asm/atomic.h>
 
 /*
mm/slub.c +1 -1
index 4ac5e3e..a98d456 100644
@@ -16,7 +16,7 @@
 #include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 #include <linux/cpu.h>
 #include <linux/cpuset.h>
 #include <linux/mempolicy.h>
Signature · 1 line
1.5.5.3
author
#1 lore raw

PATCH 2/2 tracepoint: Make kmem tracepoint use TRACE_EVENT macro

TRACE_EVENT is more unify and generic for define a tracepoint. It also add ftrace support for this tracepoint.

---
 include/trace/kmem.h              |   39 +-------
 include/trace/kmem_event_types.h  |  193 +++++++++++++++++++++++++++++++++++++
 include/trace/trace_event_types.h |    1 +
 include/trace/trace_events.h      |    1 +
 4 files changed, 197 insertions(+), 37 deletions(-)
 create mode 100644 include/trace/kmem_event_types.h
include/trace/kmem.h +2 -37
index 24d2519..46efc24 100644
@@ -1,44 +1,9 @@
 #ifndef _TRACE_KMEM_H
 #define _TRACE_KMEM_H
 
-#include <linux/tracepoint.h>
 #include <linux/types.h>
+#include <linux/tracepoint.h>
 
-DECLARE_TRACE(kmalloc,
-	      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));
-DECLARE_TRACE(kmem_cache_alloc,
-	      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));
-DECLARE_TRACE(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_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node));
-DECLARE_TRACE(kmem_cache_alloc_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));
-DECLARE_TRACE(kfree,
-	      TP_PROTO(unsigned long call_site, const void *ptr),
-	      TP_ARGS(call_site, ptr));
-DECLARE_TRACE(kmem_cache_free,
-	      TP_PROTO(unsigned long call_site, const void *ptr),
-	      TP_ARGS(call_site, ptr));
+#include <trace/kmem_event_types.h>
 
 #endif /* _TRACE_KMEM_H */
include/trace/kmem_event_types.h new file +193 -0

193 lines not on this page · raw message

include/trace/trace_event_types.h +1 -0
index 33b6bfc..552a50e 100644
@@ -4,3 +4,4 @@
 #include <trace/irq_event_types.h>
 #include <trace/lockdep_event_types.h>
 #include <trace/skb_event_types.h>
+#include <trace/kmem_event_types.h>
include/trace/trace_events.h +1 -0
index 0e2aa80..13d6b85 100644
@@ -4,3 +4,4 @@
 #include <trace/irq.h>
 #include <trace/lockdep.h>
 #include <trace/skb.h>
+#include <trace/kmem.h>
Signature · 1 line
1.5.5.3
author
#2 lore raw

Re: [PATCH 2/2] tracepoint: Make kmem tracepoint use TRACE_EVENT macro

Quoted 11 lines · Zhaolei

TRACE_EVENT is more unify and generic for define a tracepoint. It also add ftrace support for this tracepoint.

---
 include/trace/kmem.h              |   39 +-------
 include/trace/kmem_event_types.h  |  193 +++++++++++++++++++++++++++++++++++++
 include/trace/trace_event_types.h |    1 +
 include/trace/trace_events.h      |    1 +
 4 files changed, 197 insertions(+), 37 deletions(-)
 create mode 100644 include/trace/kmem_event_types.h

Sorry for notice that this patch must apply on top of skb's TRACE_EVENT patch:
[PATCH] Tracepoint: Make skb tracepoint use TRACE_EVENT macro

Because both patch need to add a line into include/trace/trace_event_types.h and include/trace/trace_events.h.

Thanks
Zhaolei

#5 lore raw
In reply to Zhaolei
Quoted 10 lines · Zhaolei

Current kmemtrace.h is used both as header file of kmemtrace and kmem's tracepoints definition.
Tracepoints' definition file may be used by other code, and should only have definition of tracepoint.

We can separate include/trace/kmemtrace.h into 2 files:
include/linux/kmemtrace.h: header file for kmemtrace
include/trace/kmem.h: definition of kmem tracepoints

Quoted 14 lines
---
 include/linux/kmemtrace.h             |   25 +++++++++++++++++++++++++
 include/linux/slab_def.h              |    2 +-
 include/linux/slub_def.h              |    2 +-
 include/trace/{kmemtrace.h => kmem.h} |   25 +++----------------------
 init/main.c                           |    2 +-
 kernel/trace/kmemtrace.c              |    2 +-
 kernel/trace/trace.h                  |    2 +-
 mm/slab.c                             |    2 +-
 mm/slob.c                             |    2 +-
 mm/slub.c                             |    2 +-
 10 files changed, 36 insertions(+), 30 deletions(-)
 create mode 100644 include/linux/kmemtrace.h
 rename include/trace/{kmemtrace.h => kmem.h} (78%)

Pekka, Eduard, do you agree with these two patches? Converting those tracepoints to TRACE_EVENT() is really nice. The above include file restructuring makes sense too - it separates tracepoint definition from the plugin init method.

Ingo

#3 lore raw

Re: [PATCH 2/2] tracepoint: Make kmem tracepoint use TRACE_EVENT macro

In reply to Zhaolei
Quoted 5 lines · Zhaolei

TRACE_EVENT is more unify and generic for define a tracepoint. It also add ftrace support for this tracepoint.

---

Nice!
It would be good to also propagate this conversion to some other tracers. It think about power, workqueue and block tracers.

I may have some time to work on the workqueue tracer soon.

Another idea: I plan to provide an "enable" file per trace event subsystem so that we can quickly toggle a whole batch of event tracing for any targeted subsystem.

Ingo also suggested a quick toggle for all events. As an end result, me would have a hierarchical level of enable files:

./events

	enable
	subsys1/
		enable
		subsys1_event1/
			enable
			....
		subsys1_event2/
		...
	subsys2/
		enable
		subsys2_event1/
		subsys2_event2/
		...
	...

I will work on it.
The root enable file will be only useful for quick regression tests anyway. We will have some suprises.... :-)

Thanks,
Frederic.

Quoted 279 lines
 include/trace/kmem.h              |   39 +-------
 include/trace/kmem_event_types.h  |  193 +++++++++++++++++++++++++++++++++++++
 include/trace/trace_event_types.h |    1 +
 include/trace/trace_events.h      |    1 +
 4 files changed, 197 insertions(+), 37 deletions(-)
 create mode 100644 include/trace/kmem_event_types.h
include/trace/kmem.h +2 -37
index 24d2519..46efc24 100644
@@ -1,44 +1,9 @@
 #ifndef _TRACE_KMEM_H
 #define _TRACE_KMEM_H
 
-#include <linux/tracepoint.h>
 #include <linux/types.h>
+#include <linux/tracepoint.h>
 
-DECLARE_TRACE(kmalloc,
-	      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));
-DECLARE_TRACE(kmem_cache_alloc,
-	      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));
-DECLARE_TRACE(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_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node));
-DECLARE_TRACE(kmem_cache_alloc_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));
-DECLARE_TRACE(kfree,
-	      TP_PROTO(unsigned long call_site, const void *ptr),
-	      TP_ARGS(call_site, ptr));
-DECLARE_TRACE(kmem_cache_free,
-	      TP_PROTO(unsigned long call_site, const void *ptr),
-	      TP_ARGS(call_site, ptr));
+#include <trace/kmem_event_types.h>
 
 #endif /* _TRACE_KMEM_H */
include/trace/kmem_event_types.h new file +193 -0
new file mode 100644
index 0000000..4ff420f
@@ -0,0 +1,193 @@
+
+/* use <trace/kmem.h> instead */
+#ifndef TRACE_EVENT
+# error Do not include this file directly.
+# error Unless you know what you are doing.
+#endif
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM kmem
+
+TRACE_EVENT(kmalloc,
+
+	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_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	)
+	),
+
+	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_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%08x",
+		__entry->call_site,
+		__entry->ptr,
+		__entry->bytes_req,
+		__entry->bytes_alloc,
+		__entry->gfp_flags)
+);
+
+TRACE_EVENT(kmem_cache_alloc,
+
+	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_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	)
+	),
+
+	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_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%08x",
+		__entry->call_site,
+		__entry->ptr,
+		__entry->bytes_req,
+		__entry->bytes_alloc,
+		__entry->gfp_flags)
+);
+
+TRACE_EVENT(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_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		)
+	),
+
+	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_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%08x node=%d",
+		__entry->call_site,
+		__entry->ptr,
+		__entry->bytes_req,
+		__entry->bytes_alloc,
+		__entry->gfp_flags,
+		__entry->node)
+);
+
+TRACE_EVENT(kmem_cache_alloc_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_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		)
+	),
+
+	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_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%08x node=%d",
+		__entry->call_site,
+		__entry->ptr,
+		__entry->bytes_req,
+		__entry->bytes_alloc,
+		__entry->gfp_flags,
+		__entry->node)
+);
+
+TRACE_EVENT(kfree,
+
+	TP_PROTO(unsigned long call_site, const void *ptr),
+
+	TP_ARGS(call_site, ptr),
+
+	TP_STRUCT__entry(
+		__field(	unsigned long,	call_site	)
+		__field(	const void *,	ptr		)
+	),
+
+	TP_fast_assign(
+		__entry->call_site	= call_site;
+		__entry->ptr		= ptr;
+	),
+
+	TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
+);
+
+TRACE_EVENT(kmem_cache_free,
+
+	TP_PROTO(unsigned long call_site, const void *ptr),
+
+	TP_ARGS(call_site, ptr),
+
+	TP_STRUCT__entry(
+		__field(	unsigned long,	call_site	)
+		__field(	const void *,	ptr		)
+	),
+
+	TP_fast_assign(
+		__entry->call_site	= call_site;
+		__entry->ptr		= ptr;
+	),
+
+	TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
+);
+
+#undef TRACE_SYSTEM
include/trace/trace_event_types.h +1 -0
index 33b6bfc..552a50e 100644
@@ -4,3 +4,4 @@
 #include <trace/irq_event_types.h>
 #include <trace/lockdep_event_types.h>
 #include <trace/skb_event_types.h>
+#include <trace/kmem_event_types.h>
include/trace/trace_events.h +1 -0
index 0e2aa80..13d6b85 100644
@@ -4,3 +4,4 @@
 #include <trace/irq.h>
 #include <trace/lockdep.h>
 #include <trace/skb.h>
+#include <trace/kmem.h>
Signature · 1 line
1.5.5.3
#6 lore raw
In reply to Ingo Molnar
Quoted 28 lines · Ingo Molnar
Quoted 10 lines · Zhaolei

Current kmemtrace.h is used both as header file of kmemtrace and kmem's tracepoints definition.
Tracepoints' definition file may be used by other code, and should only have definition of tracepoint.

We can separate include/trace/kmemtrace.h into 2 files:
include/linux/kmemtrace.h: header file for kmemtrace
include/trace/kmem.h: definition of kmem tracepoints

Quoted 14 lines
---
 include/linux/kmemtrace.h             |   25 +++++++++++++++++++++++++
 include/linux/slab_def.h              |    2 +-
 include/linux/slub_def.h              |    2 +-
 include/trace/{kmemtrace.h => kmem.h} |   25 +++----------------------
 init/main.c                           |    2 +-
 kernel/trace/kmemtrace.c              |    2 +-
 kernel/trace/trace.h                  |    2 +-
 mm/slab.c                             |    2 +-
 mm/slob.c                             |    2 +-
 mm/slub.c                             |    2 +-
 10 files changed, 36 insertions(+), 30 deletions(-)
 create mode 100644 include/linux/kmemtrace.h
 rename include/trace/{kmemtrace.h => kmem.h} (78%)
Quoted 6 lines

Pekka, Eduard, do you agree with these two patches? Converting those tracepoints to TRACE_EVENT() is really nice. The above include file restructuring makes sense too - it separates tracepoint definition from the plugin init method.

Ingo

Yes, these two patches look great. The first one makes the kmem tracepoints usable by other things (e.g. kmemcheck) in a kmemtrace-independent fashion, which is nice. Thanks, Zhao.

One thing I don't actually get is why have kmem_event_types.h separate from kmem.h, but it's not really an issue, I see other tracers doing the same thing. Other than that, it looks fine although I didn't test. Here's the ack if you need it:

Pekka?

Eduard

Applied
#7 lore raw
Quoted 41 lines · Eduard - Gabriel Munteanu
Quoted 28 lines · Ingo Molnar
Quoted 10 lines · Zhaolei

Current kmemtrace.h is used both as header file of kmemtrace and kmem's tracepoints definition.
Tracepoints' definition file may be used by other code, and should only have definition of tracepoint.

We can separate include/trace/kmemtrace.h into 2 files:
include/linux/kmemtrace.h: header file for kmemtrace
include/trace/kmem.h: definition of kmem tracepoints

Quoted 14 lines
---
 include/linux/kmemtrace.h             |   25 +++++++++++++++++++++++++
 include/linux/slab_def.h              |    2 +-
 include/linux/slub_def.h              |    2 +-
 include/trace/{kmemtrace.h => kmem.h} |   25 +++----------------------
 init/main.c                           |    2 +-
 kernel/trace/kmemtrace.c              |    2 +-
 kernel/trace/trace.h                  |    2 +-
 mm/slab.c                             |    2 +-
 mm/slob.c                             |    2 +-
 mm/slub.c                             |    2 +-
 10 files changed, 36 insertions(+), 30 deletions(-)
 create mode 100644 include/linux/kmemtrace.h
 rename include/trace/{kmemtrace.h => kmem.h} (78%)
Quoted 6 lines

Pekka, Eduard, do you agree with these two patches? Converting those tracepoints to TRACE_EVENT() is really nice. The above include file restructuring makes sense too - it separates tracepoint definition from the plugin init method.

Ingo

Yes, these two patches look great. The first one makes the kmem tracepoints usable by other things (e.g. kmemcheck) in a kmemtrace-independent fashion, which is nice. Thanks, Zhao.

Quoted 6 lines

One thing I don't actually get is why have kmem_event_types.h separate from kmem.h, but it's not really an issue, I see other tracers doing the same thing. Other than that, it looks fine although I didn't test. Here's the ack if you need it:

I've applied the patches to tip:tracing/ftrace - thanks guys!

The separation of kmem.h from kmem_event_types.h is mainly to keep the generic event definitions separate from other 'glue'. Indeed it looks a bit artificial here.

Ingo

#8 lore raw

[tip:tracing/core] tracing, kmemtrace: Separate include/trace/kmemtrace.h to kmemtrace part and tracepoint part

In reply to Zhaolei
Commit-ID:  02af61bb50f5d5f0322dbe5ab2a0d75808d25c7b
Gitweb:     http://git.kernel.org/tip/02af61bb50f5d5f0322dbe5ab2a0d75808d25c7b
Author:     Zhaolei <[email protected]>
AuthorDate: Fri, 10 Apr 2009 14:26:18 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sun, 12 Apr 2009 15:22:55 +0200

tracing, kmemtrace: Separate include/trace/kmemtrace.h to kmemtrace part and tracepoint part

Impact: refactor code for future changes

Current kmemtrace.h is used both as header file of kmemtrace and kmem's tracepoints definition.

Tracepoints' definition file may be used by other code, and should only have definition of tracepoint.

We can separate include/trace/kmemtrace.h into 2 files:

include/linux/kmemtrace.h: header file for kmemtrace
include/trace/kmem.h: definition of kmem tracepoints

LKML-Reference: <[email protected]>

---
 include/linux/kmemtrace.h |   25 ++++++++++++++++++
 include/linux/slab_def.h  |    2 +-
 include/linux/slub_def.h  |    2 +-
 include/trace/kmem.h      |   44 +++++++++++++++++++++++++++++++
 include/trace/kmemtrace.h |   63 ---------------------------------------------
 init/main.c               |    2 +-
 kernel/trace/kmemtrace.c  |    2 +-
 kernel/trace/trace.h      |    2 +-
 mm/slab.c                 |    2 +-
 mm/slob.c                 |    2 +-
 mm/slub.c                 |    2 +-
 11 files changed, 77 insertions(+), 71 deletions(-)
include/linux/kmemtrace.h new file +25 -0
new file mode 100644
index 0000000..15c45a2
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2008 Eduard - Gabriel Munteanu
+ *
+ * This file is released under GPL version 2.
+ */
+
+#ifndef _LINUX_KMEMTRACE_H
+#define _LINUX_KMEMTRACE_H
+
+#ifdef __KERNEL__
+
+#include <trace/kmem.h>
+
+#ifdef CONFIG_KMEMTRACE
+extern void kmemtrace_init(void);
+#else
+static inline void kmemtrace_init(void)
+{
+}
+#endif
+
+#endif /* __KERNEL__ */
+
+#endif /* _LINUX_KMEMTRACE_H */
+
include/linux/slab_def.h +1 -1
index 5ac9b0b..713f841 100644
@@ -14,7 +14,7 @@
 #include <asm/page.h>		/* kmalloc_sizes.h needs PAGE_SIZE */
 #include <asm/cache.h>		/* kmalloc_sizes.h needs L1_CACHE_BYTES */
 #include <linux/compiler.h>
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 
 /* Size description struct for general caches. */
 struct cache_sizes {
include/linux/slub_def.h +1 -1
index 5046f90..be5d40c 100644
@@ -10,7 +10,7 @@
 #include <linux/gfp.h>
 #include <linux/workqueue.h>
 #include <linux/kobject.h>
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 
 enum stat_item {
 	ALLOC_FASTPATH,		/* Allocation from cpu slab */
include/trace/kmem.h new file +44 -0

44 lines not on this page · raw message

include/trace/kmemtrace.h deleted +0 -63

63 lines not on this page · raw message

init/main.c +1 -1
index 3585f07..eece40c 100644
@@ -64,6 +64,7 @@
 #include <linux/idr.h>
 #include <linux/ftrace.h>
 #include <linux/async.h>
+#include <linux/kmemtrace.h>
 #include <trace/boot.h>
 
 #include <asm/io.h>
@@ -71,7 +72,6 @@
 #include <asm/setup.h>
 #include <asm/sections.h>
 #include <asm/cacheflush.h>
-#include <trace/kmemtrace.h>
 
 #ifdef CONFIG_X86_LOCAL_APIC
 #include <asm/smp.h>
kernel/trace/kmemtrace.c +1 -1
index 5011f4d..7a0aa0e 100644
@@ -12,7 +12,7 @@
 #include <linux/dcache.h>
 #include <linux/fs.h>
 
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 
 #include "trace_output.h"
 #include "trace.h"
kernel/trace/trace.h +1 -1
index f76a8f8..34b94c3 100644
@@ -9,7 +9,7 @@
 #include <linux/mmiotrace.h>
 #include <linux/ftrace.h>
 #include <trace/boot.h>
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 #include <trace/power.h>
 
 enum trace_type {
mm/slab.c +1 -1
index 9a90b00..f85831d 100644
@@ -102,7 +102,7 @@
 #include	<linux/cpu.h>
 #include	<linux/sysctl.h>
 #include	<linux/module.h>
-#include	<trace/kmemtrace.h>
+#include	<linux/kmemtrace.h>
 #include	<linux/rcupdate.h>
 #include	<linux/string.h>
 #include	<linux/uaccess.h>
mm/slob.c +1 -1
index a2d4ab3..494f05f 100644
@@ -65,7 +65,7 @@
 #include <linux/module.h>
 #include <linux/rcupdate.h>
 #include <linux/list.h>
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 #include <asm/atomic.h>
 
 /*
mm/slub.c +1 -1
index 7ab54ec..ea9e716 100644
@@ -16,7 +16,7 @@
 #include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 #include <linux/cpu.h>
 #include <linux/cpuset.h>
 #include <linux/mempolicy.h>
#4 lore raw

[tip:tracing/core] tracing, kmemtrace: Make kmem tracepoints use TRACE_EVENT macro

In reply to Zhaolei
Commit-ID:  fc182a4330fc22ea1b68fa3d5064dd85a73a4c4a
Gitweb:     http://git.kernel.org/tip/fc182a4330fc22ea1b68fa3d5064dd85a73a4c4a
Author:     Zhaolei <[email protected]>
AuthorDate: Fri, 10 Apr 2009 14:27:38 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sun, 12 Apr 2009 15:22:56 +0200

tracing, kmemtrace: Make kmem tracepoints use TRACE_EVENT macro

TRACE_EVENT is a more generic way to define tracepoints. Doing so adds these new capabilities to this tracepoint:

- zero-copy and per-cpu splice() tracing
- binary tracing without printf overhead
- structured logging records exposed under /debug/tracing/events
- trace events embedded in function tracer output and other plugins
- user-defined, per tracepoint filter expressions

LKML-Reference: <[email protected]>

---
 include/trace/kmem.h              |   39 +-------
 include/trace/kmem_event_types.h  |  193 +++++++++++++++++++++++++++++++++++++
 include/trace/trace_event_types.h |    1 +
 include/trace/trace_events.h      |    1 +
 4 files changed, 197 insertions(+), 37 deletions(-)
include/trace/kmem.h +2 -37
index 24d2519..46efc24 100644
@@ -1,44 +1,9 @@
 #ifndef _TRACE_KMEM_H
 #define _TRACE_KMEM_H
 
-#include <linux/tracepoint.h>
 #include <linux/types.h>
+#include <linux/tracepoint.h>
 
-DECLARE_TRACE(kmalloc,
-	      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));
-DECLARE_TRACE(kmem_cache_alloc,
-	      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));
-DECLARE_TRACE(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_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node));
-DECLARE_TRACE(kmem_cache_alloc_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));
-DECLARE_TRACE(kfree,
-	      TP_PROTO(unsigned long call_site, const void *ptr),
-	      TP_ARGS(call_site, ptr));
-DECLARE_TRACE(kmem_cache_free,
-	      TP_PROTO(unsigned long call_site, const void *ptr),
-	      TP_ARGS(call_site, ptr));
+#include <trace/kmem_event_types.h>
 
 #endif /* _TRACE_KMEM_H */
include/trace/kmem_event_types.h new file +193 -0

193 lines not on this page · raw message

include/trace/trace_event_types.h +1 -0
index 33b6bfc..552a50e 100644
@@ -4,3 +4,4 @@
 #include <trace/irq_event_types.h>
 #include <trace/lockdep_event_types.h>
 #include <trace/skb_event_types.h>
+#include <trace/kmem_event_types.h>
include/trace/trace_events.h +1 -0
index 0e2aa80..13d6b85 100644
@@ -4,3 +4,4 @@
 #include <trace/irq.h>
 #include <trace/lockdep.h>
 #include <trace/skb.h>
+#include <trace/kmem.h>