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 TRACE_EVENT(writeback_dirty_page
,
37 TP_PROTO(struct page
*page
, struct address_space
*mapping
),
39 TP_ARGS(page
, mapping
),
42 __array(char, name
, 32)
43 __field(unsigned long, ino
)
44 __field(pgoff_t
, index
)
48 strncpy(__entry
->name
,
49 mapping
? dev_name(mapping
->backing_dev_info
->dev
) : "(unknown)", 32);
50 __entry
->ino
= mapping
? mapping
->host
->i_ino
: 0;
51 __entry
->index
= page
->index
;
54 TP_printk("bdi %s: ino=%lu index=%lu",
61 DECLARE_EVENT_CLASS(writeback_dirty_inode_template
,
63 TP_PROTO(struct inode
*inode
, int flags
),
65 TP_ARGS(inode
, flags
),
68 __array(char, name
, 32)
69 __field(unsigned long, ino
)
70 __field(unsigned long, flags
)
74 struct backing_dev_info
*bdi
= inode
->i_mapping
->backing_dev_info
;
76 /* may be called for files on pseudo FSes w/ unregistered bdi */
77 strncpy(__entry
->name
,
78 bdi
->dev
? dev_name(bdi
->dev
) : "(unknown)", 32);
79 __entry
->ino
= inode
->i_ino
;
80 __entry
->flags
= flags
;
83 TP_printk("bdi %s: ino=%lu flags=%s",
86 show_inode_state(__entry
->flags
)
90 DEFINE_EVENT(writeback_dirty_inode_template
, writeback_dirty_inode_start
,
92 TP_PROTO(struct inode
*inode
, int flags
),
97 DEFINE_EVENT(writeback_dirty_inode_template
, writeback_dirty_inode
,
99 TP_PROTO(struct inode
*inode
, int flags
),
101 TP_ARGS(inode
, flags
)
104 DECLARE_EVENT_CLASS(writeback_write_inode_template
,
106 TP_PROTO(struct inode
*inode
, struct writeback_control
*wbc
),
111 __array(char, name
, 32)
112 __field(unsigned long, ino
)
113 __field(int, sync_mode
)
117 strncpy(__entry
->name
,
118 dev_name(inode
->i_mapping
->backing_dev_info
->dev
), 32);
119 __entry
->ino
= inode
->i_ino
;
120 __entry
->sync_mode
= wbc
->sync_mode
;
123 TP_printk("bdi %s: ino=%lu sync_mode=%d",
130 DEFINE_EVENT(writeback_write_inode_template
, writeback_write_inode_start
,
132 TP_PROTO(struct inode
*inode
, struct writeback_control
*wbc
),
137 DEFINE_EVENT(writeback_write_inode_template
, writeback_write_inode
,
139 TP_PROTO(struct inode
*inode
, struct writeback_control
*wbc
),
144 DECLARE_EVENT_CLASS(writeback_work_class
,
145 TP_PROTO(struct backing_dev_info
*bdi
, struct wb_writeback_work
*work
),
148 __array(char, name
, 32)
149 __field(long, nr_pages
)
150 __field(dev_t
, sb_dev
)
151 __field(int, sync_mode
)
152 __field(int, for_kupdate
)
153 __field(int, range_cyclic
)
154 __field(int, for_background
)
158 struct device
*dev
= bdi
->dev
;
160 dev
= default_backing_dev_info
.dev
;
161 strncpy(__entry
->name
, dev_name(dev
), 32);
162 __entry
->nr_pages
= work
->nr_pages
;
163 __entry
->sb_dev
= work
->sb
? work
->sb
->s_dev
: 0;
164 __entry
->sync_mode
= work
->sync_mode
;
165 __entry
->for_kupdate
= work
->for_kupdate
;
166 __entry
->range_cyclic
= work
->range_cyclic
;
167 __entry
->for_background
= work
->for_background
;
168 __entry
->reason
= work
->reason
;
170 TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
171 "kupdate=%d range_cyclic=%d background=%d reason=%s",
173 MAJOR(__entry
->sb_dev
), MINOR(__entry
->sb_dev
),
176 __entry
->for_kupdate
,
177 __entry
->range_cyclic
,
178 __entry
->for_background
,
179 __print_symbolic(__entry
->reason
, WB_WORK_REASON
)
182 #define DEFINE_WRITEBACK_WORK_EVENT(name) \
183 DEFINE_EVENT(writeback_work_class, name, \
184 TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \
186 DEFINE_WRITEBACK_WORK_EVENT(writeback_queue
);
187 DEFINE_WRITEBACK_WORK_EVENT(writeback_exec
);
188 DEFINE_WRITEBACK_WORK_EVENT(writeback_start
);
189 DEFINE_WRITEBACK_WORK_EVENT(writeback_written
);
190 DEFINE_WRITEBACK_WORK_EVENT(writeback_wait
);
192 TRACE_EVENT(writeback_pages_written
,
193 TP_PROTO(long pages_written
),
194 TP_ARGS(pages_written
),
199 __entry
->pages
= pages_written
;
201 TP_printk("%ld", __entry
->pages
)
204 DECLARE_EVENT_CLASS(writeback_class
,
205 TP_PROTO(struct backing_dev_info
*bdi
),
208 __array(char, name
, 32)
211 strncpy(__entry
->name
, dev_name(bdi
->dev
), 32);
217 #define DEFINE_WRITEBACK_EVENT(name) \
218 DEFINE_EVENT(writeback_class, name, \
219 TP_PROTO(struct backing_dev_info *bdi), \
222 DEFINE_WRITEBACK_EVENT(writeback_nowork
);
223 DEFINE_WRITEBACK_EVENT(writeback_wake_background
);
224 DEFINE_WRITEBACK_EVENT(writeback_bdi_register
);
225 DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister
);
227 DECLARE_EVENT_CLASS(wbc_class
,
228 TP_PROTO(struct writeback_control
*wbc
, struct backing_dev_info
*bdi
),
231 __array(char, name
, 32)
232 __field(long, nr_to_write
)
233 __field(long, pages_skipped
)
234 __field(int, sync_mode
)
235 __field(int, for_kupdate
)
236 __field(int, for_background
)
237 __field(int, for_reclaim
)
238 __field(int, range_cyclic
)
239 __field(long, range_start
)
240 __field(long, range_end
)
244 strncpy(__entry
->name
, dev_name(bdi
->dev
), 32);
245 __entry
->nr_to_write
= wbc
->nr_to_write
;
246 __entry
->pages_skipped
= wbc
->pages_skipped
;
247 __entry
->sync_mode
= wbc
->sync_mode
;
248 __entry
->for_kupdate
= wbc
->for_kupdate
;
249 __entry
->for_background
= wbc
->for_background
;
250 __entry
->for_reclaim
= wbc
->for_reclaim
;
251 __entry
->range_cyclic
= wbc
->range_cyclic
;
252 __entry
->range_start
= (long)wbc
->range_start
;
253 __entry
->range_end
= (long)wbc
->range_end
;
256 TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
257 "bgrd=%d reclm=%d cyclic=%d "
258 "start=0x%lx end=0x%lx",
260 __entry
->nr_to_write
,
261 __entry
->pages_skipped
,
263 __entry
->for_kupdate
,
264 __entry
->for_background
,
265 __entry
->for_reclaim
,
266 __entry
->range_cyclic
,
267 __entry
->range_start
,
271 #define DEFINE_WBC_EVENT(name) \
272 DEFINE_EVENT(wbc_class, name, \
273 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
275 DEFINE_WBC_EVENT(wbc_writepage
);
277 TRACE_EVENT(writeback_queue_io
,
278 TP_PROTO(struct bdi_writeback
*wb
,
279 struct wb_writeback_work
*work
,
281 TP_ARGS(wb
, work
, moved
),
283 __array(char, name
, 32)
284 __field(unsigned long, older
)
290 unsigned long *older_than_this
= work
->older_than_this
;
291 strncpy(__entry
->name
, dev_name(wb
->bdi
->dev
), 32);
292 __entry
->older
= older_than_this
? *older_than_this
: 0;
293 __entry
->age
= older_than_this
?
294 (jiffies
- *older_than_this
) * 1000 / HZ
: -1;
295 __entry
->moved
= moved
;
296 __entry
->reason
= work
->reason
;
298 TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s",
300 __entry
->older
, /* older_than_this in jiffies */
301 __entry
->age
, /* older_than_this in relative milliseconds */
303 __print_symbolic(__entry
->reason
, WB_WORK_REASON
)
307 TRACE_EVENT(global_dirty_state
,
309 TP_PROTO(unsigned long background_thresh
,
310 unsigned long dirty_thresh
313 TP_ARGS(background_thresh
,
318 __field(unsigned long, nr_dirty
)
319 __field(unsigned long, nr_writeback
)
320 __field(unsigned long, nr_unstable
)
321 __field(unsigned long, background_thresh
)
322 __field(unsigned long, dirty_thresh
)
323 __field(unsigned long, dirty_limit
)
324 __field(unsigned long, nr_dirtied
)
325 __field(unsigned long, nr_written
)
329 __entry
->nr_dirty
= global_page_state(NR_FILE_DIRTY
);
330 __entry
->nr_writeback
= global_page_state(NR_WRITEBACK
);
331 __entry
->nr_unstable
= global_page_state(NR_UNSTABLE_NFS
);
332 __entry
->nr_dirtied
= global_page_state(NR_DIRTIED
);
333 __entry
->nr_written
= global_page_state(NR_WRITTEN
);
334 __entry
->background_thresh
= background_thresh
;
335 __entry
->dirty_thresh
= dirty_thresh
;
336 __entry
->dirty_limit
= global_dirty_limit
;
339 TP_printk("dirty=%lu writeback=%lu unstable=%lu "
340 "bg_thresh=%lu thresh=%lu limit=%lu "
341 "dirtied=%lu written=%lu",
343 __entry
->nr_writeback
,
344 __entry
->nr_unstable
,
345 __entry
->background_thresh
,
346 __entry
->dirty_thresh
,
347 __entry
->dirty_limit
,
353 #define KBps(x) ((x) << (PAGE_SHIFT - 10))
355 TRACE_EVENT(bdi_dirty_ratelimit
,
357 TP_PROTO(struct backing_dev_info
*bdi
,
358 unsigned long dirty_rate
,
359 unsigned long task_ratelimit
),
361 TP_ARGS(bdi
, dirty_rate
, task_ratelimit
),
364 __array(char, bdi
, 32)
365 __field(unsigned long, write_bw
)
366 __field(unsigned long, avg_write_bw
)
367 __field(unsigned long, dirty_rate
)
368 __field(unsigned long, dirty_ratelimit
)
369 __field(unsigned long, task_ratelimit
)
370 __field(unsigned long, balanced_dirty_ratelimit
)
374 strlcpy(__entry
->bdi
, dev_name(bdi
->dev
), 32);
375 __entry
->write_bw
= KBps(bdi
->write_bandwidth
);
376 __entry
->avg_write_bw
= KBps(bdi
->avg_write_bandwidth
);
377 __entry
->dirty_rate
= KBps(dirty_rate
);
378 __entry
->dirty_ratelimit
= KBps(bdi
->dirty_ratelimit
);
379 __entry
->task_ratelimit
= KBps(task_ratelimit
);
380 __entry
->balanced_dirty_ratelimit
=
381 KBps(bdi
->balanced_dirty_ratelimit
);
385 "write_bw=%lu awrite_bw=%lu dirty_rate=%lu "
386 "dirty_ratelimit=%lu task_ratelimit=%lu "
387 "balanced_dirty_ratelimit=%lu",
389 __entry
->write_bw
, /* write bandwidth */
390 __entry
->avg_write_bw
, /* avg write bandwidth */
391 __entry
->dirty_rate
, /* bdi dirty rate */
392 __entry
->dirty_ratelimit
, /* base ratelimit */
393 __entry
->task_ratelimit
, /* ratelimit with position control */
394 __entry
->balanced_dirty_ratelimit
/* the balanced ratelimit */
398 TRACE_EVENT(balance_dirty_pages
,
400 TP_PROTO(struct backing_dev_info
*bdi
,
401 unsigned long thresh
,
402 unsigned long bg_thresh
,
404 unsigned long bdi_thresh
,
405 unsigned long bdi_dirty
,
406 unsigned long dirty_ratelimit
,
407 unsigned long task_ratelimit
,
408 unsigned long dirtied
,
409 unsigned long period
,
411 unsigned long start_time
),
413 TP_ARGS(bdi
, thresh
, bg_thresh
, dirty
, bdi_thresh
, bdi_dirty
,
414 dirty_ratelimit
, task_ratelimit
,
415 dirtied
, period
, pause
, start_time
),
418 __array( char, bdi
, 32)
419 __field(unsigned long, limit
)
420 __field(unsigned long, setpoint
)
421 __field(unsigned long, dirty
)
422 __field(unsigned long, bdi_setpoint
)
423 __field(unsigned long, bdi_dirty
)
424 __field(unsigned long, dirty_ratelimit
)
425 __field(unsigned long, task_ratelimit
)
426 __field(unsigned int, dirtied
)
427 __field(unsigned int, dirtied_pause
)
428 __field(unsigned long, paused
)
429 __field( long, pause
)
430 __field(unsigned long, period
)
431 __field( long, think
)
435 unsigned long freerun
= (thresh
+ bg_thresh
) / 2;
436 strlcpy(__entry
->bdi
, dev_name(bdi
->dev
), 32);
438 __entry
->limit
= global_dirty_limit
;
439 __entry
->setpoint
= (global_dirty_limit
+ freerun
) / 2;
440 __entry
->dirty
= dirty
;
441 __entry
->bdi_setpoint
= __entry
->setpoint
*
442 bdi_thresh
/ (thresh
+ 1);
443 __entry
->bdi_dirty
= bdi_dirty
;
444 __entry
->dirty_ratelimit
= KBps(dirty_ratelimit
);
445 __entry
->task_ratelimit
= KBps(task_ratelimit
);
446 __entry
->dirtied
= dirtied
;
447 __entry
->dirtied_pause
= current
->nr_dirtied_pause
;
448 __entry
->think
= current
->dirty_paused_when
== 0 ? 0 :
449 (long)(jiffies
- current
->dirty_paused_when
) * 1000/HZ
;
450 __entry
->period
= period
* 1000 / HZ
;
451 __entry
->pause
= pause
* 1000 / HZ
;
452 __entry
->paused
= (jiffies
- start_time
) * 1000 / HZ
;
457 "limit=%lu setpoint=%lu dirty=%lu "
458 "bdi_setpoint=%lu bdi_dirty=%lu "
459 "dirty_ratelimit=%lu task_ratelimit=%lu "
460 "dirtied=%u dirtied_pause=%u "
461 "paused=%lu pause=%ld period=%lu think=%ld",
466 __entry
->bdi_setpoint
,
468 __entry
->dirty_ratelimit
,
469 __entry
->task_ratelimit
,
471 __entry
->dirtied_pause
,
472 __entry
->paused
, /* ms */
473 __entry
->pause
, /* ms */
474 __entry
->period
, /* ms */
475 __entry
->think
/* ms */
479 TRACE_EVENT(writeback_sb_inodes_requeue
,
481 TP_PROTO(struct inode
*inode
),
485 __array(char, name
, 32)
486 __field(unsigned long, ino
)
487 __field(unsigned long, state
)
488 __field(unsigned long, dirtied_when
)
492 strncpy(__entry
->name
,
493 dev_name(inode_to_bdi(inode
)->dev
), 32);
494 __entry
->ino
= inode
->i_ino
;
495 __entry
->state
= inode
->i_state
;
496 __entry
->dirtied_when
= inode
->dirtied_when
;
499 TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu",
502 show_inode_state(__entry
->state
),
503 __entry
->dirtied_when
,
504 (jiffies
- __entry
->dirtied_when
) / HZ
508 DECLARE_EVENT_CLASS(writeback_congest_waited_template
,
510 TP_PROTO(unsigned int usec_timeout
, unsigned int usec_delayed
),
512 TP_ARGS(usec_timeout
, usec_delayed
),
515 __field( unsigned int, usec_timeout
)
516 __field( unsigned int, usec_delayed
)
520 __entry
->usec_timeout
= usec_timeout
;
521 __entry
->usec_delayed
= usec_delayed
;
524 TP_printk("usec_timeout=%u usec_delayed=%u",
525 __entry
->usec_timeout
,
526 __entry
->usec_delayed
)
529 DEFINE_EVENT(writeback_congest_waited_template
, writeback_congestion_wait
,
531 TP_PROTO(unsigned int usec_timeout
, unsigned int usec_delayed
),
533 TP_ARGS(usec_timeout
, usec_delayed
)
536 DEFINE_EVENT(writeback_congest_waited_template
, writeback_wait_iff_congested
,
538 TP_PROTO(unsigned int usec_timeout
, unsigned int usec_delayed
),
540 TP_ARGS(usec_timeout
, usec_delayed
)
543 DECLARE_EVENT_CLASS(writeback_single_inode_template
,
545 TP_PROTO(struct inode
*inode
,
546 struct writeback_control
*wbc
,
547 unsigned long nr_to_write
550 TP_ARGS(inode
, wbc
, nr_to_write
),
553 __array(char, name
, 32)
554 __field(unsigned long, ino
)
555 __field(unsigned long, state
)
556 __field(unsigned long, dirtied_when
)
557 __field(unsigned long, writeback_index
)
558 __field(long, nr_to_write
)
559 __field(unsigned long, wrote
)
563 strncpy(__entry
->name
,
564 dev_name(inode_to_bdi(inode
)->dev
), 32);
565 __entry
->ino
= inode
->i_ino
;
566 __entry
->state
= inode
->i_state
;
567 __entry
->dirtied_when
= inode
->dirtied_when
;
568 __entry
->writeback_index
= inode
->i_mapping
->writeback_index
;
569 __entry
->nr_to_write
= nr_to_write
;
570 __entry
->wrote
= nr_to_write
- wbc
->nr_to_write
;
573 TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu "
574 "index=%lu to_write=%ld wrote=%lu",
577 show_inode_state(__entry
->state
),
578 __entry
->dirtied_when
,
579 (jiffies
- __entry
->dirtied_when
) / HZ
,
580 __entry
->writeback_index
,
581 __entry
->nr_to_write
,
586 DEFINE_EVENT(writeback_single_inode_template
, writeback_single_inode_start
,
587 TP_PROTO(struct inode
*inode
,
588 struct writeback_control
*wbc
,
589 unsigned long nr_to_write
),
590 TP_ARGS(inode
, wbc
, nr_to_write
)
593 DEFINE_EVENT(writeback_single_inode_template
, writeback_single_inode
,
594 TP_PROTO(struct inode
*inode
,
595 struct writeback_control
*wbc
,
596 unsigned long nr_to_write
),
597 TP_ARGS(inode
, wbc
, nr_to_write
)
600 #endif /* _TRACE_WRITEBACK_H */
602 /* This part must be outside protection */
603 #include <trace/define_trace.h>