memcg, vmscan: add memcg reclaim tracepoint
[sfrench/cifs-2.6.git] / include / trace / events / vmscan.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM vmscan
3
4 #if !defined(_TRACE_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_VMSCAN_H
6
7 #include <linux/types.h>
8 #include <linux/tracepoint.h>
9 #include "gfpflags.h"
10
11 #define RECLAIM_WB_ANON         0x0001u
12 #define RECLAIM_WB_FILE         0x0002u
13 #define RECLAIM_WB_SYNC         0x0004u
14 #define RECLAIM_WB_ASYNC        0x0008u
15
16 #define show_reclaim_flags(flags)                               \
17         (flags) ? __print_flags(flags, "|",                     \
18                 {RECLAIM_WB_ANON,       "RECLAIM_WB_ANON"},     \
19                 {RECLAIM_WB_FILE,       "RECLAIM_WB_FILE"},     \
20                 {RECLAIM_WB_SYNC,       "RECLAIM_WB_SYNC"},     \
21                 {RECLAIM_WB_ASYNC,      "RECLAIM_WB_ASYNC"}     \
22                 ) : "RECLAIM_WB_NONE"
23
24 #define trace_reclaim_flags(page, sync) ( \
25         (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
26         (sync == PAGEOUT_IO_SYNC ? RECLAIM_WB_SYNC : RECLAIM_WB_ASYNC)   \
27         )
28
29 TRACE_EVENT(mm_vmscan_kswapd_sleep,
30
31         TP_PROTO(int nid),
32
33         TP_ARGS(nid),
34
35         TP_STRUCT__entry(
36                 __field(        int,    nid     )
37         ),
38
39         TP_fast_assign(
40                 __entry->nid    = nid;
41         ),
42
43         TP_printk("nid=%d", __entry->nid)
44 );
45
46 TRACE_EVENT(mm_vmscan_kswapd_wake,
47
48         TP_PROTO(int nid, int order),
49
50         TP_ARGS(nid, order),
51
52         TP_STRUCT__entry(
53                 __field(        int,    nid     )
54                 __field(        int,    order   )
55         ),
56
57         TP_fast_assign(
58                 __entry->nid    = nid;
59                 __entry->order  = order;
60         ),
61
62         TP_printk("nid=%d order=%d", __entry->nid, __entry->order)
63 );
64
65 TRACE_EVENT(mm_vmscan_wakeup_kswapd,
66
67         TP_PROTO(int nid, int zid, int order),
68
69         TP_ARGS(nid, zid, order),
70
71         TP_STRUCT__entry(
72                 __field(        int,            nid     )
73                 __field(        int,            zid     )
74                 __field(        int,            order   )
75         ),
76
77         TP_fast_assign(
78                 __entry->nid            = nid;
79                 __entry->zid            = zid;
80                 __entry->order          = order;
81         ),
82
83         TP_printk("nid=%d zid=%d order=%d",
84                 __entry->nid,
85                 __entry->zid,
86                 __entry->order)
87 );
88
89 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,
90
91         TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
92
93         TP_ARGS(order, may_writepage, gfp_flags),
94
95         TP_STRUCT__entry(
96                 __field(        int,    order           )
97                 __field(        int,    may_writepage   )
98                 __field(        gfp_t,  gfp_flags       )
99         ),
100
101         TP_fast_assign(
102                 __entry->order          = order;
103                 __entry->may_writepage  = may_writepage;
104                 __entry->gfp_flags      = gfp_flags;
105         ),
106
107         TP_printk("order=%d may_writepage=%d gfp_flags=%s",
108                 __entry->order,
109                 __entry->may_writepage,
110                 show_gfp_flags(__entry->gfp_flags))
111 );
112
113 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin,
114
115         TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
116
117         TP_ARGS(order, may_writepage, gfp_flags)
118 );
119
120 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin,
121
122         TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
123
124         TP_ARGS(order, may_writepage, gfp_flags)
125 );
126
127 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin,
128
129         TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
130
131         TP_ARGS(order, may_writepage, gfp_flags)
132 );
133
134 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,
135
136         TP_PROTO(unsigned long nr_reclaimed),
137
138         TP_ARGS(nr_reclaimed),
139
140         TP_STRUCT__entry(
141                 __field(        unsigned long,  nr_reclaimed    )
142         ),
143
144         TP_fast_assign(
145                 __entry->nr_reclaimed   = nr_reclaimed;
146         ),
147
148         TP_printk("nr_reclaimed=%lu", __entry->nr_reclaimed)
149 );
150
151 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end,
152
153         TP_PROTO(unsigned long nr_reclaimed),
154
155         TP_ARGS(nr_reclaimed)
156 );
157
158 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_reclaim_end,
159
160         TP_PROTO(unsigned long nr_reclaimed),
161
162         TP_ARGS(nr_reclaimed)
163 );
164
165 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end,
166
167         TP_PROTO(unsigned long nr_reclaimed),
168
169         TP_ARGS(nr_reclaimed)
170 );
171
172
173 TRACE_EVENT(mm_vmscan_lru_isolate,
174
175         TP_PROTO(int order,
176                 unsigned long nr_requested,
177                 unsigned long nr_scanned,
178                 unsigned long nr_taken,
179                 unsigned long nr_lumpy_taken,
180                 unsigned long nr_lumpy_dirty,
181                 unsigned long nr_lumpy_failed,
182                 int isolate_mode),
183
184         TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode),
185
186         TP_STRUCT__entry(
187                 __field(int, order)
188                 __field(unsigned long, nr_requested)
189                 __field(unsigned long, nr_scanned)
190                 __field(unsigned long, nr_taken)
191                 __field(unsigned long, nr_lumpy_taken)
192                 __field(unsigned long, nr_lumpy_dirty)
193                 __field(unsigned long, nr_lumpy_failed)
194                 __field(int, isolate_mode)
195         ),
196
197         TP_fast_assign(
198                 __entry->order = order;
199                 __entry->nr_requested = nr_requested;
200                 __entry->nr_scanned = nr_scanned;
201                 __entry->nr_taken = nr_taken;
202                 __entry->nr_lumpy_taken = nr_lumpy_taken;
203                 __entry->nr_lumpy_dirty = nr_lumpy_dirty;
204                 __entry->nr_lumpy_failed = nr_lumpy_failed;
205                 __entry->isolate_mode = isolate_mode;
206         ),
207
208         TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu contig_taken=%lu contig_dirty=%lu contig_failed=%lu",
209                 __entry->isolate_mode,
210                 __entry->order,
211                 __entry->nr_requested,
212                 __entry->nr_scanned,
213                 __entry->nr_taken,
214                 __entry->nr_lumpy_taken,
215                 __entry->nr_lumpy_dirty,
216                 __entry->nr_lumpy_failed)
217 );
218
219 TRACE_EVENT(mm_vmscan_writepage,
220
221         TP_PROTO(struct page *page,
222                 int reclaim_flags),
223
224         TP_ARGS(page, reclaim_flags),
225
226         TP_STRUCT__entry(
227                 __field(struct page *, page)
228                 __field(int, reclaim_flags)
229         ),
230
231         TP_fast_assign(
232                 __entry->page = page;
233                 __entry->reclaim_flags = reclaim_flags;
234         ),
235
236         TP_printk("page=%p pfn=%lu flags=%s",
237                 __entry->page,
238                 page_to_pfn(__entry->page),
239                 show_reclaim_flags(__entry->reclaim_flags))
240 );
241
242 #endif /* _TRACE_VMSCAN_H */
243
244 /* This part must be outside protection */
245 #include <trace/define_trace.h>