2 #define TRACE_SYSTEM vmscan
4 #if !defined(_TRACE_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_VMSCAN_H
7 #include <linux/types.h>
8 #include <linux/tracepoint.h>
10 #include <linux/memcontrol.h>
11 #include <trace/events/mmflags.h>
13 #define RECLAIM_WB_ANON 0x0001u
14 #define RECLAIM_WB_FILE 0x0002u
15 #define RECLAIM_WB_MIXED 0x0010u
16 #define RECLAIM_WB_SYNC 0x0004u /* Unused, all reclaim async */
17 #define RECLAIM_WB_ASYNC 0x0008u
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"}, \
23 {RECLAIM_WB_MIXED, "RECLAIM_WB_MIXED"}, \
24 {RECLAIM_WB_SYNC, "RECLAIM_WB_SYNC"}, \
25 {RECLAIM_WB_ASYNC, "RECLAIM_WB_ASYNC"} \
28 #define trace_reclaim_flags(page) ( \
29 (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
33 #define trace_shrink_flags(file) \
35 (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
39 TRACE_EVENT(mm_vmscan_kswapd_sleep
,
53 TP_printk("nid=%d", __entry
->nid
)
56 TRACE_EVENT(mm_vmscan_kswapd_wake
,
58 TP_PROTO(int nid
, int zid
, int order
),
60 TP_ARGS(nid
, zid
, order
),
71 __entry
->order
= order
;
74 TP_printk("nid=%d zid=%d order=%d", __entry
->nid
, __entry
->zid
, __entry
->order
)
77 TRACE_EVENT(mm_vmscan_wakeup_kswapd
,
79 TP_PROTO(int nid
, int zid
, int order
),
81 TP_ARGS(nid
, zid
, order
),
92 __entry
->order
= order
;
95 TP_printk("nid=%d zid=%d order=%d",
101 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template
,
103 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
105 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
),
108 __field( int, order
)
109 __field( int, may_writepage
)
110 __field( gfp_t
, gfp_flags
)
111 __field( int, classzone_idx
)
115 __entry
->order
= order
;
116 __entry
->may_writepage
= may_writepage
;
117 __entry
->gfp_flags
= gfp_flags
;
118 __entry
->classzone_idx
= classzone_idx
;
121 TP_printk("order=%d may_writepage=%d gfp_flags=%s classzone_idx=%d",
123 __entry
->may_writepage
,
124 show_gfp_flags(__entry
->gfp_flags
),
125 __entry
->classzone_idx
)
128 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_direct_reclaim_begin
,
130 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
132 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
)
135 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_reclaim_begin
,
137 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
139 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
)
142 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_softlimit_reclaim_begin
,
144 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
146 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
)
149 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template
,
151 TP_PROTO(unsigned long nr_reclaimed
),
153 TP_ARGS(nr_reclaimed
),
156 __field( unsigned long, nr_reclaimed
)
160 __entry
->nr_reclaimed
= nr_reclaimed
;
163 TP_printk("nr_reclaimed=%lu", __entry
->nr_reclaimed
)
166 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_direct_reclaim_end
,
168 TP_PROTO(unsigned long nr_reclaimed
),
170 TP_ARGS(nr_reclaimed
)
173 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_reclaim_end
,
175 TP_PROTO(unsigned long nr_reclaimed
),
177 TP_ARGS(nr_reclaimed
)
180 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_softlimit_reclaim_end
,
182 TP_PROTO(unsigned long nr_reclaimed
),
184 TP_ARGS(nr_reclaimed
)
187 TRACE_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
),
193 TP_ARGS(shr
, sc
, nr_objects_to_shrink
, pgs_scanned
, lru_pgs
,
194 cache_items
, delta
, total_scan
),
197 __field(struct shrinker
*, shr
)
198 __field(void *, shrink
)
200 __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
)
211 __entry
->shrink
= shr
->scan_objects
;
212 __entry
->nid
= sc
->nid
;
213 __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
;
222 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",
226 __entry
->nr_objects_to_shrink
,
227 show_gfp_flags(__entry
->gfp_flags
),
228 __entry
->pgs_scanned
,
230 __entry
->cache_items
,
235 TRACE_EVENT(mm_shrink_slab_end
,
236 TP_PROTO(struct shrinker
*shr
, int nid
, int shrinker_retval
,
237 long unused_scan_cnt
, long new_scan_cnt
, long total_scan
),
239 TP_ARGS(shr
, nid
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
,
243 __field(struct shrinker
*, shr
)
245 __field(void *, shrink
)
246 __field(long, unused_scan
)
247 __field(long, new_scan
)
249 __field(long, total_scan
)
255 __entry
->shrink
= shr
->scan_objects
;
256 __entry
->unused_scan
= unused_scan_cnt
;
257 __entry
->new_scan
= new_scan_cnt
;
258 __entry
->retval
= shrinker_retval
;
259 __entry
->total_scan
= total_scan
;
262 TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
266 __entry
->unused_scan
,
272 DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template
,
274 TP_PROTO(int classzone_idx
,
276 unsigned long nr_requested
,
277 unsigned long nr_scanned
,
278 unsigned long nr_taken
,
279 isolate_mode_t isolate_mode
,
282 TP_ARGS(classzone_idx
, order
, nr_requested
, nr_scanned
, nr_taken
, isolate_mode
, file
),
285 __field(int, classzone_idx
)
287 __field(unsigned long, nr_requested
)
288 __field(unsigned long, nr_scanned
)
289 __field(unsigned long, nr_taken
)
290 __field(isolate_mode_t
, isolate_mode
)
295 __entry
->classzone_idx
= classzone_idx
;
296 __entry
->order
= order
;
297 __entry
->nr_requested
= nr_requested
;
298 __entry
->nr_scanned
= nr_scanned
;
299 __entry
->nr_taken
= nr_taken
;
300 __entry
->isolate_mode
= isolate_mode
;
301 __entry
->file
= file
;
304 TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu file=%d",
305 __entry
->isolate_mode
,
306 __entry
->classzone_idx
,
308 __entry
->nr_requested
,
314 DEFINE_EVENT(mm_vmscan_lru_isolate_template
, mm_vmscan_lru_isolate
,
316 TP_PROTO(int classzone_idx
,
318 unsigned long nr_requested
,
319 unsigned long nr_scanned
,
320 unsigned long nr_taken
,
321 isolate_mode_t isolate_mode
,
324 TP_ARGS(classzone_idx
, order
, nr_requested
, nr_scanned
, nr_taken
, isolate_mode
, file
)
328 DEFINE_EVENT(mm_vmscan_lru_isolate_template
, mm_vmscan_memcg_isolate
,
330 TP_PROTO(int classzone_idx
,
332 unsigned long nr_requested
,
333 unsigned long nr_scanned
,
334 unsigned long nr_taken
,
335 isolate_mode_t isolate_mode
,
338 TP_ARGS(classzone_idx
, order
, nr_requested
, nr_scanned
, nr_taken
, isolate_mode
, file
)
342 TRACE_EVENT(mm_vmscan_writepage
,
344 TP_PROTO(struct page
*page
),
349 __field(unsigned long, pfn
)
350 __field(int, reclaim_flags
)
354 __entry
->pfn
= page_to_pfn(page
);
355 __entry
->reclaim_flags
= trace_reclaim_flags(page
);
358 TP_printk("page=%p pfn=%lu flags=%s",
359 pfn_to_page(__entry
->pfn
),
361 show_reclaim_flags(__entry
->reclaim_flags
))
364 TRACE_EVENT(mm_vmscan_lru_shrink_inactive
,
367 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
368 int priority
, int file
),
370 TP_ARGS(nid
, nr_scanned
, nr_reclaimed
, priority
, file
),
374 __field(unsigned long, nr_scanned
)
375 __field(unsigned long, nr_reclaimed
)
376 __field(int, priority
)
377 __field(int, reclaim_flags
)
382 __entry
->nr_scanned
= nr_scanned
;
383 __entry
->nr_reclaimed
= nr_reclaimed
;
384 __entry
->priority
= priority
;
385 __entry
->reclaim_flags
= trace_shrink_flags(file
);
388 TP_printk("nid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
390 __entry
->nr_scanned
, __entry
->nr_reclaimed
,
392 show_reclaim_flags(__entry
->reclaim_flags
))
395 #endif /* _TRACE_VMSCAN_H */
397 /* This part must be outside protection */
398 #include <trace/define_trace.h>