spi-topcliff-pch: add recovery processing in case wait-event timeout
[zen-stable.git] / include / trace / events / writeback.h
blob5973410e8f8cf34fd9fb1abaedb7325435716f9a
1 #undef TRACE_SYSTEM
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/device.h>
9 #include <linux/writeback.h>
11 #define show_inode_state(state) \
12 __print_flags(state, "|", \
13 {I_DIRTY_SYNC, "I_DIRTY_SYNC"}, \
14 {I_DIRTY_DATASYNC, "I_DIRTY_DATASYNC"}, \
15 {I_DIRTY_PAGES, "I_DIRTY_PAGES"}, \
16 {I_NEW, "I_NEW"}, \
17 {I_WILL_FREE, "I_WILL_FREE"}, \
18 {I_FREEING, "I_FREEING"}, \
19 {I_CLEAR, "I_CLEAR"}, \
20 {I_SYNC, "I_SYNC"}, \
21 {I_REFERENCED, "I_REFERENCED"} \
24 #define WB_WORK_REASON \
25 {WB_REASON_BACKGROUND, "background"}, \
26 {WB_REASON_TRY_TO_FREE_PAGES, "try_to_free_pages"}, \
27 {WB_REASON_SYNC, "sync"}, \
28 {WB_REASON_PERIODIC, "periodic"}, \
29 {WB_REASON_LAPTOP_TIMER, "laptop_timer"}, \
30 {WB_REASON_FREE_MORE_MEM, "free_more_memory"}, \
31 {WB_REASON_FS_FREE_SPACE, "fs_free_space"}, \
32 {WB_REASON_FORKER_THREAD, "forker_thread"}
34 struct wb_writeback_work;
36 DECLARE_EVENT_CLASS(writeback_work_class,
37 TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work),
38 TP_ARGS(bdi, work),
39 TP_STRUCT__entry(
40 __array(char, name, 32)
41 __field(long, nr_pages)
42 __field(dev_t, sb_dev)
43 __field(int, sync_mode)
44 __field(int, for_kupdate)
45 __field(int, range_cyclic)
46 __field(int, for_background)
47 __field(int, reason)
49 TP_fast_assign(
50 struct device *dev = bdi->dev;
51 if (!dev)
52 dev = default_backing_dev_info.dev;
53 strncpy(__entry->name, dev_name(dev), 32);
54 __entry->nr_pages = work->nr_pages;
55 __entry->sb_dev = work->sb ? work->sb->s_dev : 0;
56 __entry->sync_mode = work->sync_mode;
57 __entry->for_kupdate = work->for_kupdate;
58 __entry->range_cyclic = work->range_cyclic;
59 __entry->for_background = work->for_background;
60 __entry->reason = work->reason;
62 TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
63 "kupdate=%d range_cyclic=%d background=%d reason=%s",
64 __entry->name,
65 MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev),
66 __entry->nr_pages,
67 __entry->sync_mode,
68 __entry->for_kupdate,
69 __entry->range_cyclic,
70 __entry->for_background,
71 __print_symbolic(__entry->reason, WB_WORK_REASON)
74 #define DEFINE_WRITEBACK_WORK_EVENT(name) \
75 DEFINE_EVENT(writeback_work_class, name, \
76 TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \
77 TP_ARGS(bdi, work))
78 DEFINE_WRITEBACK_WORK_EVENT(writeback_nothread);
79 DEFINE_WRITEBACK_WORK_EVENT(writeback_queue);
80 DEFINE_WRITEBACK_WORK_EVENT(writeback_exec);
81 DEFINE_WRITEBACK_WORK_EVENT(writeback_start);
82 DEFINE_WRITEBACK_WORK_EVENT(writeback_written);
83 DEFINE_WRITEBACK_WORK_EVENT(writeback_wait);
85 TRACE_EVENT(writeback_pages_written,
86 TP_PROTO(long pages_written),
87 TP_ARGS(pages_written),
88 TP_STRUCT__entry(
89 __field(long, pages)
91 TP_fast_assign(
92 __entry->pages = pages_written;
94 TP_printk("%ld", __entry->pages)
97 DECLARE_EVENT_CLASS(writeback_class,
98 TP_PROTO(struct backing_dev_info *bdi),
99 TP_ARGS(bdi),
100 TP_STRUCT__entry(
101 __array(char, name, 32)
103 TP_fast_assign(
104 strncpy(__entry->name, dev_name(bdi->dev), 32);
106 TP_printk("bdi %s",
107 __entry->name
110 #define DEFINE_WRITEBACK_EVENT(name) \
111 DEFINE_EVENT(writeback_class, name, \
112 TP_PROTO(struct backing_dev_info *bdi), \
113 TP_ARGS(bdi))
115 DEFINE_WRITEBACK_EVENT(writeback_nowork);
116 DEFINE_WRITEBACK_EVENT(writeback_wake_background);
117 DEFINE_WRITEBACK_EVENT(writeback_wake_thread);
118 DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread);
119 DEFINE_WRITEBACK_EVENT(writeback_bdi_register);
120 DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister);
121 DEFINE_WRITEBACK_EVENT(writeback_thread_start);
122 DEFINE_WRITEBACK_EVENT(writeback_thread_stop);
124 DECLARE_EVENT_CLASS(wbc_class,
125 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
126 TP_ARGS(wbc, bdi),
127 TP_STRUCT__entry(
128 __array(char, name, 32)
129 __field(long, nr_to_write)
130 __field(long, pages_skipped)
131 __field(int, sync_mode)
132 __field(int, for_kupdate)
133 __field(int, for_background)
134 __field(int, for_reclaim)
135 __field(int, range_cyclic)
136 __field(long, range_start)
137 __field(long, range_end)
140 TP_fast_assign(
141 strncpy(__entry->name, dev_name(bdi->dev), 32);
142 __entry->nr_to_write = wbc->nr_to_write;
143 __entry->pages_skipped = wbc->pages_skipped;
144 __entry->sync_mode = wbc->sync_mode;
145 __entry->for_kupdate = wbc->for_kupdate;
146 __entry->for_background = wbc->for_background;
147 __entry->for_reclaim = wbc->for_reclaim;
148 __entry->range_cyclic = wbc->range_cyclic;
149 __entry->range_start = (long)wbc->range_start;
150 __entry->range_end = (long)wbc->range_end;
153 TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
154 "bgrd=%d reclm=%d cyclic=%d "
155 "start=0x%lx end=0x%lx",
156 __entry->name,
157 __entry->nr_to_write,
158 __entry->pages_skipped,
159 __entry->sync_mode,
160 __entry->for_kupdate,
161 __entry->for_background,
162 __entry->for_reclaim,
163 __entry->range_cyclic,
164 __entry->range_start,
165 __entry->range_end)
168 #define DEFINE_WBC_EVENT(name) \
169 DEFINE_EVENT(wbc_class, name, \
170 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
171 TP_ARGS(wbc, bdi))
172 DEFINE_WBC_EVENT(wbc_writepage);
174 TRACE_EVENT(writeback_queue_io,
175 TP_PROTO(struct bdi_writeback *wb,
176 struct wb_writeback_work *work,
177 int moved),
178 TP_ARGS(wb, work, moved),
179 TP_STRUCT__entry(
180 __array(char, name, 32)
181 __field(unsigned long, older)
182 __field(long, age)
183 __field(int, moved)
184 __field(int, reason)
186 TP_fast_assign(
187 unsigned long *older_than_this = work->older_than_this;
188 strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
189 __entry->older = older_than_this ? *older_than_this : 0;
190 __entry->age = older_than_this ?
191 (jiffies - *older_than_this) * 1000 / HZ : -1;
192 __entry->moved = moved;
193 __entry->reason = work->reason;
195 TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s",
196 __entry->name,
197 __entry->older, /* older_than_this in jiffies */
198 __entry->age, /* older_than_this in relative milliseconds */
199 __entry->moved,
200 __print_symbolic(__entry->reason, WB_WORK_REASON)
204 TRACE_EVENT(global_dirty_state,
206 TP_PROTO(unsigned long background_thresh,
207 unsigned long dirty_thresh
210 TP_ARGS(background_thresh,
211 dirty_thresh
214 TP_STRUCT__entry(
215 __field(unsigned long, nr_dirty)
216 __field(unsigned long, nr_writeback)
217 __field(unsigned long, nr_unstable)
218 __field(unsigned long, background_thresh)
219 __field(unsigned long, dirty_thresh)
220 __field(unsigned long, dirty_limit)
221 __field(unsigned long, nr_dirtied)
222 __field(unsigned long, nr_written)
225 TP_fast_assign(
226 __entry->nr_dirty = global_page_state(NR_FILE_DIRTY);
227 __entry->nr_writeback = global_page_state(NR_WRITEBACK);
228 __entry->nr_unstable = global_page_state(NR_UNSTABLE_NFS);
229 __entry->nr_dirtied = global_page_state(NR_DIRTIED);
230 __entry->nr_written = global_page_state(NR_WRITTEN);
231 __entry->background_thresh = background_thresh;
232 __entry->dirty_thresh = dirty_thresh;
233 __entry->dirty_limit = global_dirty_limit;
236 TP_printk("dirty=%lu writeback=%lu unstable=%lu "
237 "bg_thresh=%lu thresh=%lu limit=%lu "
238 "dirtied=%lu written=%lu",
239 __entry->nr_dirty,
240 __entry->nr_writeback,
241 __entry->nr_unstable,
242 __entry->background_thresh,
243 __entry->dirty_thresh,
244 __entry->dirty_limit,
245 __entry->nr_dirtied,
246 __entry->nr_written
250 #define KBps(x) ((x) << (PAGE_SHIFT - 10))
252 TRACE_EVENT(bdi_dirty_ratelimit,
254 TP_PROTO(struct backing_dev_info *bdi,
255 unsigned long dirty_rate,
256 unsigned long task_ratelimit),
258 TP_ARGS(bdi, dirty_rate, task_ratelimit),
260 TP_STRUCT__entry(
261 __array(char, bdi, 32)
262 __field(unsigned long, write_bw)
263 __field(unsigned long, avg_write_bw)
264 __field(unsigned long, dirty_rate)
265 __field(unsigned long, dirty_ratelimit)
266 __field(unsigned long, task_ratelimit)
267 __field(unsigned long, balanced_dirty_ratelimit)
270 TP_fast_assign(
271 strlcpy(__entry->bdi, dev_name(bdi->dev), 32);
272 __entry->write_bw = KBps(bdi->write_bandwidth);
273 __entry->avg_write_bw = KBps(bdi->avg_write_bandwidth);
274 __entry->dirty_rate = KBps(dirty_rate);
275 __entry->dirty_ratelimit = KBps(bdi->dirty_ratelimit);
276 __entry->task_ratelimit = KBps(task_ratelimit);
277 __entry->balanced_dirty_ratelimit =
278 KBps(bdi->balanced_dirty_ratelimit);
281 TP_printk("bdi %s: "
282 "write_bw=%lu awrite_bw=%lu dirty_rate=%lu "
283 "dirty_ratelimit=%lu task_ratelimit=%lu "
284 "balanced_dirty_ratelimit=%lu",
285 __entry->bdi,
286 __entry->write_bw, /* write bandwidth */
287 __entry->avg_write_bw, /* avg write bandwidth */
288 __entry->dirty_rate, /* bdi dirty rate */
289 __entry->dirty_ratelimit, /* base ratelimit */
290 __entry->task_ratelimit, /* ratelimit with position control */
291 __entry->balanced_dirty_ratelimit /* the balanced ratelimit */
295 TRACE_EVENT(balance_dirty_pages,
297 TP_PROTO(struct backing_dev_info *bdi,
298 unsigned long thresh,
299 unsigned long bg_thresh,
300 unsigned long dirty,
301 unsigned long bdi_thresh,
302 unsigned long bdi_dirty,
303 unsigned long dirty_ratelimit,
304 unsigned long task_ratelimit,
305 unsigned long dirtied,
306 unsigned long period,
307 long pause,
308 unsigned long start_time),
310 TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
311 dirty_ratelimit, task_ratelimit,
312 dirtied, period, pause, start_time),
314 TP_STRUCT__entry(
315 __array( char, bdi, 32)
316 __field(unsigned long, limit)
317 __field(unsigned long, setpoint)
318 __field(unsigned long, dirty)
319 __field(unsigned long, bdi_setpoint)
320 __field(unsigned long, bdi_dirty)
321 __field(unsigned long, dirty_ratelimit)
322 __field(unsigned long, task_ratelimit)
323 __field(unsigned int, dirtied)
324 __field(unsigned int, dirtied_pause)
325 __field(unsigned long, paused)
326 __field( long, pause)
327 __field(unsigned long, period)
328 __field( long, think)
331 TP_fast_assign(
332 unsigned long freerun = (thresh + bg_thresh) / 2;
333 strlcpy(__entry->bdi, dev_name(bdi->dev), 32);
335 __entry->limit = global_dirty_limit;
336 __entry->setpoint = (global_dirty_limit + freerun) / 2;
337 __entry->dirty = dirty;
338 __entry->bdi_setpoint = __entry->setpoint *
339 bdi_thresh / (thresh + 1);
340 __entry->bdi_dirty = bdi_dirty;
341 __entry->dirty_ratelimit = KBps(dirty_ratelimit);
342 __entry->task_ratelimit = KBps(task_ratelimit);
343 __entry->dirtied = dirtied;
344 __entry->dirtied_pause = current->nr_dirtied_pause;
345 __entry->think = current->dirty_paused_when == 0 ? 0 :
346 (long)(jiffies - current->dirty_paused_when) * 1000/HZ;
347 __entry->period = period * 1000 / HZ;
348 __entry->pause = pause * 1000 / HZ;
349 __entry->paused = (jiffies - start_time) * 1000 / HZ;
353 TP_printk("bdi %s: "
354 "limit=%lu setpoint=%lu dirty=%lu "
355 "bdi_setpoint=%lu bdi_dirty=%lu "
356 "dirty_ratelimit=%lu task_ratelimit=%lu "
357 "dirtied=%u dirtied_pause=%u "
358 "paused=%lu pause=%ld period=%lu think=%ld",
359 __entry->bdi,
360 __entry->limit,
361 __entry->setpoint,
362 __entry->dirty,
363 __entry->bdi_setpoint,
364 __entry->bdi_dirty,
365 __entry->dirty_ratelimit,
366 __entry->task_ratelimit,
367 __entry->dirtied,
368 __entry->dirtied_pause,
369 __entry->paused, /* ms */
370 __entry->pause, /* ms */
371 __entry->period, /* ms */
372 __entry->think /* ms */
376 DECLARE_EVENT_CLASS(writeback_congest_waited_template,
378 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
380 TP_ARGS(usec_timeout, usec_delayed),
382 TP_STRUCT__entry(
383 __field( unsigned int, usec_timeout )
384 __field( unsigned int, usec_delayed )
387 TP_fast_assign(
388 __entry->usec_timeout = usec_timeout;
389 __entry->usec_delayed = usec_delayed;
392 TP_printk("usec_timeout=%u usec_delayed=%u",
393 __entry->usec_timeout,
394 __entry->usec_delayed)
397 DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait,
399 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
401 TP_ARGS(usec_timeout, usec_delayed)
404 DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested,
406 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
408 TP_ARGS(usec_timeout, usec_delayed)
411 DECLARE_EVENT_CLASS(writeback_single_inode_template,
413 TP_PROTO(struct inode *inode,
414 struct writeback_control *wbc,
415 unsigned long nr_to_write
418 TP_ARGS(inode, wbc, nr_to_write),
420 TP_STRUCT__entry(
421 __array(char, name, 32)
422 __field(unsigned long, ino)
423 __field(unsigned long, state)
424 __field(unsigned long, dirtied_when)
425 __field(unsigned long, writeback_index)
426 __field(long, nr_to_write)
427 __field(unsigned long, wrote)
430 TP_fast_assign(
431 strncpy(__entry->name,
432 dev_name(inode_to_bdi(inode)->dev), 32);
433 __entry->ino = inode->i_ino;
434 __entry->state = inode->i_state;
435 __entry->dirtied_when = inode->dirtied_when;
436 __entry->writeback_index = inode->i_mapping->writeback_index;
437 __entry->nr_to_write = nr_to_write;
438 __entry->wrote = nr_to_write - wbc->nr_to_write;
441 TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu "
442 "index=%lu to_write=%ld wrote=%lu",
443 __entry->name,
444 __entry->ino,
445 show_inode_state(__entry->state),
446 __entry->dirtied_when,
447 (jiffies - __entry->dirtied_when) / HZ,
448 __entry->writeback_index,
449 __entry->nr_to_write,
450 __entry->wrote
454 DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode_requeue,
455 TP_PROTO(struct inode *inode,
456 struct writeback_control *wbc,
457 unsigned long nr_to_write),
458 TP_ARGS(inode, wbc, nr_to_write)
461 DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode,
462 TP_PROTO(struct inode *inode,
463 struct writeback_control *wbc,
464 unsigned long nr_to_write),
465 TP_ARGS(inode, wbc, nr_to_write)
468 #endif /* _TRACE_WRITEBACK_H */
470 /* This part must be outside protection */
471 #include <trace/define_trace.h>