2 #define TRACE_SYSTEM writeback
4 #if !defined(_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_WRITEBACK_H
7 #include <linux/backing-dev.h>
8 #include <linux/writeback.h>
10 #define show_inode_state(state) \
11 __print_flags(state, "|", \
12 {I_DIRTY_SYNC, "I_DIRTY_SYNC"}, \
13 {I_DIRTY_DATASYNC, "I_DIRTY_DATASYNC"}, \
14 {I_DIRTY_PAGES, "I_DIRTY_PAGES"}, \
16 {I_WILL_FREE, "I_WILL_FREE"}, \
17 {I_FREEING, "I_FREEING"}, \
18 {I_CLEAR, "I_CLEAR"}, \
20 {I_REFERENCED, "I_REFERENCED"} \
23 #define WB_WORK_REASON \
24 {WB_REASON_BACKGROUND, "background"}, \
25 {WB_REASON_TRY_TO_FREE_PAGES, "try_to_free_pages"}, \
26 {WB_REASON_SYNC, "sync"}, \
27 {WB_REASON_PERIODIC, "periodic"}, \
28 {WB_REASON_LAPTOP_TIMER, "laptop_timer"}, \
29 {WB_REASON_FREE_MORE_MEM, "free_more_memory"}, \
30 {WB_REASON_FS_FREE_SPACE, "fs_free_space"}, \
31 {WB_REASON_FORKER_THREAD, "forker_thread"}
33 struct wb_writeback_work
;
35 DECLARE_EVENT_CLASS(writeback_work_class
,
36 TP_PROTO(struct backing_dev_info
*bdi
, struct wb_writeback_work
*work
),
39 __array(char, name
, 32)
40 __field(long, nr_pages
)
41 __field(dev_t
, sb_dev
)
42 __field(int, sync_mode
)
43 __field(int, for_kupdate
)
44 __field(int, range_cyclic
)
45 __field(int, for_background
)
49 struct device
*dev
= bdi
->dev
;
51 dev
= default_backing_dev_info
.dev
;
52 strncpy(__entry
->name
, dev_name(dev
), 32);
53 __entry
->nr_pages
= work
->nr_pages
;
54 __entry
->sb_dev
= work
->sb
? work
->sb
->s_dev
: 0;
55 __entry
->sync_mode
= work
->sync_mode
;
56 __entry
->for_kupdate
= work
->for_kupdate
;
57 __entry
->range_cyclic
= work
->range_cyclic
;
58 __entry
->for_background
= work
->for_background
;
59 __entry
->reason
= work
->reason
;
61 TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
62 "kupdate=%d range_cyclic=%d background=%d reason=%s",
64 MAJOR(__entry
->sb_dev
), MINOR(__entry
->sb_dev
),
68 __entry
->range_cyclic
,
69 __entry
->for_background
,
70 __print_symbolic(__entry
->reason
, WB_WORK_REASON
)
73 #define DEFINE_WRITEBACK_WORK_EVENT(name) \
74 DEFINE_EVENT(writeback_work_class, name, \
75 TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \
77 DEFINE_WRITEBACK_WORK_EVENT(writeback_nothread
);
78 DEFINE_WRITEBACK_WORK_EVENT(writeback_queue
);
79 DEFINE_WRITEBACK_WORK_EVENT(writeback_exec
);
80 DEFINE_WRITEBACK_WORK_EVENT(writeback_start
);
81 DEFINE_WRITEBACK_WORK_EVENT(writeback_written
);
82 DEFINE_WRITEBACK_WORK_EVENT(writeback_wait
);
84 TRACE_EVENT(writeback_pages_written
,
85 TP_PROTO(long pages_written
),
86 TP_ARGS(pages_written
),
91 __entry
->pages
= pages_written
;
93 TP_printk("%ld", __entry
->pages
)
96 DECLARE_EVENT_CLASS(writeback_class
,
97 TP_PROTO(struct backing_dev_info
*bdi
),
100 __array(char, name
, 32)
103 strncpy(__entry
->name
, dev_name(bdi
->dev
), 32);
109 #define DEFINE_WRITEBACK_EVENT(name) \
110 DEFINE_EVENT(writeback_class, name, \
111 TP_PROTO(struct backing_dev_info *bdi), \
114 DEFINE_WRITEBACK_EVENT(writeback_nowork
);
115 DEFINE_WRITEBACK_EVENT(writeback_wake_background
);
116 DEFINE_WRITEBACK_EVENT(writeback_wake_thread
);
117 DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread
);
118 DEFINE_WRITEBACK_EVENT(writeback_bdi_register
);
119 DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister
);
120 DEFINE_WRITEBACK_EVENT(writeback_thread_start
);
121 DEFINE_WRITEBACK_EVENT(writeback_thread_stop
);
123 DECLARE_EVENT_CLASS(wbc_class
,
124 TP_PROTO(struct writeback_control
*wbc
, struct backing_dev_info
*bdi
),
127 __array(char, name
, 32)
128 __field(long, nr_to_write
)
129 __field(long, pages_skipped
)
130 __field(int, sync_mode
)
131 __field(int, for_kupdate
)
132 __field(int, for_background
)
133 __field(int, for_reclaim
)
134 __field(int, range_cyclic
)
135 __field(long, range_start
)
136 __field(long, range_end
)
140 strncpy(__entry
->name
, dev_name(bdi
->dev
), 32);
141 __entry
->nr_to_write
= wbc
->nr_to_write
;
142 __entry
->pages_skipped
= wbc
->pages_skipped
;
143 __entry
->sync_mode
= wbc
->sync_mode
;
144 __entry
->for_kupdate
= wbc
->for_kupdate
;
145 __entry
->for_background
= wbc
->for_background
;
146 __entry
->for_reclaim
= wbc
->for_reclaim
;
147 __entry
->range_cyclic
= wbc
->range_cyclic
;
148 __entry
->range_start
= (long)wbc
->range_start
;
149 __entry
->range_end
= (long)wbc
->range_end
;
152 TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
153 "bgrd=%d reclm=%d cyclic=%d "
154 "start=0x%lx end=0x%lx",
156 __entry
->nr_to_write
,
157 __entry
->pages_skipped
,
159 __entry
->for_kupdate
,
160 __entry
->for_background
,
161 __entry
->for_reclaim
,
162 __entry
->range_cyclic
,
163 __entry
->range_start
,
167 #define DEFINE_WBC_EVENT(name) \
168 DEFINE_EVENT(wbc_class, name, \
169 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
171 DEFINE_WBC_EVENT(wbc_writepage
);
173 TRACE_EVENT(writeback_queue_io
,
174 TP_PROTO(struct bdi_writeback
*wb
,
175 struct wb_writeback_work
*work
,
177 TP_ARGS(wb
, work
, moved
),
179 __array(char, name
, 32)
180 __field(unsigned long, older
)
186 unsigned long *older_than_this
= work
->older_than_this
;
187 strncpy(__entry
->name
, dev_name(wb
->bdi
->dev
), 32);
188 __entry
->older
= older_than_this
? *older_than_this
: 0;
189 __entry
->age
= older_than_this
?
190 (jiffies
- *older_than_this
) * 1000 / HZ
: -1;
191 __entry
->moved
= moved
;
192 __entry
->reason
= work
->reason
;
194 TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s",
196 __entry
->older
, /* older_than_this in jiffies */
197 __entry
->age
, /* older_than_this in relative milliseconds */
199 __print_symbolic(__entry
->reason
, WB_WORK_REASON
)
203 TRACE_EVENT(global_dirty_state
,
205 TP_PROTO(unsigned long background_thresh
,
206 unsigned long dirty_thresh
209 TP_ARGS(background_thresh
,
214 __field(unsigned long, nr_dirty
)
215 __field(unsigned long, nr_writeback
)
216 __field(unsigned long, nr_unstable
)
217 __field(unsigned long, background_thresh
)
218 __field(unsigned long, dirty_thresh
)
219 __field(unsigned long, dirty_limit
)
220 __field(unsigned long, nr_dirtied
)
221 __field(unsigned long, nr_written
)
225 __entry
->nr_dirty
= global_page_state(NR_FILE_DIRTY
);
226 __entry
->nr_writeback
= global_page_state(NR_WRITEBACK
);
227 __entry
->nr_unstable
= global_page_state(NR_UNSTABLE_NFS
);
228 __entry
->nr_dirtied
= global_page_state(NR_DIRTIED
);
229 __entry
->nr_written
= global_page_state(NR_WRITTEN
);
230 __entry
->background_thresh
= background_thresh
;
231 __entry
->dirty_thresh
= dirty_thresh
;
232 __entry
->dirty_limit
= global_dirty_limit
;
235 TP_printk("dirty=%lu writeback=%lu unstable=%lu "
236 "bg_thresh=%lu thresh=%lu limit=%lu "
237 "dirtied=%lu written=%lu",
239 __entry
->nr_writeback
,
240 __entry
->nr_unstable
,
241 __entry
->background_thresh
,
242 __entry
->dirty_thresh
,
243 __entry
->dirty_limit
,
249 #define KBps(x) ((x) << (PAGE_SHIFT - 10))
251 TRACE_EVENT(bdi_dirty_ratelimit
,
253 TP_PROTO(struct backing_dev_info
*bdi
,
254 unsigned long dirty_rate
,
255 unsigned long task_ratelimit
),
257 TP_ARGS(bdi
, dirty_rate
, task_ratelimit
),
260 __array(char, bdi
, 32)
261 __field(unsigned long, write_bw
)
262 __field(unsigned long, avg_write_bw
)
263 __field(unsigned long, dirty_rate
)
264 __field(unsigned long, dirty_ratelimit
)
265 __field(unsigned long, task_ratelimit
)
266 __field(unsigned long, balanced_dirty_ratelimit
)
270 strlcpy(__entry
->bdi
, dev_name(bdi
->dev
), 32);
271 __entry
->write_bw
= KBps(bdi
->write_bandwidth
);
272 __entry
->avg_write_bw
= KBps(bdi
->avg_write_bandwidth
);
273 __entry
->dirty_rate
= KBps(dirty_rate
);
274 __entry
->dirty_ratelimit
= KBps(bdi
->dirty_ratelimit
);
275 __entry
->task_ratelimit
= KBps(task_ratelimit
);
276 __entry
->balanced_dirty_ratelimit
=
277 KBps(bdi
->balanced_dirty_ratelimit
);
281 "write_bw=%lu awrite_bw=%lu dirty_rate=%lu "
282 "dirty_ratelimit=%lu task_ratelimit=%lu "
283 "balanced_dirty_ratelimit=%lu",
285 __entry
->write_bw
, /* write bandwidth */
286 __entry
->avg_write_bw
, /* avg write bandwidth */
287 __entry
->dirty_rate
, /* bdi dirty rate */
288 __entry
->dirty_ratelimit
, /* base ratelimit */
289 __entry
->task_ratelimit
, /* ratelimit with position control */
290 __entry
->balanced_dirty_ratelimit
/* the balanced ratelimit */
294 TRACE_EVENT(balance_dirty_pages
,
296 TP_PROTO(struct backing_dev_info
*bdi
,
297 unsigned long thresh
,
298 unsigned long bg_thresh
,
300 unsigned long bdi_thresh
,
301 unsigned long bdi_dirty
,
302 unsigned long dirty_ratelimit
,
303 unsigned long task_ratelimit
,
304 unsigned long dirtied
,
305 unsigned long period
,
307 unsigned long start_time
),
309 TP_ARGS(bdi
, thresh
, bg_thresh
, dirty
, bdi_thresh
, bdi_dirty
,
310 dirty_ratelimit
, task_ratelimit
,
311 dirtied
, period
, pause
, start_time
),
314 __array( char, bdi
, 32)
315 __field(unsigned long, limit
)
316 __field(unsigned long, setpoint
)
317 __field(unsigned long, dirty
)
318 __field(unsigned long, bdi_setpoint
)
319 __field(unsigned long, bdi_dirty
)
320 __field(unsigned long, dirty_ratelimit
)
321 __field(unsigned long, task_ratelimit
)
322 __field(unsigned int, dirtied
)
323 __field(unsigned int, dirtied_pause
)
324 __field(unsigned long, paused
)
325 __field( long, pause
)
326 __field(unsigned long, period
)
327 __field( long, think
)
331 unsigned long freerun
= (thresh
+ bg_thresh
) / 2;
332 strlcpy(__entry
->bdi
, dev_name(bdi
->dev
), 32);
334 __entry
->limit
= global_dirty_limit
;
335 __entry
->setpoint
= (global_dirty_limit
+ freerun
) / 2;
336 __entry
->dirty
= dirty
;
337 __entry
->bdi_setpoint
= __entry
->setpoint
*
338 bdi_thresh
/ (thresh
+ 1);
339 __entry
->bdi_dirty
= bdi_dirty
;
340 __entry
->dirty_ratelimit
= KBps(dirty_ratelimit
);
341 __entry
->task_ratelimit
= KBps(task_ratelimit
);
342 __entry
->dirtied
= dirtied
;
343 __entry
->dirtied_pause
= current
->nr_dirtied_pause
;
344 __entry
->think
= current
->dirty_paused_when
== 0 ? 0 :
345 (long)(jiffies
- current
->dirty_paused_when
) * 1000/HZ
;
346 __entry
->period
= period
* 1000 / HZ
;
347 __entry
->pause
= pause
* 1000 / HZ
;
348 __entry
->paused
= (jiffies
- start_time
) * 1000 / HZ
;
353 "limit=%lu setpoint=%lu dirty=%lu "
354 "bdi_setpoint=%lu bdi_dirty=%lu "
355 "dirty_ratelimit=%lu task_ratelimit=%lu "
356 "dirtied=%u dirtied_pause=%u "
357 "paused=%lu pause=%ld period=%lu think=%ld",
362 __entry
->bdi_setpoint
,
364 __entry
->dirty_ratelimit
,
365 __entry
->task_ratelimit
,
367 __entry
->dirtied_pause
,
368 __entry
->paused
, /* ms */
369 __entry
->pause
, /* ms */
370 __entry
->period
, /* ms */
371 __entry
->think
/* ms */
375 TRACE_EVENT(writeback_sb_inodes_requeue
,
377 TP_PROTO(struct inode
*inode
),
381 __array(char, name
, 32)
382 __field(unsigned long, ino
)
383 __field(unsigned long, state
)
384 __field(unsigned long, dirtied_when
)
388 strncpy(__entry
->name
,
389 dev_name(inode_to_bdi(inode
)->dev
), 32);
390 __entry
->ino
= inode
->i_ino
;
391 __entry
->state
= inode
->i_state
;
392 __entry
->dirtied_when
= inode
->dirtied_when
;
395 TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu",
398 show_inode_state(__entry
->state
),
399 __entry
->dirtied_when
,
400 (jiffies
- __entry
->dirtied_when
) / HZ
404 DECLARE_EVENT_CLASS(writeback_congest_waited_template
,
406 TP_PROTO(unsigned int usec_timeout
, unsigned int usec_delayed
),
408 TP_ARGS(usec_timeout
, usec_delayed
),
411 __field( unsigned int, usec_timeout
)
412 __field( unsigned int, usec_delayed
)
416 __entry
->usec_timeout
= usec_timeout
;
417 __entry
->usec_delayed
= usec_delayed
;
420 TP_printk("usec_timeout=%u usec_delayed=%u",
421 __entry
->usec_timeout
,
422 __entry
->usec_delayed
)
425 DEFINE_EVENT(writeback_congest_waited_template
, writeback_congestion_wait
,
427 TP_PROTO(unsigned int usec_timeout
, unsigned int usec_delayed
),
429 TP_ARGS(usec_timeout
, usec_delayed
)
432 DEFINE_EVENT(writeback_congest_waited_template
, writeback_wait_iff_congested
,
434 TP_PROTO(unsigned int usec_timeout
, unsigned int usec_delayed
),
436 TP_ARGS(usec_timeout
, usec_delayed
)
439 DECLARE_EVENT_CLASS(writeback_single_inode_template
,
441 TP_PROTO(struct inode
*inode
,
442 struct writeback_control
*wbc
,
443 unsigned long nr_to_write
446 TP_ARGS(inode
, wbc
, nr_to_write
),
449 __array(char, name
, 32)
450 __field(unsigned long, ino
)
451 __field(unsigned long, state
)
452 __field(unsigned long, dirtied_when
)
453 __field(unsigned long, writeback_index
)
454 __field(long, nr_to_write
)
455 __field(unsigned long, wrote
)
459 strncpy(__entry
->name
,
460 dev_name(inode_to_bdi(inode
)->dev
), 32);
461 __entry
->ino
= inode
->i_ino
;
462 __entry
->state
= inode
->i_state
;
463 __entry
->dirtied_when
= inode
->dirtied_when
;
464 __entry
->writeback_index
= inode
->i_mapping
->writeback_index
;
465 __entry
->nr_to_write
= nr_to_write
;
466 __entry
->wrote
= nr_to_write
- wbc
->nr_to_write
;
469 TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu "
470 "index=%lu to_write=%ld wrote=%lu",
473 show_inode_state(__entry
->state
),
474 __entry
->dirtied_when
,
475 (jiffies
- __entry
->dirtied_when
) / HZ
,
476 __entry
->writeback_index
,
477 __entry
->nr_to_write
,
482 DEFINE_EVENT(writeback_single_inode_template
, writeback_single_inode
,
483 TP_PROTO(struct inode
*inode
,
484 struct writeback_control
*wbc
,
485 unsigned long nr_to_write
),
486 TP_ARGS(inode
, wbc
, nr_to_write
)
489 #endif /* _TRACE_WRITEBACK_H */
491 /* This part must be outside protection */
492 #include <trace/define_trace.h>