Commit 53d0422c authored by Li Zefan's avatar Li Zefan Committed by Ingo Molnar

tracing: Convert some kmem events to DEFINE_EVENT

Use DECLARE_EVENT_CLASS to remove duplicate code:

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

8 events are converted:

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

No change in functionality.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Acked-by: default avatarPekka Enberg <penberg@cs.helsinki.fi>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mel Gorman <mel@csn.ul.ie>
LKML-Reference: <4B0E286A.2000405@cn.fujitsu.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 925684d6
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
{(unsigned long)__GFP_MOVABLE, "GFP_MOVABLE"} \ {(unsigned long)__GFP_MOVABLE, "GFP_MOVABLE"} \
) : "GFP_NOWAIT" ) : "GFP_NOWAIT"
TRACE_EVENT(kmalloc, DECLARE_EVENT_CLASS(kmem_alloc,
TP_PROTO(unsigned long call_site, TP_PROTO(unsigned long call_site,
const void *ptr, const void *ptr,
...@@ -78,41 +78,23 @@ TRACE_EVENT(kmalloc, ...@@ -78,41 +78,23 @@ TRACE_EVENT(kmalloc,
show_gfp_flags(__entry->gfp_flags)) show_gfp_flags(__entry->gfp_flags))
); );
TRACE_EVENT(kmem_cache_alloc, DEFINE_EVENT(kmem_alloc, kmalloc,
TP_PROTO(unsigned long call_site, TP_PROTO(unsigned long call_site, const void *ptr,
const void *ptr, size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
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( DEFINE_EVENT(kmem_alloc, kmem_cache_alloc,
__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( TP_PROTO(unsigned long call_site, const void *ptr,
__entry->call_site = call_site; size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
__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=%s", TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
__entry->call_site,
__entry->ptr,
__entry->bytes_req,
__entry->bytes_alloc,
show_gfp_flags(__entry->gfp_flags))
); );
TRACE_EVENT(kmalloc_node, DECLARE_EVENT_CLASS(kmem_alloc_node,
TP_PROTO(unsigned long call_site, TP_PROTO(unsigned long call_site,
const void *ptr, const void *ptr,
...@@ -150,45 +132,25 @@ TRACE_EVENT(kmalloc_node, ...@@ -150,45 +132,25 @@ TRACE_EVENT(kmalloc_node,
__entry->node) __entry->node)
); );
TRACE_EVENT(kmem_cache_alloc_node, DEFINE_EVENT(kmem_alloc_node, kmalloc_node,
TP_PROTO(unsigned long call_site, TP_PROTO(unsigned long call_site, const void *ptr,
const void *ptr, size_t bytes_req, size_t bytes_alloc,
size_t bytes_req, gfp_t gfp_flags, int node),
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( DEFINE_EVENT(kmem_alloc_node, kmem_cache_alloc_node,
__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( TP_PROTO(unsigned long call_site, const void *ptr,
__entry->call_site = call_site; size_t bytes_req, size_t bytes_alloc,
__entry->ptr = ptr; gfp_t gfp_flags, int node),
__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=%s node=%d", TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
__entry->call_site,
__entry->ptr,
__entry->bytes_req,
__entry->bytes_alloc,
show_gfp_flags(__entry->gfp_flags),
__entry->node)
); );
TRACE_EVENT(kfree, DECLARE_EVENT_CLASS(kmem_free,
TP_PROTO(unsigned long call_site, const void *ptr), TP_PROTO(unsigned long call_site, const void *ptr),
...@@ -207,23 +169,18 @@ TRACE_EVENT(kfree, ...@@ -207,23 +169,18 @@ TRACE_EVENT(kfree,
TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr) 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_PROTO(unsigned long call_site, const void *ptr),
TP_ARGS(call_site, ptr), TP_ARGS(call_site, ptr)
);
TP_STRUCT__entry( DEFINE_EVENT(kmem_free, kmem_cache_free,
__field( unsigned long, call_site )
__field( const void *, ptr )
),
TP_fast_assign( TP_PROTO(unsigned long call_site, const void *ptr),
__entry->call_site = call_site;
__entry->ptr = ptr;
),
TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr) TP_ARGS(call_site, ptr)
); );
TRACE_EVENT(mm_page_free_direct, TRACE_EVENT(mm_page_free_direct,
...@@ -299,7 +256,7 @@ TRACE_EVENT(mm_page_alloc, ...@@ -299,7 +256,7 @@ TRACE_EVENT(mm_page_alloc,
show_gfp_flags(__entry->gfp_flags)) 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), TP_PROTO(struct page *page, unsigned int order, int migratetype),
...@@ -325,29 +282,22 @@ TRACE_EVENT(mm_page_alloc_zone_locked, ...@@ -325,29 +282,22 @@ TRACE_EVENT(mm_page_alloc_zone_locked,
__entry->order == 0) __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( DEFINE_EVENT_PRINT(mm_page, mm_page_pcpu_drain,
__field( struct page *, page )
__field( int, order )
__field( int, migratetype )
),
TP_fast_assign( TP_PROTO(struct page *page, unsigned int order, int migratetype),
__entry->page = page;
__entry->order = order; TP_ARGS(page, order, migratetype),
__entry->migratetype = migratetype;
),
TP_printk("page=%p pfn=%lu order=%d migratetype=%d", TP_printk("page=%p pfn=%lu order=%d migratetype=%d",
__entry->page, __entry->page, page_to_pfn(__entry->page),
page_to_pfn(__entry->page), __entry->order, __entry->migratetype)
__entry->order,
__entry->migratetype)
); );
TRACE_EVENT(mm_page_alloc_extfrag, TRACE_EVENT(mm_page_alloc_extfrag,
......
...@@ -48,12 +48,14 @@ ...@@ -48,12 +48,14 @@
#include <linux/page_cgroup.h> #include <linux/page_cgroup.h>
#include <linux/debugobjects.h> #include <linux/debugobjects.h>
#include <linux/kmemleak.h> #include <linux/kmemleak.h>
#include <trace/events/kmem.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
#include <asm/div64.h> #include <asm/div64.h>
#include "internal.h" #include "internal.h"
#define CREATE_TRACE_POINTS
#include <trace/events/kmem.h>
/* /*
* Array of node states. * Array of node states.
*/ */
......
...@@ -6,9 +6,6 @@ ...@@ -6,9 +6,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#define CREATE_TRACE_POINTS
#include <trace/events/kmem.h>
/** /**
* kstrdup - allocate space for and copy an existing string * kstrdup - allocate space for and copy an existing string
* @s: the string to duplicate * @s: the string to duplicate
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment