blob: c88fd0934e7ead911941d13272bb89215584ba67 [file] [log] [blame]
Mel Gorman33906bc2010-08-09 17:19:16 -07001#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>
KOSAKI Motohiro83cd81a2011-06-15 15:08:14 -07009#include <linux/mm.h>
10#include <linux/memcontrol.h>
Vlastimil Babka420adbe92016-03-15 14:55:52 -070011#include <trace/events/mmflags.h>
Mel Gorman33906bc2010-08-09 17:19:16 -070012
Mel Gorman755f0222010-08-09 17:19:18 -070013#define RECLAIM_WB_ANON 0x0001u
14#define RECLAIM_WB_FILE 0x0002u
Mel Gormane11da5b2010-10-26 14:21:40 -070015#define RECLAIM_WB_MIXED 0x0010u
Mel Gorman41ac1992012-05-29 15:06:19 -070016#define RECLAIM_WB_SYNC 0x0004u /* Unused, all reclaim async */
Mel Gorman755f0222010-08-09 17:19:18 -070017#define RECLAIM_WB_ASYNC 0x0008u
18
19#define show_reclaim_flags(flags) \
20 (flags) ? __print_flags(flags, "|", \
21 {RECLAIM_WB_ANON, "RECLAIM_WB_ANON"}, \
22 {RECLAIM_WB_FILE, "RECLAIM_WB_FILE"}, \
Mel Gormane11da5b2010-10-26 14:21:40 -070023 {RECLAIM_WB_MIXED, "RECLAIM_WB_MIXED"}, \
Mel Gorman755f0222010-08-09 17:19:18 -070024 {RECLAIM_WB_SYNC, "RECLAIM_WB_SYNC"}, \
25 {RECLAIM_WB_ASYNC, "RECLAIM_WB_ASYNC"} \
26 ) : "RECLAIM_WB_NONE"
27
Mel Gorman23b9da52012-05-29 15:06:20 -070028#define trace_reclaim_flags(page) ( \
Mel Gorman755f0222010-08-09 17:19:18 -070029 (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
Mel Gorman41ac1992012-05-29 15:06:19 -070030 (RECLAIM_WB_ASYNC) \
Mel Gorman755f0222010-08-09 17:19:18 -070031 )
32
Mel Gorman23b9da52012-05-29 15:06:20 -070033#define trace_shrink_flags(file) \
Mel Gorman41ac1992012-05-29 15:06:19 -070034 ( \
35 (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
36 (RECLAIM_WB_ASYNC) \
Mel Gormane11da5b2010-10-26 14:21:40 -070037 )
38
Mel Gorman33906bc2010-08-09 17:19:16 -070039TRACE_EVENT(mm_vmscan_kswapd_sleep,
40
41 TP_PROTO(int nid),
42
43 TP_ARGS(nid),
44
45 TP_STRUCT__entry(
46 __field( int, nid )
47 ),
48
49 TP_fast_assign(
50 __entry->nid = nid;
51 ),
52
53 TP_printk("nid=%d", __entry->nid)
54);
55
56TRACE_EVENT(mm_vmscan_kswapd_wake,
57
Mel Gormane5146b12016-07-28 15:46:47 -070058 TP_PROTO(int nid, int zid, int order),
Mel Gorman33906bc2010-08-09 17:19:16 -070059
Mel Gormane5146b12016-07-28 15:46:47 -070060 TP_ARGS(nid, zid, order),
Mel Gorman33906bc2010-08-09 17:19:16 -070061
62 TP_STRUCT__entry(
63 __field( int, nid )
Mel Gormane5146b12016-07-28 15:46:47 -070064 __field( int, zid )
Mel Gorman33906bc2010-08-09 17:19:16 -070065 __field( int, order )
66 ),
67
68 TP_fast_assign(
69 __entry->nid = nid;
Mel Gormane5146b12016-07-28 15:46:47 -070070 __entry->zid = zid;
Mel Gorman33906bc2010-08-09 17:19:16 -070071 __entry->order = order;
72 ),
73
Mel Gormane5146b12016-07-28 15:46:47 -070074 TP_printk("nid=%d zid=%d order=%d", __entry->nid, __entry->zid, __entry->order)
Mel Gorman33906bc2010-08-09 17:19:16 -070075);
76
77TRACE_EVENT(mm_vmscan_wakeup_kswapd,
78
79 TP_PROTO(int nid, int zid, int order),
80
81 TP_ARGS(nid, zid, order),
82
83 TP_STRUCT__entry(
84 __field( int, nid )
85 __field( int, zid )
86 __field( int, order )
87 ),
88
89 TP_fast_assign(
90 __entry->nid = nid;
91 __entry->zid = zid;
92 __entry->order = order;
93 ),
94
95 TP_printk("nid=%d zid=%d order=%d",
96 __entry->nid,
97 __entry->zid,
98 __entry->order)
99);
100
KOSAKI Motohirocf4dcc32010-08-09 17:19:55 -0700101DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,
Mel Gorman33906bc2010-08-09 17:19:16 -0700102
Mel Gormane5146b12016-07-28 15:46:47 -0700103 TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
Mel Gorman33906bc2010-08-09 17:19:16 -0700104
Mel Gormane5146b12016-07-28 15:46:47 -0700105 TP_ARGS(order, may_writepage, gfp_flags, classzone_idx),
Mel Gorman33906bc2010-08-09 17:19:16 -0700106
107 TP_STRUCT__entry(
108 __field( int, order )
109 __field( int, may_writepage )
110 __field( gfp_t, gfp_flags )
Mel Gormane5146b12016-07-28 15:46:47 -0700111 __field( int, classzone_idx )
Mel Gorman33906bc2010-08-09 17:19:16 -0700112 ),
113
114 TP_fast_assign(
115 __entry->order = order;
116 __entry->may_writepage = may_writepage;
117 __entry->gfp_flags = gfp_flags;
Mel Gormane5146b12016-07-28 15:46:47 -0700118 __entry->classzone_idx = classzone_idx;
Mel Gorman33906bc2010-08-09 17:19:16 -0700119 ),
120
Mel Gormane5146b12016-07-28 15:46:47 -0700121 TP_printk("order=%d may_writepage=%d gfp_flags=%s classzone_idx=%d",
Mel Gorman33906bc2010-08-09 17:19:16 -0700122 __entry->order,
123 __entry->may_writepage,
Mel Gormane5146b12016-07-28 15:46:47 -0700124 show_gfp_flags(__entry->gfp_flags),
125 __entry->classzone_idx)
Mel Gorman33906bc2010-08-09 17:19:16 -0700126);
127
KOSAKI Motohirocf4dcc32010-08-09 17:19:55 -0700128DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin,
129
Mel Gormane5146b12016-07-28 15:46:47 -0700130 TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
KOSAKI Motohirocf4dcc32010-08-09 17:19:55 -0700131
Mel Gormane5146b12016-07-28 15:46:47 -0700132 TP_ARGS(order, may_writepage, gfp_flags, classzone_idx)
KOSAKI Motohirocf4dcc32010-08-09 17:19:55 -0700133);
134
KOSAKI Motohirobdce6d92010-08-09 17:19:56 -0700135DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin,
136
Mel Gormane5146b12016-07-28 15:46:47 -0700137 TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
KOSAKI Motohirobdce6d92010-08-09 17:19:56 -0700138
Mel Gormane5146b12016-07-28 15:46:47 -0700139 TP_ARGS(order, may_writepage, gfp_flags, classzone_idx)
KOSAKI Motohirobdce6d92010-08-09 17:19:56 -0700140);
141
142DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin,
143
Mel Gormane5146b12016-07-28 15:46:47 -0700144 TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
KOSAKI Motohirobdce6d92010-08-09 17:19:56 -0700145
Mel Gormane5146b12016-07-28 15:46:47 -0700146 TP_ARGS(order, may_writepage, gfp_flags, classzone_idx)
KOSAKI Motohirobdce6d92010-08-09 17:19:56 -0700147);
KOSAKI Motohirocf4dcc32010-08-09 17:19:55 -0700148
149DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,
Mel Gorman33906bc2010-08-09 17:19:16 -0700150
151 TP_PROTO(unsigned long nr_reclaimed),
152
153 TP_ARGS(nr_reclaimed),
154
155 TP_STRUCT__entry(
156 __field( unsigned long, nr_reclaimed )
157 ),
158
159 TP_fast_assign(
160 __entry->nr_reclaimed = nr_reclaimed;
161 ),
162
163 TP_printk("nr_reclaimed=%lu", __entry->nr_reclaimed)
164);
165
KOSAKI Motohirocf4dcc32010-08-09 17:19:55 -0700166DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end,
167
168 TP_PROTO(unsigned long nr_reclaimed),
169
170 TP_ARGS(nr_reclaimed)
171);
172
KOSAKI Motohirobdce6d92010-08-09 17:19:56 -0700173DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_reclaim_end,
174
175 TP_PROTO(unsigned long nr_reclaimed),
176
177 TP_ARGS(nr_reclaimed)
178);
179
180DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end,
181
182 TP_PROTO(unsigned long nr_reclaimed),
183
184 TP_ARGS(nr_reclaimed)
185);
186
Dave Chinner09576072011-07-08 14:14:34 +1000187TRACE_EVENT(mm_shrink_slab_start,
188 TP_PROTO(struct shrinker *shr, struct shrink_control *sc,
189 long nr_objects_to_shrink, unsigned long pgs_scanned,
190 unsigned long lru_pgs, unsigned long cache_items,
191 unsigned long long delta, unsigned long total_scan),
192
193 TP_ARGS(shr, sc, nr_objects_to_shrink, pgs_scanned, lru_pgs,
194 cache_items, delta, total_scan),
195
196 TP_STRUCT__entry(
197 __field(struct shrinker *, shr)
198 __field(void *, shrink)
Dave Hansendf9024a2014-06-04 16:08:07 -0700199 __field(int, nid)
Dave Chinner09576072011-07-08 14:14:34 +1000200 __field(long, nr_objects_to_shrink)
201 __field(gfp_t, gfp_flags)
202 __field(unsigned long, pgs_scanned)
203 __field(unsigned long, lru_pgs)
204 __field(unsigned long, cache_items)
205 __field(unsigned long long, delta)
206 __field(unsigned long, total_scan)
207 ),
208
209 TP_fast_assign(
210 __entry->shr = shr;
Dave Chinnera0b02132013-08-28 10:18:16 +1000211 __entry->shrink = shr->scan_objects;
Dave Hansendf9024a2014-06-04 16:08:07 -0700212 __entry->nid = sc->nid;
Dave Chinner09576072011-07-08 14:14:34 +1000213 __entry->nr_objects_to_shrink = nr_objects_to_shrink;
214 __entry->gfp_flags = sc->gfp_mask;
215 __entry->pgs_scanned = pgs_scanned;
216 __entry->lru_pgs = lru_pgs;
217 __entry->cache_items = cache_items;
218 __entry->delta = delta;
219 __entry->total_scan = total_scan;
220 ),
221
Dave Hansendf9024a2014-06-04 16:08:07 -0700222 TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
Dave Chinner09576072011-07-08 14:14:34 +1000223 __entry->shrink,
224 __entry->shr,
Dave Hansendf9024a2014-06-04 16:08:07 -0700225 __entry->nid,
Dave Chinner09576072011-07-08 14:14:34 +1000226 __entry->nr_objects_to_shrink,
227 show_gfp_flags(__entry->gfp_flags),
228 __entry->pgs_scanned,
229 __entry->lru_pgs,
230 __entry->cache_items,
231 __entry->delta,
232 __entry->total_scan)
233);
234
235TRACE_EVENT(mm_shrink_slab_end,
Dave Hansendf9024a2014-06-04 16:08:07 -0700236 TP_PROTO(struct shrinker *shr, int nid, int shrinker_retval,
Dave Hansen7fe70472014-06-04 16:08:06 -0700237 long unused_scan_cnt, long new_scan_cnt, long total_scan),
Dave Chinner09576072011-07-08 14:14:34 +1000238
Dave Hansendf9024a2014-06-04 16:08:07 -0700239 TP_ARGS(shr, nid, shrinker_retval, unused_scan_cnt, new_scan_cnt,
240 total_scan),
Dave Chinner09576072011-07-08 14:14:34 +1000241
242 TP_STRUCT__entry(
243 __field(struct shrinker *, shr)
Dave Hansendf9024a2014-06-04 16:08:07 -0700244 __field(int, nid)
Dave Chinner09576072011-07-08 14:14:34 +1000245 __field(void *, shrink)
246 __field(long, unused_scan)
247 __field(long, new_scan)
248 __field(int, retval)
249 __field(long, total_scan)
250 ),
251
252 TP_fast_assign(
253 __entry->shr = shr;
Dave Hansendf9024a2014-06-04 16:08:07 -0700254 __entry->nid = nid;
Dave Chinnera0b02132013-08-28 10:18:16 +1000255 __entry->shrink = shr->scan_objects;
Dave Chinner09576072011-07-08 14:14:34 +1000256 __entry->unused_scan = unused_scan_cnt;
257 __entry->new_scan = new_scan_cnt;
258 __entry->retval = shrinker_retval;
Dave Hansen7fe70472014-06-04 16:08:06 -0700259 __entry->total_scan = total_scan;
Dave Chinner09576072011-07-08 14:14:34 +1000260 ),
261
Dave Hansendf9024a2014-06-04 16:08:07 -0700262 TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
Dave Chinner09576072011-07-08 14:14:34 +1000263 __entry->shrink,
264 __entry->shr,
Dave Hansendf9024a2014-06-04 16:08:07 -0700265 __entry->nid,
Dave Chinner09576072011-07-08 14:14:34 +1000266 __entry->unused_scan,
267 __entry->new_scan,
268 __entry->total_scan,
269 __entry->retval)
270);
KOSAKI Motohirobdce6d92010-08-09 17:19:56 -0700271
KOSAKI Motohiroe17613c2010-08-09 17:19:57 -0700272DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template,
Mel Gormana8a94d12010-08-09 17:19:17 -0700273
Mel Gormane5146b12016-07-28 15:46:47 -0700274 TP_PROTO(int classzone_idx,
275 int order,
Mel Gormana8a94d12010-08-09 17:19:17 -0700276 unsigned long nr_requested,
277 unsigned long nr_scanned,
278 unsigned long nr_taken,
Tao Maea4d3492012-01-12 17:19:20 -0800279 isolate_mode_t isolate_mode,
280 int file),
Mel Gormana8a94d12010-08-09 17:19:17 -0700281
Mel Gormane5146b12016-07-28 15:46:47 -0700282 TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_taken, isolate_mode, file),
Mel Gormana8a94d12010-08-09 17:19:17 -0700283
284 TP_STRUCT__entry(
Mel Gormane5146b12016-07-28 15:46:47 -0700285 __field(int, classzone_idx)
Mel Gormana8a94d12010-08-09 17:19:17 -0700286 __field(int, order)
287 __field(unsigned long, nr_requested)
288 __field(unsigned long, nr_scanned)
289 __field(unsigned long, nr_taken)
Minchan Kim4356f212011-10-31 17:06:47 -0700290 __field(isolate_mode_t, isolate_mode)
Tao Maea4d3492012-01-12 17:19:20 -0800291 __field(int, file)
Mel Gormana8a94d12010-08-09 17:19:17 -0700292 ),
293
294 TP_fast_assign(
Mel Gormane5146b12016-07-28 15:46:47 -0700295 __entry->classzone_idx = classzone_idx;
Mel Gormana8a94d12010-08-09 17:19:17 -0700296 __entry->order = order;
297 __entry->nr_requested = nr_requested;
298 __entry->nr_scanned = nr_scanned;
299 __entry->nr_taken = nr_taken;
Mel Gormana8a94d12010-08-09 17:19:17 -0700300 __entry->isolate_mode = isolate_mode;
Tao Maea4d3492012-01-12 17:19:20 -0800301 __entry->file = file;
Mel Gormana8a94d12010-08-09 17:19:17 -0700302 ),
303
Mel Gormane5146b12016-07-28 15:46:47 -0700304 TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu file=%d",
Mel Gormana8a94d12010-08-09 17:19:17 -0700305 __entry->isolate_mode,
Mel Gormane5146b12016-07-28 15:46:47 -0700306 __entry->classzone_idx,
Mel Gormana8a94d12010-08-09 17:19:17 -0700307 __entry->order,
308 __entry->nr_requested,
309 __entry->nr_scanned,
310 __entry->nr_taken,
Tao Maea4d3492012-01-12 17:19:20 -0800311 __entry->file)
Mel Gormana8a94d12010-08-09 17:19:17 -0700312);
313
KOSAKI Motohiroe17613c2010-08-09 17:19:57 -0700314DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate,
315
Mel Gormane5146b12016-07-28 15:46:47 -0700316 TP_PROTO(int classzone_idx,
317 int order,
KOSAKI Motohiroe17613c2010-08-09 17:19:57 -0700318 unsigned long nr_requested,
319 unsigned long nr_scanned,
320 unsigned long nr_taken,
Tao Maea4d3492012-01-12 17:19:20 -0800321 isolate_mode_t isolate_mode,
322 int file),
KOSAKI Motohiroe17613c2010-08-09 17:19:57 -0700323
Mel Gormane5146b12016-07-28 15:46:47 -0700324 TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_taken, isolate_mode, file)
KOSAKI Motohiroe17613c2010-08-09 17:19:57 -0700325
326);
327
KOSAKI Motohirocc8e9702010-08-09 17:19:57 -0700328DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate,
329
Mel Gormane5146b12016-07-28 15:46:47 -0700330 TP_PROTO(int classzone_idx,
331 int order,
KOSAKI Motohirocc8e9702010-08-09 17:19:57 -0700332 unsigned long nr_requested,
333 unsigned long nr_scanned,
334 unsigned long nr_taken,
Tao Maea4d3492012-01-12 17:19:20 -0800335 isolate_mode_t isolate_mode,
336 int file),
KOSAKI Motohirocc8e9702010-08-09 17:19:57 -0700337
Mel Gormane5146b12016-07-28 15:46:47 -0700338 TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_taken, isolate_mode, file)
KOSAKI Motohirocc8e9702010-08-09 17:19:57 -0700339
340);
341
Mel Gorman755f0222010-08-09 17:19:18 -0700342TRACE_EVENT(mm_vmscan_writepage,
343
yalin wang3aa23852016-01-14 15:18:30 -0800344 TP_PROTO(struct page *page),
Mel Gorman755f0222010-08-09 17:19:18 -0700345
yalin wang3aa23852016-01-14 15:18:30 -0800346 TP_ARGS(page),
Mel Gorman755f0222010-08-09 17:19:18 -0700347
348 TP_STRUCT__entry(
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900349 __field(unsigned long, pfn)
Mel Gorman755f0222010-08-09 17:19:18 -0700350 __field(int, reclaim_flags)
351 ),
352
353 TP_fast_assign(
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900354 __entry->pfn = page_to_pfn(page);
yalin wang3aa23852016-01-14 15:18:30 -0800355 __entry->reclaim_flags = trace_reclaim_flags(page);
Mel Gorman755f0222010-08-09 17:19:18 -0700356 ),
357
358 TP_printk("page=%p pfn=%lu flags=%s",
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900359 pfn_to_page(__entry->pfn),
360 __entry->pfn,
Mel Gorman755f0222010-08-09 17:19:18 -0700361 show_reclaim_flags(__entry->reclaim_flags))
362);
363
Mel Gormane11da5b2010-10-26 14:21:40 -0700364TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
365
Mel Gorman599d0c92016-07-28 15:45:31 -0700366 TP_PROTO(int nid,
yalin wangba5e9572016-01-14 15:18:48 -0800367 unsigned long nr_scanned, unsigned long nr_reclaimed,
368 int priority, int file),
Mel Gormane11da5b2010-10-26 14:21:40 -0700369
Mel Gorman599d0c92016-07-28 15:45:31 -0700370 TP_ARGS(nid, nr_scanned, nr_reclaimed, priority, file),
Mel Gormane11da5b2010-10-26 14:21:40 -0700371
372 TP_STRUCT__entry(
373 __field(int, nid)
Mel Gormane11da5b2010-10-26 14:21:40 -0700374 __field(unsigned long, nr_scanned)
375 __field(unsigned long, nr_reclaimed)
376 __field(int, priority)
377 __field(int, reclaim_flags)
378 ),
379
380 TP_fast_assign(
Mel Gorman599d0c92016-07-28 15:45:31 -0700381 __entry->nid = nid;
Mel Gormane11da5b2010-10-26 14:21:40 -0700382 __entry->nr_scanned = nr_scanned;
383 __entry->nr_reclaimed = nr_reclaimed;
384 __entry->priority = priority;
yalin wangba5e9572016-01-14 15:18:48 -0800385 __entry->reclaim_flags = trace_shrink_flags(file);
Mel Gormane11da5b2010-10-26 14:21:40 -0700386 ),
387
Mel Gorman599d0c92016-07-28 15:45:31 -0700388 TP_printk("nid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
389 __entry->nid,
Mel Gormane11da5b2010-10-26 14:21:40 -0700390 __entry->nr_scanned, __entry->nr_reclaimed,
391 __entry->priority,
392 show_reclaim_flags(__entry->reclaim_flags))
393);
394
Mel Gorman33906bc2010-08-09 17:19:16 -0700395#endif /* _TRACE_VMSCAN_H */
396
397/* This part must be outside protection */
398#include <trace/define_trace.h>