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
Signed-off-by: Zhao Lei <[email protected]>
---
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%)
diff --git a/include/linux/kmemtrace.h b/include/linux/kmemtrace.h
new file mode 100644
index 0000000..15c45a2
--- /dev/null
+++ b/include/linux/kmemtrace.h
@@ -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 */
+
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index 1a78b7a..850d057 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -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
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 5046f90..be5d40c 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -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 */
diff --git a/include/trace/kmemtrace.h b/include/trace/kmem.h
similarity index 78%
rename from include/trace/kmemtrace.h
rename to include/trace/kmem.h
index 28ee69f..24d2519 100644
--- a/include/trace/kmemtrace.h
+++ b/include/trace/kmem.h
@@ -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 */
diff --git a/init/main.c b/init/main.c
index ed702d9..694a563 100644
--- a/init/main.c
+++ b/init/main.c
@@ -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>
diff --git a/kernel/trace/kmemtrace.c b/kernel/trace/kmemtrace.c
index 91cd0a5..86cdf67 100644
--- a/kernel/trace/kmemtrace.c
+++ b/kernel/trace/kmemtrace.c
@@ -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"
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index ee23ea2..ce6bdc4 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -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 {
diff --git a/mm/slab.c b/mm/slab.c
index 6bf8a95..762acc2 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -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>
diff --git a/mm/slob.c b/mm/slob.c
index a2d4ab3..494f05f 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -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>
/*
diff --git a/mm/slub.c b/mm/slub.c
index 4ac5e3e..a98d456 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -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>
--
1.5.5.3
TRACE_EVENT is more unify and generic for define a tracepoint.
It also add ftrace support for this tracepoint.
Signed-off-by: Zhao Lei <[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(-)
create mode 100644 include/trace/kmem_event_types.h
diff --git a/include/trace/kmem.h b/include/trace/kmem.h
index 24d2519..46efc24 100644
--- a/include/trace/kmem.h
+++ b/include/trace/kmem.h
@@ -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 */
diff --git a/include/trace/kmem_event_types.h b/include/trace/kmem_event_types.h
new file mode 100644
index 0000000..4ff420f
--- /dev/null
+++ b/include/trace/kmem_event_types.h
@@ -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
diff --git a/include/trace/trace_event_types.h b/include/trace/trace_event_types.h
index 33b6bfc..552a50e 100644
--- a/include/trace/trace_event_types.h
+++ b/include/trace/trace_event_types.h
@@ -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>
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 0e2aa80..13d6b85 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -4,3 +4,4 @@
#include <trace/irq.h>
#include <trace/lockdep.h>
#include <trace/skb.h>
+#include <trace/kmem.h>
--
1.5.5.3
Zhaolei wrote:
> TRACE_EVENT is more unify and generic for define a tracepoint.
> It also add ftrace support for this tracepoint.
>
> Signed-off-by: Zhao Lei <[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(-)
> 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
* Zhaolei <[email protected]> wrote:
> 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
>
> Signed-off-by: Zhao Lei <[email protected]>
> ---
> 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
On Fri, Apr 10, 2009 at 02:27:38PM +0800, Zhaolei wrote:
> TRACE_EVENT is more unify and generic for define a tracepoint.
> It also add ftrace support for this tracepoint.
>
> Signed-off-by: Zhao Lei <[email protected]>
> ---
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.
> 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
>
> diff --git a/include/trace/kmem.h b/include/trace/kmem.h
> index 24d2519..46efc24 100644
> --- a/include/trace/kmem.h
> +++ b/include/trace/kmem.h
> @@ -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 */
> diff --git a/include/trace/kmem_event_types.h b/include/trace/kmem_event_types.h
> new file mode 100644
> index 0000000..4ff420f
> --- /dev/null
> +++ b/include/trace/kmem_event_types.h
> @@ -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
> diff --git a/include/trace/trace_event_types.h b/include/trace/trace_event_types.h
> index 33b6bfc..552a50e 100644
> --- a/include/trace/trace_event_types.h
> +++ b/include/trace/trace_event_types.h
> @@ -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>
> diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
> index 0e2aa80..13d6b85 100644
> --- a/include/trace/trace_events.h
> +++ b/include/trace/trace_events.h
> @@ -4,3 +4,4 @@
> #include <trace/irq.h>
> #include <trace/lockdep.h>
> #include <trace/skb.h>
> +#include <trace/kmem.h>
> --
> 1.5.5.3
>
>
On Fri, Apr 10, 2009 at 01:03:03PM +0200, Ingo Molnar wrote:
>
> * Zhaolei <[email protected]> wrote:
>
> > 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
> >
> > Signed-off-by: Zhao Lei <[email protected]>
> > ---
> > 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
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:
Acked-by: Eduard - Gabriel Munteanu <[email protected]>
Pekka?
Eduard
* Eduard - Gabriel Munteanu <[email protected]> wrote:
> On Fri, Apr 10, 2009 at 01:03:03PM +0200, Ingo Molnar wrote:
> >
> > * Zhaolei <[email protected]> wrote:
> >
> > > 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
> > >
> > > Signed-off-by: Zhao Lei <[email protected]>
> > > ---
> > > 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
>
> 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:
>
> Acked-by: Eduard - Gabriel Munteanu <[email protected]>
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
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
Signed-off-by: Zhao Lei <[email protected]>
Acked-by: Eduard - Gabriel Munteanu <[email protected]>
Acked-by: Pekka Enberg <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Tom Zanussi <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[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(-)
diff --git a/include/linux/kmemtrace.h b/include/linux/kmemtrace.h
new file mode 100644
index 0000000..15c45a2
--- /dev/null
+++ b/include/linux/kmemtrace.h
@@ -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 */
+
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index 5ac9b0b..713f841 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -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 {
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 5046f90..be5d40c 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -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 */
diff --git a/include/trace/kmem.h b/include/trace/kmem.h
new file mode 100644
index 0000000..24d2519
--- /dev/null
+++ b/include/trace/kmem.h
@@ -0,0 +1,44 @@
+#ifndef _TRACE_KMEM_H
+#define _TRACE_KMEM_H
+
+#include <linux/tracepoint.h>
+#include <linux/types.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));
+
+#endif /* _TRACE_KMEM_H */
diff --git a/include/trace/kmemtrace.h b/include/trace/kmemtrace.h
deleted file mode 100644
index 28ee69f..0000000
--- a/include/trace/kmemtrace.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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 <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,
- 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));
-
-#endif /* __KERNEL__ */
-
-#endif /* _LINUX_KMEMTRACE_H */
-
diff --git a/init/main.c b/init/main.c
index 3585f07..eece40c 100644
--- a/init/main.c
+++ b/init/main.c
@@ -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>
diff --git a/kernel/trace/kmemtrace.c b/kernel/trace/kmemtrace.c
index 5011f4d..7a0aa0e 100644
--- a/kernel/trace/kmemtrace.c
+++ b/kernel/trace/kmemtrace.c
@@ -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"
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index f76a8f8..34b94c3 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -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 {
diff --git a/mm/slab.c b/mm/slab.c
index 9a90b00..f85831d 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -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>
diff --git a/mm/slob.c b/mm/slob.c
index a2d4ab3..494f05f 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -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>
/*
diff --git a/mm/slub.c b/mm/slub.c
index 7ab54ec..ea9e716 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -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>
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
Signed-off-by: Zhao Lei <[email protected]>
Acked-by: Eduard - Gabriel Munteanu <[email protected]>
Acked-by: Pekka Enberg <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Tom Zanussi <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[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(-)
diff --git a/include/trace/kmem.h b/include/trace/kmem.h
index 24d2519..46efc24 100644
--- a/include/trace/kmem.h
+++ b/include/trace/kmem.h
@@ -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 */
diff --git a/include/trace/kmem_event_types.h b/include/trace/kmem_event_types.h
new file mode 100644
index 0000000..4ff420f
--- /dev/null
+++ b/include/trace/kmem_event_types.h
@@ -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
diff --git a/include/trace/trace_event_types.h b/include/trace/trace_event_types.h
index 33b6bfc..552a50e 100644
--- a/include/trace/trace_event_types.h
+++ b/include/trace/trace_event_types.h
@@ -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>
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 0e2aa80..13d6b85 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -4,3 +4,4 @@
#include <trace/irq.h>
#include <trace/lockdep.h>
#include <trace/skb.h>
+#include <trace/kmem.h>