Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
writeback.h
Go to the documentation of this file.
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM writeback
3 
4 #if !defined(_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_WRITEBACK_H
6 
7 #include <linux/backing-dev.h>
8 #include <linux/writeback.h>
9 
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"}, \
15  {I_NEW, "I_NEW"}, \
16  {I_WILL_FREE, "I_WILL_FREE"}, \
17  {I_FREEING, "I_FREEING"}, \
18  {I_CLEAR, "I_CLEAR"}, \
19  {I_SYNC, "I_SYNC"}, \
20  {I_REFERENCED, "I_REFERENCED"} \
21  )
22 
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"}
32 
33 struct wb_writeback_work;
34 
35 DECLARE_EVENT_CLASS(writeback_work_class,
36  TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work),
37  TP_ARGS(bdi, 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)
46  __field(int, reason)
47  ),
49  struct device *dev = bdi->dev;
50  if (!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;
60  ),
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",
63  __entry->name,
64  MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev),
65  __entry->nr_pages,
66  __entry->sync_mode,
67  __entry->for_kupdate,
68  __entry->range_cyclic,
69  __entry->for_background,
71  )
72 );
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), \
76  TP_ARGS(bdi, 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);
83 
84 TRACE_EVENT(writeback_pages_written,
85  TP_PROTO(long pages_written),
86  TP_ARGS(pages_written),
88  __field(long, pages)
89  ),
91  __entry->pages = pages_written;
92  ),
93  TP_printk("%ld", __entry->pages)
94 );
95 
96 DECLARE_EVENT_CLASS(writeback_class,
97  TP_PROTO(struct backing_dev_info *bdi),
98  TP_ARGS(bdi),
100  __array(char, name, 32)
101  ),
103  strncpy(__entry->name, dev_name(bdi->dev), 32);
104  ),
105  TP_printk("bdi %s",
106  __entry->name
107  )
108 );
109 #define DEFINE_WRITEBACK_EVENT(name) \
110 DEFINE_EVENT(writeback_class, name, \
111  TP_PROTO(struct backing_dev_info *bdi), \
112  TP_ARGS(bdi))
113 
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);
122 
123 DECLARE_EVENT_CLASS(wbc_class,
124  TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
125  TP_ARGS(wbc, 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)
137  ),
138 
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;
150  ),
151 
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",
155  __entry->name,
156  __entry->nr_to_write,
157  __entry->pages_skipped,
158  __entry->sync_mode,
159  __entry->for_kupdate,
160  __entry->for_background,
161  __entry->for_reclaim,
162  __entry->range_cyclic,
163  __entry->range_start,
164  __entry->range_end)
165 )
166 
167 #define DEFINE_WBC_EVENT(name) \
168 DEFINE_EVENT(wbc_class, name, \
169  TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
170  TP_ARGS(wbc, bdi))
171 DEFINE_WBC_EVENT(wbc_writepage);
172 
173 TRACE_EVENT(writeback_queue_io,
174  TP_PROTO(struct bdi_writeback *wb,
175  struct wb_writeback_work *work,
176  int moved),
177  TP_ARGS(wb, work, moved),
179  __array(char, name, 32)
180  __field(unsigned long, older)
181  __field(long, age)
182  __field(int, moved)
183  __field(int, reason)
184  ),
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;
193  ),
194  TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s",
195  __entry->name,
196  __entry->older, /* older_than_this in jiffies */
197  __entry->age, /* older_than_this in relative milliseconds */
198  __entry->moved,
200  )
201 );
202 
203 TRACE_EVENT(global_dirty_state,
204 
205  TP_PROTO(unsigned long background_thresh,
206  unsigned long dirty_thresh
207  ),
208 
209  TP_ARGS(background_thresh,
210  dirty_thresh
211  ),
212 
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)
222  ),
223 
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;
233  ),
234 
235  TP_printk("dirty=%lu writeback=%lu unstable=%lu "
236  "bg_thresh=%lu thresh=%lu limit=%lu "
237  "dirtied=%lu written=%lu",
238  __entry->nr_dirty,
239  __entry->nr_writeback,
240  __entry->nr_unstable,
241  __entry->background_thresh,
242  __entry->dirty_thresh,
243  __entry->dirty_limit,
244  __entry->nr_dirtied,
245  __entry->nr_written
246  )
247 );
248 
249 #define KBps(x) ((x) << (PAGE_SHIFT - 10))
250 
251 TRACE_EVENT(bdi_dirty_ratelimit,
252 
253  TP_PROTO(struct backing_dev_info *bdi,
254  unsigned long dirty_rate,
255  unsigned long task_ratelimit),
256 
257  TP_ARGS(bdi, dirty_rate, task_ratelimit),
258 
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)
267  ),
268 
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 =
278  ),
279 
280  TP_printk("bdi %s: "
281  "write_bw=%lu awrite_bw=%lu dirty_rate=%lu "
282  "dirty_ratelimit=%lu task_ratelimit=%lu "
283  "balanced_dirty_ratelimit=%lu",
284  __entry->bdi,
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 */
291  )
292 );
293 
294 TRACE_EVENT(balance_dirty_pages,
295 
296  TP_PROTO(struct backing_dev_info *bdi,
297  unsigned long thresh,
298  unsigned long bg_thresh,
299  unsigned long dirty,
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,
306  long pause,
307  unsigned long start_time),
308 
309  TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
310  dirty_ratelimit, task_ratelimit,
311  dirtied, period, pause, start_time),
312 
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)
328  ),
329 
331  unsigned long freerun = (thresh + bg_thresh) / 2;
332  strlcpy(__entry->bdi, dev_name(bdi->dev), 32);
333 
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;
349  ),
350 
351 
352  TP_printk("bdi %s: "
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",
358  __entry->bdi,
359  __entry->limit,
360  __entry->setpoint,
361  __entry->dirty,
362  __entry->bdi_setpoint,
363  __entry->bdi_dirty,
364  __entry->dirty_ratelimit,
365  __entry->task_ratelimit,
366  __entry->dirtied,
367  __entry->dirtied_pause,
368  __entry->paused, /* ms */
369  __entry->pause, /* ms */
370  __entry->period, /* ms */
371  __entry->think /* ms */
372  )
373 );
374 
375 TRACE_EVENT(writeback_sb_inodes_requeue,
376 
377  TP_PROTO(struct inode *inode),
378  TP_ARGS(inode),
379 
381  __array(char, name, 32)
382  __field(unsigned long, ino)
383  __field(unsigned long, state)
384  __field(unsigned long, dirtied_when)
385  ),
386 
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;
393  ),
394 
395  TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu",
396  __entry->name,
397  __entry->ino,
398  show_inode_state(__entry->state),
399  __entry->dirtied_when,
400  (jiffies - __entry->dirtied_when) / HZ
401  )
402 );
403 
404 DECLARE_EVENT_CLASS(writeback_congest_waited_template,
405 
406  TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
407 
408  TP_ARGS(usec_timeout, usec_delayed),
409 
411  __field( unsigned int, usec_timeout )
412  __field( unsigned int, usec_delayed )
413  ),
414 
416  __entry->usec_timeout = usec_timeout;
417  __entry->usec_delayed = usec_delayed;
418  ),
419 
420  TP_printk("usec_timeout=%u usec_delayed=%u",
421  __entry->usec_timeout,
422  __entry->usec_delayed)
423 );
424 
425 DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait,
426 
427  TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
428 
429  TP_ARGS(usec_timeout, usec_delayed)
430 );
431 
432 DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested,
433 
434  TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
435 
436  TP_ARGS(usec_timeout, usec_delayed)
437 );
438 
439 DECLARE_EVENT_CLASS(writeback_single_inode_template,
440 
441  TP_PROTO(struct inode *inode,
442  struct writeback_control *wbc,
443  unsigned long nr_to_write
444  ),
445 
446  TP_ARGS(inode, wbc, nr_to_write),
447 
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)
456  ),
457 
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;
467  ),
468 
469  TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu "
470  "index=%lu to_write=%ld wrote=%lu",
471  __entry->name,
472  __entry->ino,
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,
478  __entry->wrote
479  )
480 );
481 
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)
487 );
488 
489 #endif /* _TRACE_WRITEBACK_H */
490 
491 /* This part must be outside protection */
492 #include <trace/define_trace.h>