vmscan: tracing: add trace event when a page is written
authorMel Gorman <mel@csn.ul.ie>
Tue, 10 Aug 2010 00:19:18 +0000 (17:19 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 10 Aug 2010 03:45:00 +0000 (20:45 -0700)
Add a trace event for when page reclaim queues a page for IO and records
whether it is synchronous or asynchronous.  Excessive synchronous IO for a
process can result in noticeable stalls during direct reclaim.  Excessive
IO from page reclaim may indicate that the system is seriously under
provisioned for the amount of dirty pages that exist.

Signed-off-by: Mel Gorman <mel@csn.ul.ie>
Acked-by: Rik van Riel <riel@redhat.com>
Acked-by: Larry Woodman <lwoodman@redhat.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Michael Rubin <mrubin@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/trace/events/vmscan.h
mm/vmscan.c

index c0552be1f50acd04b530536e47091e09624377dc..69789dc721000a09e4d5b88a22c1818987ae3ed6 100644 (file)
@@ -8,6 +8,24 @@
 #include <linux/tracepoint.h>
 #include "gfpflags.h"
 
+#define RECLAIM_WB_ANON                0x0001u
+#define RECLAIM_WB_FILE                0x0002u
+#define RECLAIM_WB_SYNC                0x0004u
+#define RECLAIM_WB_ASYNC       0x0008u
+
+#define show_reclaim_flags(flags)                              \
+       (flags) ? __print_flags(flags, "|",                     \
+               {RECLAIM_WB_ANON,       "RECLAIM_WB_ANON"},     \
+               {RECLAIM_WB_FILE,       "RECLAIM_WB_FILE"},     \
+               {RECLAIM_WB_SYNC,       "RECLAIM_WB_SYNC"},     \
+               {RECLAIM_WB_ASYNC,      "RECLAIM_WB_ASYNC"}     \
+               ) : "RECLAIM_WB_NONE"
+
+#define trace_reclaim_flags(page, sync) ( \
+       (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
+       (sync == PAGEOUT_IO_SYNC ? RECLAIM_WB_SYNC : RECLAIM_WB_ASYNC)   \
+       )
+
 TRACE_EVENT(mm_vmscan_kswapd_sleep,
 
        TP_PROTO(int nid),
@@ -155,6 +173,29 @@ TRACE_EVENT(mm_vmscan_lru_isolate,
                __entry->nr_lumpy_failed)
 );
 
+TRACE_EVENT(mm_vmscan_writepage,
+
+       TP_PROTO(struct page *page,
+               int reclaim_flags),
+
+       TP_ARGS(page, reclaim_flags),
+
+       TP_STRUCT__entry(
+               __field(struct page *, page)
+               __field(int, reclaim_flags)
+       ),
+
+       TP_fast_assign(
+               __entry->page = page;
+               __entry->reclaim_flags = reclaim_flags;
+       ),
+
+       TP_printk("page=%p pfn=%lu flags=%s",
+               __entry->page,
+               page_to_pfn(__entry->page),
+               show_reclaim_flags(__entry->reclaim_flags))
+);
+
 #endif /* _TRACE_VMSCAN_H */
 
 /* This part must be outside protection */
index 3d006d91a526a8dc36daff4a06e8b11acb201558..b7a4e6a3cf89acbbc973493acf2498c51fa668a9 100644 (file)
@@ -401,6 +401,8 @@ static pageout_t pageout(struct page *page, struct address_space *mapping,
                        /* synchronous write or broken a_ops? */
                        ClearPageReclaim(page);
                }
+               trace_mm_vmscan_writepage(page,
+                       trace_reclaim_flags(page, sync_writeback));
                inc_zone_page_state(page, NR_VMSCAN_WRITE);
                return PAGE_SUCCESS;
        }