tracing, mm: Record pfn instead of pointer to struct page
authorNamhyung Kim <namhyung@kernel.org>
Mon, 6 Apr 2015 05:36:09 +0000 (14:36 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 13 Apr 2015 14:44:52 +0000 (11:44 -0300)
The struct page is opaque for userspace tools, so it'd be better to save
pfn in order to identify page frames.

The textual output of $debugfs/tracing/trace file remains unchanged and
only raw (binary) data format is changed - but thanks to libtraceevent,
userspace tools which deal with the raw data (like perf and trace-cmd)
can parse the format easily.  So impact on the userspace will also be
minimal.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Based-on-patch-by: Joonsoo Kim <js1304@gmail.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/1428298576-9785-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
include/trace/events/filemap.h
include/trace/events/kmem.h
include/trace/events/vmscan.h

index 0421f49a20f7a2af50ca0ab7e7280455d1871367..42febb6bc1d56a00256a62cbb9149c3b5e3c92a7 100644 (file)
@@ -18,14 +18,14 @@ DECLARE_EVENT_CLASS(mm_filemap_op_page_cache,
        TP_ARGS(page),
 
        TP_STRUCT__entry(
-               __field(struct page *, page)
+               __field(unsigned long, pfn)
                __field(unsigned long, i_ino)
                __field(unsigned long, index)
                __field(dev_t, s_dev)
        ),
 
        TP_fast_assign(
-               __entry->page = page;
+               __entry->pfn = page_to_pfn(page);
                __entry->i_ino = page->mapping->host->i_ino;
                __entry->index = page->index;
                if (page->mapping->host->i_sb)
@@ -37,8 +37,8 @@ DECLARE_EVENT_CLASS(mm_filemap_op_page_cache,
        TP_printk("dev %d:%d ino %lx page=%p pfn=%lu ofs=%lu",
                MAJOR(__entry->s_dev), MINOR(__entry->s_dev),
                __entry->i_ino,
-               __entry->page,
-               page_to_pfn(__entry->page),
+               pfn_to_page(__entry->pfn),
+               __entry->pfn,
                __entry->index << PAGE_SHIFT)
 );
 
index 4ad10baecd4dcddbb47e503ccc41b1c309aaba3c..81ea598121173bf782c04f7c6bfae63b5207b75e 100644 (file)
@@ -154,18 +154,18 @@ TRACE_EVENT(mm_page_free,
        TP_ARGS(page, order),
 
        TP_STRUCT__entry(
-               __field(        struct page *,  page            )
+               __field(        unsigned long,  pfn             )
                __field(        unsigned int,   order           )
        ),
 
        TP_fast_assign(
-               __entry->page           = page;
+               __entry->pfn            = page_to_pfn(page);
                __entry->order          = order;
        ),
 
        TP_printk("page=%p pfn=%lu order=%d",
-                       __entry->page,
-                       page_to_pfn(__entry->page),
+                       pfn_to_page(__entry->pfn),
+                       __entry->pfn,
                        __entry->order)
 );
 
@@ -176,18 +176,18 @@ TRACE_EVENT(mm_page_free_batched,
        TP_ARGS(page, cold),
 
        TP_STRUCT__entry(
-               __field(        struct page *,  page            )
+               __field(        unsigned long,  pfn             )
                __field(        int,            cold            )
        ),
 
        TP_fast_assign(
-               __entry->page           = page;
+               __entry->pfn            = page_to_pfn(page);
                __entry->cold           = cold;
        ),
 
        TP_printk("page=%p pfn=%lu order=0 cold=%d",
-                       __entry->page,
-                       page_to_pfn(__entry->page),
+                       pfn_to_page(__entry->pfn),
+                       __entry->pfn,
                        __entry->cold)
 );
 
@@ -199,22 +199,22 @@ TRACE_EVENT(mm_page_alloc,
        TP_ARGS(page, order, gfp_flags, migratetype),
 
        TP_STRUCT__entry(
-               __field(        struct page *,  page            )
+               __field(        unsigned long,  pfn             )
                __field(        unsigned int,   order           )
                __field(        gfp_t,          gfp_flags       )
                __field(        int,            migratetype     )
        ),
 
        TP_fast_assign(
-               __entry->page           = page;
+               __entry->pfn            = page ? page_to_pfn(page) : -1UL;
                __entry->order          = order;
                __entry->gfp_flags      = gfp_flags;
                __entry->migratetype    = migratetype;
        ),
 
        TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
-               __entry->page,
-               __entry->page ? page_to_pfn(__entry->page) : 0,
+               __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,
+               __entry->pfn != -1UL ? __entry->pfn : 0,
                __entry->order,
                __entry->migratetype,
                show_gfp_flags(__entry->gfp_flags))
@@ -227,20 +227,20 @@ DECLARE_EVENT_CLASS(mm_page,
        TP_ARGS(page, order, migratetype),
 
        TP_STRUCT__entry(
-               __field(        struct page *,  page            )
+               __field(        unsigned long,  pfn             )
                __field(        unsigned int,   order           )
                __field(        int,            migratetype     )
        ),
 
        TP_fast_assign(
-               __entry->page           = page;
+               __entry->pfn            = page ? page_to_pfn(page) : -1UL;
                __entry->order          = order;
                __entry->migratetype    = migratetype;
        ),
 
        TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
-               __entry->page,
-               __entry->page ? page_to_pfn(__entry->page) : 0,
+               __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,
+               __entry->pfn != -1UL ? __entry->pfn : 0,
                __entry->order,
                __entry->migratetype,
                __entry->order == 0)
@@ -260,7 +260,7 @@ DEFINE_EVENT_PRINT(mm_page, mm_page_pcpu_drain,
        TP_ARGS(page, order, migratetype),
 
        TP_printk("page=%p pfn=%lu order=%d migratetype=%d",
-               __entry->page, page_to_pfn(__entry->page),
+               pfn_to_page(__entry->pfn), __entry->pfn,
                __entry->order, __entry->migratetype)
 );
 
@@ -275,7 +275,7 @@ TRACE_EVENT(mm_page_alloc_extfrag,
                alloc_migratetype, fallback_migratetype),
 
        TP_STRUCT__entry(
-               __field(        struct page *,  page                    )
+               __field(        unsigned long,  pfn                     )
                __field(        int,            alloc_order             )
                __field(        int,            fallback_order          )
                __field(        int,            alloc_migratetype       )
@@ -284,7 +284,7 @@ TRACE_EVENT(mm_page_alloc_extfrag,
        ),
 
        TP_fast_assign(
-               __entry->page                   = page;
+               __entry->pfn                    = page_to_pfn(page);
                __entry->alloc_order            = alloc_order;
                __entry->fallback_order         = fallback_order;
                __entry->alloc_migratetype      = alloc_migratetype;
@@ -294,8 +294,8 @@ TRACE_EVENT(mm_page_alloc_extfrag,
        ),
 
        TP_printk("page=%p pfn=%lu alloc_order=%d fallback_order=%d pageblock_order=%d alloc_migratetype=%d fallback_migratetype=%d fragmenting=%d change_ownership=%d",
-               __entry->page,
-               page_to_pfn(__entry->page),
+               pfn_to_page(__entry->pfn),
+               __entry->pfn,
                __entry->alloc_order,
                __entry->fallback_order,
                pageblock_order,
index 69590b6ffc091116911b29dffbb64871bd9f92b1..f66476b96264cec3cc11f7797bd8fb3acac64de7 100644 (file)
@@ -336,18 +336,18 @@ TRACE_EVENT(mm_vmscan_writepage,
        TP_ARGS(page, reclaim_flags),
 
        TP_STRUCT__entry(
-               __field(struct page *, page)
+               __field(unsigned long, pfn)
                __field(int, reclaim_flags)
        ),
 
        TP_fast_assign(
-               __entry->page = page;
+               __entry->pfn = page_to_pfn(page);
                __entry->reclaim_flags = reclaim_flags;
        ),
 
        TP_printk("page=%p pfn=%lu flags=%s",
-               __entry->page,
-               page_to_pfn(__entry->page),
+               pfn_to_page(__entry->pfn),
+               __entry->pfn,
                show_reclaim_flags(__entry->reclaim_flags))
 );