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 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
)
195 __field(long, nr_objects_to_shrink
)
196 __field(gfp_t
, gfp_flags
)
197 __field(unsigned long, pgs_scanned
)
198 __field(unsigned long, lru_pgs
)
199 __field(unsigned long, cache_items
)
200 __field(unsigned long long, delta
)
201 __field(unsigned long, total_scan
)
206 __entry
->shrink
= shr
->scan_objects
;
207 __entry
->nid
= sc
->nid
;
208 __entry
->nr_objects_to_shrink
= nr_objects_to_shrink
;
209 __entry
->gfp_flags
= sc
->gfp_mask
;
210 __entry
->pgs_scanned
= pgs_scanned
;
211 __entry
->lru_pgs
= lru_pgs
;
212 __entry
->cache_items
= cache_items
;
213 __entry
->delta
= delta
;
214 __entry
->total_scan
= total_scan
;
217 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",
221 __entry
->nr_objects_to_shrink
,
222 show_gfp_flags(__entry
->gfp_flags
),
223 __entry
->pgs_scanned
,
225 __entry
->cache_items
,
230 TRACE_EVENT(mm_shrink_slab_end
,
231 TP_PROTO(struct shrinker
*shr
, int nid
, int shrinker_retval
,
232 long unused_scan_cnt
, long new_scan_cnt
, long total_scan
),
234 TP_ARGS(shr
, nid
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
,
238 __field(struct shrinker
*, shr
)
240 __field(void *, shrink
)
241 __field(long, unused_scan
)
242 __field(long, new_scan
)
244 __field(long, total_scan
)
250 __entry
->shrink
= shr
->scan_objects
;
251 __entry
->unused_scan
= unused_scan_cnt
;
252 __entry
->new_scan
= new_scan_cnt
;
253 __entry
->retval
= shrinker_retval
;
254 __entry
->total_scan
= total_scan
;
257 TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
261 __entry
->unused_scan
,
267 DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template
,
270 unsigned long nr_requested
,
271 unsigned long nr_scanned
,
272 unsigned long nr_taken
,
273 isolate_mode_t isolate_mode
,
276 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
, isolate_mode
, file
),
280 __field(unsigned long, nr_requested
)
281 __field(unsigned long, nr_scanned
)
282 __field(unsigned long, nr_taken
)
283 __field(isolate_mode_t
, isolate_mode
)
288 __entry
->order
= order
;
289 __entry
->nr_requested
= nr_requested
;
290 __entry
->nr_scanned
= nr_scanned
;
291 __entry
->nr_taken
= nr_taken
;
292 __entry
->isolate_mode
= isolate_mode
;
293 __entry
->file
= file
;
296 TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu file=%d",
297 __entry
->isolate_mode
,
299 __entry
->nr_requested
,
305 DEFINE_EVENT(mm_vmscan_lru_isolate_template
, mm_vmscan_lru_isolate
,
308 unsigned long nr_requested
,
309 unsigned long nr_scanned
,
310 unsigned long nr_taken
,
311 isolate_mode_t isolate_mode
,
314 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
, isolate_mode
, file
)
318 DEFINE_EVENT(mm_vmscan_lru_isolate_template
, mm_vmscan_memcg_isolate
,
321 unsigned long nr_requested
,
322 unsigned long nr_scanned
,
323 unsigned long nr_taken
,
324 isolate_mode_t isolate_mode
,
327 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
, isolate_mode
, file
)
331 TRACE_EVENT(mm_vmscan_writepage
,
333 TP_PROTO(struct page
*page
),
338 __field(unsigned long, pfn
)
339 __field(int, reclaim_flags
)
343 __entry
->pfn
= page_to_pfn(page
);
344 __entry
->reclaim_flags
= trace_reclaim_flags(page
);
347 TP_printk("page=%p pfn=%lu flags=%s",
348 pfn_to_page(__entry
->pfn
),
350 show_reclaim_flags(__entry
->reclaim_flags
))
353 TRACE_EVENT(mm_vmscan_lru_shrink_inactive
,
355 TP_PROTO(struct zone
*zone
,
356 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
357 int priority
, int file
),
359 TP_ARGS(zone
, nr_scanned
, nr_reclaimed
, priority
, file
),
364 __field(unsigned long, nr_scanned
)
365 __field(unsigned long, nr_reclaimed
)
366 __field(int, priority
)
367 __field(int, reclaim_flags
)
371 __entry
->nid
= zone_to_nid(zone
);
372 __entry
->zid
= zone_idx(zone
);
373 __entry
->nr_scanned
= nr_scanned
;
374 __entry
->nr_reclaimed
= nr_reclaimed
;
375 __entry
->priority
= priority
;
376 __entry
->reclaim_flags
= trace_shrink_flags(file
);
379 TP_printk("nid=%d zid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
380 __entry
->nid
, __entry
->zid
,
381 __entry
->nr_scanned
, __entry
->nr_reclaimed
,
383 show_reclaim_flags(__entry
->reclaim_flags
))
386 #endif /* _TRACE_VMSCAN_H */
388 /* This part must be outside protection */
389 #include <trace/define_trace.h>