aboutsummaryrefslogtreecommitdiffstats
path: root/include/trace
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2013-07-03 18:02:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:07:31 -0400
commitc6286c983900c77410a951874f1589f4a41fbbae (patch)
tree3e4b1d2c2c4c783886f9c6e98770f4602273197c /include/trace
parentf968ef1c55199301e98c28fe7dfa8ace05ecdb96 (diff)
mm: add tracepoints for LRU activation and insertions
Andrew Perepechko reported a problem whereby pages are being prematurely evicted as the mark_page_accessed() hint is ignored for pages that are currently on a pagevec -- http://www.spinics.net/lists/linux-ext4/msg37340.html . Alexey Lyahkov and Robin Dong have also reported problems recently that could be due to hot pages reaching the end of the inactive list too quickly and be reclaimed. Rather than addressing this on a per-filesystem basis, this series aims to fix the mark_page_accessed() interface by deferring what LRU a page is added to pagevec drain time and allowing mark_page_accessed() to call SetPageActive on a pagevec page. Patch 1 adds two tracepoints for LRU page activation and insertion. Using these processes it's possible to build a model of pages in the LRU that can be processed offline. Patch 2 defers making the decision on what LRU to add a page to until when the pagevec is drained. Patch 3 searches the local pagevec for pages to mark PageActive on mark_page_accessed. The changelog explains why only the local pagevec is examined. Patches 4 and 5 tidy up the API. postmark, a dd-based test and fs-mark both single and threaded mode were run but none of them showed any performance degradation or gain as a result of the patch. Using patch 1, I built a *very* basic model of the LRU to examine offline what the average age of different page types on the LRU were in milliseconds. Of course, capturing the trace distorts the test as it's written to local disk but it does not matter for the purposes of this test. The average age of pages in milliseconds were vanilla deferdrain Average age mapped anon: 1454 1250 Average age mapped file: 127841 155552 Average age unmapped anon: 85 235 Average age unmapped file: 73633 38884 Average age unmapped buffers: 74054 116155 The LRU activity was mostly files which you'd expect for a dd-based workload. Note that the average age of buffer pages is increased by the series and it is expected this is due to the fact that the buffer pages are now getting added to the active list when drained from the pagevecs. Note that the average age of the unmapped file data is decreased as they are still added to the inactive list and are reclaimed before the buffers. There is no guarantee this is a universal win for all workloads and it would be nice if the filesystem people gave some thought as to whether this decision is generally a win or a loss. This patch: Using these tracepoints it is possible to model LRU activity and the average residency of pages of different types. This can be used to debug problems related to premature reclaim of pages of particular types. Signed-off-by: Mel Gorman <mgorman@suse.de> Reviewed-by: Rik van Riel <riel@redhat.com> Cc: Jan Kara <jack@suse.cz> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Alexey Lyahkov <alexey.lyashkov@gmail.com> Cc: Andrew Perepechko <anserper@ya.ru> Cc: Robin Dong <sanbai@taobao.com> Cc: Theodore Tso <tytso@mit.edu> Cc: Hugh Dickins <hughd@google.com> Cc: Rik van Riel <riel@redhat.com> Cc: Bernd Schubert <bernd.schubert@fastmail.fm> Cc: David Howells <dhowells@redhat.com> Cc: Trond Myklebust <Trond.Myklebust@netapp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/trace')
-rw-r--r--include/trace/events/pagemap.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/include/trace/events/pagemap.h b/include/trace/events/pagemap.h
new file mode 100644
index 000000000000..1c9fabde69e4
--- /dev/null
+++ b/include/trace/events/pagemap.h
@@ -0,0 +1,89 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM pagemap
3
4#if !defined(_TRACE_PAGEMAP_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_PAGEMAP_H
6
7#include <linux/tracepoint.h>
8#include <linux/mm.h>
9
10#define PAGEMAP_MAPPED 0x0001u
11#define PAGEMAP_ANONYMOUS 0x0002u
12#define PAGEMAP_FILE 0x0004u
13#define PAGEMAP_SWAPCACHE 0x0008u
14#define PAGEMAP_SWAPBACKED 0x0010u
15#define PAGEMAP_MAPPEDDISK 0x0020u
16#define PAGEMAP_BUFFERS 0x0040u
17
18#define trace_pagemap_flags(page) ( \
19 (PageAnon(page) ? PAGEMAP_ANONYMOUS : PAGEMAP_FILE) | \
20 (page_mapped(page) ? PAGEMAP_MAPPED : 0) | \
21 (PageSwapCache(page) ? PAGEMAP_SWAPCACHE : 0) | \
22 (PageSwapBacked(page) ? PAGEMAP_SWAPBACKED : 0) | \
23 (PageMappedToDisk(page) ? PAGEMAP_MAPPEDDISK : 0) | \
24 (page_has_private(page) ? PAGEMAP_BUFFERS : 0) \
25 )
26
27TRACE_EVENT(mm_lru_insertion,
28
29 TP_PROTO(
30 struct page *page,
31 unsigned long pfn,
32 int lru,
33 unsigned long flags
34 ),
35
36 TP_ARGS(page, pfn, lru, flags),
37
38 TP_STRUCT__entry(
39 __field(struct page *, page )
40 __field(unsigned long, pfn )
41 __field(int, lru )
42 __field(unsigned long, flags )
43 ),
44
45 TP_fast_assign(
46 __entry->page = page;
47 __entry->pfn = pfn;
48 __entry->lru = lru;
49 __entry->flags = flags;
50 ),
51
52 /* Flag format is based on page-types.c formatting for pagemap */
53 TP_printk("page=%p pfn=%lu lru=%d flags=%s%s%s%s%s%s",
54 __entry->page,
55 __entry->pfn,
56 __entry->lru,
57 __entry->flags & PAGEMAP_MAPPED ? "M" : " ",
58 __entry->flags & PAGEMAP_ANONYMOUS ? "a" : "f",
59 __entry->flags & PAGEMAP_SWAPCACHE ? "s" : " ",
60 __entry->flags & PAGEMAP_SWAPBACKED ? "b" : " ",
61 __entry->flags & PAGEMAP_MAPPEDDISK ? "d" : " ",
62 __entry->flags & PAGEMAP_BUFFERS ? "B" : " ")
63);
64
65TRACE_EVENT(mm_lru_activate,
66
67 TP_PROTO(struct page *page, unsigned long pfn),
68
69 TP_ARGS(page, pfn),
70
71 TP_STRUCT__entry(
72 __field(struct page *, page )
73 __field(unsigned long, pfn )
74 ),
75
76 TP_fast_assign(
77 __entry->page = page;
78 __entry->pfn = pfn;
79 ),
80
81 /* Flag format is based on page-types.c formatting for pagemap */
82 TP_printk("page=%p pfn=%lu", __entry->page, __entry->pfn)
83
84);
85
86#endif /* _TRACE_PAGEMAP_H */
87
88/* This part must be outside protection */
89#include <trace/define_trace.h>