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>
13 #define RECLAIM_WB_ANON 0x0001u
14 #define RECLAIM_WB_FILE 0x0002u
15 #define RECLAIM_WB_MIXED 0x0010u
16 #define RECLAIM_WB_SYNC 0x0004u
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, sync) ( \
29 (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
30 (sync & RECLAIM_MODE_SYNC ? RECLAIM_WB_SYNC : RECLAIM_WB_ASYNC) \
33 #define trace_shrink_flags(file, sync) ( \
34 (sync & RECLAIM_MODE_SYNC ? RECLAIM_WB_MIXED : \
35 (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON)) | \
36 (sync & RECLAIM_MODE_SYNC ? RECLAIM_WB_SYNC : RECLAIM_WB_ASYNC) \
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 order
),
69 __entry
->order
= order
;
72 TP_printk("nid=%d order=%d", __entry
->nid
, __entry
->order
)
75 TRACE_EVENT(mm_vmscan_wakeup_kswapd
,
77 TP_PROTO(int nid
, int zid
, int order
),
79 TP_ARGS(nid
, zid
, order
),
90 __entry
->order
= order
;
93 TP_printk("nid=%d zid=%d order=%d",
99 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template
,
101 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
103 TP_ARGS(order
, may_writepage
, gfp_flags
),
106 __field( int, order
)
107 __field( int, may_writepage
)
108 __field( gfp_t
, gfp_flags
)
112 __entry
->order
= order
;
113 __entry
->may_writepage
= may_writepage
;
114 __entry
->gfp_flags
= gfp_flags
;
117 TP_printk("order=%d may_writepage=%d gfp_flags=%s",
119 __entry
->may_writepage
,
120 show_gfp_flags(__entry
->gfp_flags
))
123 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_direct_reclaim_begin
,
125 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
127 TP_ARGS(order
, may_writepage
, gfp_flags
)
130 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_reclaim_begin
,
132 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
134 TP_ARGS(order
, may_writepage
, gfp_flags
)
137 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_softlimit_reclaim_begin
,
139 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
141 TP_ARGS(order
, may_writepage
, gfp_flags
)
144 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template
,
146 TP_PROTO(unsigned long nr_reclaimed
),
148 TP_ARGS(nr_reclaimed
),
151 __field( unsigned long, nr_reclaimed
)
155 __entry
->nr_reclaimed
= nr_reclaimed
;
158 TP_printk("nr_reclaimed=%lu", __entry
->nr_reclaimed
)
161 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_direct_reclaim_end
,
163 TP_PROTO(unsigned long nr_reclaimed
),
165 TP_ARGS(nr_reclaimed
)
168 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_reclaim_end
,
170 TP_PROTO(unsigned long nr_reclaimed
),
172 TP_ARGS(nr_reclaimed
)
175 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_softlimit_reclaim_end
,
177 TP_PROTO(unsigned long nr_reclaimed
),
179 TP_ARGS(nr_reclaimed
)
182 TRACE_EVENT(mm_shrink_slab_start
,
183 TP_PROTO(struct shrinker
*shr
, struct shrink_control
*sc
,
184 long nr_objects_to_shrink
, unsigned long pgs_scanned
,
185 unsigned long lru_pgs
, unsigned long cache_items
,
186 unsigned long long delta
, unsigned long total_scan
),
188 TP_ARGS(shr
, sc
, nr_objects_to_shrink
, pgs_scanned
, lru_pgs
,
189 cache_items
, delta
, total_scan
),
192 __field(struct shrinker
*, shr
)
193 __field(void *, shrink
)
194 __field(long, nr_objects_to_shrink
)
195 __field(gfp_t
, gfp_flags
)
196 __field(unsigned long, pgs_scanned
)
197 __field(unsigned long, lru_pgs
)
198 __field(unsigned long, cache_items
)
199 __field(unsigned long long, delta
)
200 __field(unsigned long, total_scan
)
205 __entry
->shrink
= shr
->shrink
;
206 __entry
->nr_objects_to_shrink
= nr_objects_to_shrink
;
207 __entry
->gfp_flags
= sc
->gfp_mask
;
208 __entry
->pgs_scanned
= pgs_scanned
;
209 __entry
->lru_pgs
= lru_pgs
;
210 __entry
->cache_items
= cache_items
;
211 __entry
->delta
= delta
;
212 __entry
->total_scan
= total_scan
;
215 TP_printk("%pF %p: objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
218 __entry
->nr_objects_to_shrink
,
219 show_gfp_flags(__entry
->gfp_flags
),
220 __entry
->pgs_scanned
,
222 __entry
->cache_items
,
227 TRACE_EVENT(mm_shrink_slab_end
,
228 TP_PROTO(struct shrinker
*shr
, int shrinker_retval
,
229 long unused_scan_cnt
, long new_scan_cnt
),
231 TP_ARGS(shr
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
),
234 __field(struct shrinker
*, shr
)
235 __field(void *, shrink
)
236 __field(long, unused_scan
)
237 __field(long, new_scan
)
239 __field(long, total_scan
)
244 __entry
->shrink
= shr
->shrink
;
245 __entry
->unused_scan
= unused_scan_cnt
;
246 __entry
->new_scan
= new_scan_cnt
;
247 __entry
->retval
= shrinker_retval
;
248 __entry
->total_scan
= new_scan_cnt
- unused_scan_cnt
;
251 TP_printk("%pF %p: unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
254 __entry
->unused_scan
,
260 DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template
,
263 unsigned long nr_requested
,
264 unsigned long nr_scanned
,
265 unsigned long nr_taken
,
266 unsigned long nr_lumpy_taken
,
267 unsigned long nr_lumpy_dirty
,
268 unsigned long nr_lumpy_failed
,
271 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
, nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
, isolate_mode
),
275 __field(unsigned long, nr_requested
)
276 __field(unsigned long, nr_scanned
)
277 __field(unsigned long, nr_taken
)
278 __field(unsigned long, nr_lumpy_taken
)
279 __field(unsigned long, nr_lumpy_dirty
)
280 __field(unsigned long, nr_lumpy_failed
)
281 __field(int, isolate_mode
)
285 __entry
->order
= order
;
286 __entry
->nr_requested
= nr_requested
;
287 __entry
->nr_scanned
= nr_scanned
;
288 __entry
->nr_taken
= nr_taken
;
289 __entry
->nr_lumpy_taken
= nr_lumpy_taken
;
290 __entry
->nr_lumpy_dirty
= nr_lumpy_dirty
;
291 __entry
->nr_lumpy_failed
= nr_lumpy_failed
;
292 __entry
->isolate_mode
= isolate_mode
;
295 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",
296 __entry
->isolate_mode
,
298 __entry
->nr_requested
,
301 __entry
->nr_lumpy_taken
,
302 __entry
->nr_lumpy_dirty
,
303 __entry
->nr_lumpy_failed
)
306 DEFINE_EVENT(mm_vmscan_lru_isolate_template
, mm_vmscan_lru_isolate
,
309 unsigned long nr_requested
,
310 unsigned long nr_scanned
,
311 unsigned long nr_taken
,
312 unsigned long nr_lumpy_taken
,
313 unsigned long nr_lumpy_dirty
,
314 unsigned long nr_lumpy_failed
,
317 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
, nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
, isolate_mode
)
321 DEFINE_EVENT(mm_vmscan_lru_isolate_template
, mm_vmscan_memcg_isolate
,
324 unsigned long nr_requested
,
325 unsigned long nr_scanned
,
326 unsigned long nr_taken
,
327 unsigned long nr_lumpy_taken
,
328 unsigned long nr_lumpy_dirty
,
329 unsigned long nr_lumpy_failed
,
332 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
, nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
, isolate_mode
)
336 TRACE_EVENT(mm_vmscan_writepage
,
338 TP_PROTO(struct page
*page
,
341 TP_ARGS(page
, reclaim_flags
),
344 __field(struct page
*, page
)
345 __field(int, reclaim_flags
)
349 __entry
->page
= page
;
350 __entry
->reclaim_flags
= reclaim_flags
;
353 TP_printk("page=%p pfn=%lu flags=%s",
355 page_to_pfn(__entry
->page
),
356 show_reclaim_flags(__entry
->reclaim_flags
))
359 TRACE_EVENT(mm_vmscan_lru_shrink_inactive
,
361 TP_PROTO(int nid
, int zid
,
362 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
363 int priority
, int reclaim_flags
),
365 TP_ARGS(nid
, zid
, nr_scanned
, nr_reclaimed
, priority
, reclaim_flags
),
370 __field(unsigned long, nr_scanned
)
371 __field(unsigned long, nr_reclaimed
)
372 __field(int, priority
)
373 __field(int, reclaim_flags
)
379 __entry
->nr_scanned
= nr_scanned
;
380 __entry
->nr_reclaimed
= nr_reclaimed
;
381 __entry
->priority
= priority
;
382 __entry
->reclaim_flags
= reclaim_flags
;
385 TP_printk("nid=%d zid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
386 __entry
->nid
, __entry
->zid
,
387 __entry
->nr_scanned
, __entry
->nr_reclaimed
,
389 show_reclaim_flags(__entry
->reclaim_flags
))
392 TRACE_EVENT(replace_swap_token
,
393 TP_PROTO(struct mm_struct
*old_mm
,
394 struct mm_struct
*new_mm
),
396 TP_ARGS(old_mm
, new_mm
),
399 __field(struct mm_struct
*, old_mm
)
400 __field(unsigned int, old_prio
)
401 __field(struct mm_struct
*, new_mm
)
402 __field(unsigned int, new_prio
)
406 __entry
->old_mm
= old_mm
;
407 __entry
->old_prio
= old_mm
? old_mm
->token_priority
: 0;
408 __entry
->new_mm
= new_mm
;
409 __entry
->new_prio
= new_mm
->token_priority
;
412 TP_printk("old_token_mm=%p old_prio=%u new_token_mm=%p new_prio=%u",
413 __entry
->old_mm
, __entry
->old_prio
,
414 __entry
->new_mm
, __entry
->new_prio
)
417 DECLARE_EVENT_CLASS(put_swap_token_template
,
418 TP_PROTO(struct mm_struct
*swap_token_mm
),
420 TP_ARGS(swap_token_mm
),
423 __field(struct mm_struct
*, swap_token_mm
)
427 __entry
->swap_token_mm
= swap_token_mm
;
430 TP_printk("token_mm=%p", __entry
->swap_token_mm
)
433 DEFINE_EVENT(put_swap_token_template
, put_swap_token
,
434 TP_PROTO(struct mm_struct
*swap_token_mm
),
435 TP_ARGS(swap_token_mm
)
438 DEFINE_EVENT_CONDITION(put_swap_token_template
, disable_swap_token
,
439 TP_PROTO(struct mm_struct
*swap_token_mm
),
440 TP_ARGS(swap_token_mm
),
441 TP_CONDITION(swap_token_mm
!= NULL
)
444 TRACE_EVENT_CONDITION(update_swap_token_priority
,
445 TP_PROTO(struct mm_struct
*mm
,
446 unsigned int old_prio
,
447 struct mm_struct
*swap_token_mm
),
449 TP_ARGS(mm
, old_prio
, swap_token_mm
),
451 TP_CONDITION(mm
->token_priority
!= old_prio
),
454 __field(struct mm_struct
*, mm
)
455 __field(unsigned int, old_prio
)
456 __field(unsigned int, new_prio
)
457 __field(struct mm_struct
*, swap_token_mm
)
458 __field(unsigned int, swap_token_prio
)
463 __entry
->old_prio
= old_prio
;
464 __entry
->new_prio
= mm
->token_priority
;
465 __entry
->swap_token_mm
= swap_token_mm
;
466 __entry
->swap_token_prio
= swap_token_mm
? swap_token_mm
->token_priority
: 0;
469 TP_printk("mm=%p old_prio=%u new_prio=%u swap_token_mm=%p token_prio=%u",
470 __entry
->mm
, __entry
->old_prio
, __entry
->new_prio
,
471 __entry
->swap_token_mm
, __entry
->swap_token_prio
)
474 #endif /* _TRACE_VMSCAN_H */
476 /* This part must be outside protection */
477 #include <trace/define_trace.h>