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"}, \
17 {I_WILL_FREE, "I_WILL_FREE"}, \
18 {I_FREEING, "I_FREEING"}, \
19 {I_CLEAR, "I_CLEAR"}, \
21 {I_REFERENCED, "I_REFERENCED"} \
24 struct wb_writeback_work;
26 DECLARE_EVENT_CLASS(writeback_work_class,
27 TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work),
30 __array(char, name, 32)
31 __field(long, nr_pages)
32 __field(dev_t, sb_dev)
33 __field(int, sync_mode)
34 __field(int, for_kupdate)
35 __field(int, range_cyclic)
36 __field(int, for_background)
39 strncpy(__entry->name, dev_name(bdi->dev), 32);
40 __entry->nr_pages = work->nr_pages;
41 __entry->sb_dev = work->sb ? work->sb->s_dev : 0;
42 __entry->sync_mode = work->sync_mode;
43 __entry->for_kupdate = work->for_kupdate;
44 __entry->range_cyclic = work->range_cyclic;
45 __entry->for_background = work->for_background;
47 TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
48 "kupdate=%d range_cyclic=%d background=%d",
50 MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev),
54 __entry->range_cyclic,
55 __entry->for_background
58 #define DEFINE_WRITEBACK_WORK_EVENT(name) \
59 DEFINE_EVENT(writeback_work_class, name, \
60 TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \
62 DEFINE_WRITEBACK_WORK_EVENT(writeback_nothread);
63 DEFINE_WRITEBACK_WORK_EVENT(writeback_queue);
64 DEFINE_WRITEBACK_WORK_EVENT(writeback_exec);
65 DEFINE_WRITEBACK_WORK_EVENT(writeback_start);
66 DEFINE_WRITEBACK_WORK_EVENT(writeback_written);
67 DEFINE_WRITEBACK_WORK_EVENT(writeback_wait);
69 TRACE_EVENT(writeback_pages_written,
70 TP_PROTO(long pages_written),
71 TP_ARGS(pages_written),
76 __entry->pages = pages_written;
78 TP_printk("%ld", __entry->pages)
81 DECLARE_EVENT_CLASS(writeback_class,
82 TP_PROTO(struct backing_dev_info *bdi),
85 __array(char, name, 32)
88 strncpy(__entry->name, dev_name(bdi->dev), 32);
94 #define DEFINE_WRITEBACK_EVENT(name) \
95 DEFINE_EVENT(writeback_class, name, \
96 TP_PROTO(struct backing_dev_info *bdi), \
99 DEFINE_WRITEBACK_EVENT(writeback_nowork);
100 DEFINE_WRITEBACK_EVENT(writeback_wake_background);
101 DEFINE_WRITEBACK_EVENT(writeback_wake_thread);
102 DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread);
103 DEFINE_WRITEBACK_EVENT(writeback_bdi_register);
104 DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister);
105 DEFINE_WRITEBACK_EVENT(writeback_thread_start);
106 DEFINE_WRITEBACK_EVENT(writeback_thread_stop);
107 DEFINE_WRITEBACK_EVENT(balance_dirty_start);
108 DEFINE_WRITEBACK_EVENT(balance_dirty_wait);
110 TRACE_EVENT(balance_dirty_written,
112 TP_PROTO(struct backing_dev_info *bdi, int written),
114 TP_ARGS(bdi, written),
117 __array(char, name, 32)
118 __field(int, written)
122 strncpy(__entry->name, dev_name(bdi->dev), 32);
123 __entry->written = written;
126 TP_printk("bdi %s written %d",
132 DECLARE_EVENT_CLASS(wbc_class,
133 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
136 __array(char, name, 32)
137 __field(long, nr_to_write)
138 __field(long, pages_skipped)
139 __field(int, sync_mode)
140 __field(int, for_kupdate)
141 __field(int, for_background)
142 __field(int, for_reclaim)
143 __field(int, range_cyclic)
144 __field(long, range_start)
145 __field(long, range_end)
149 strncpy(__entry->name, dev_name(bdi->dev), 32);
150 __entry->nr_to_write = wbc->nr_to_write;
151 __entry->pages_skipped = wbc->pages_skipped;
152 __entry->sync_mode = wbc->sync_mode;
153 __entry->for_kupdate = wbc->for_kupdate;
154 __entry->for_background = wbc->for_background;
155 __entry->for_reclaim = wbc->for_reclaim;
156 __entry->range_cyclic = wbc->range_cyclic;
157 __entry->range_start = (long)wbc->range_start;
158 __entry->range_end = (long)wbc->range_end;
161 TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
162 "bgrd=%d reclm=%d cyclic=%d "
163 "start=0x%lx end=0x%lx",
165 __entry->nr_to_write,
166 __entry->pages_skipped,
168 __entry->for_kupdate,
169 __entry->for_background,
170 __entry->for_reclaim,
171 __entry->range_cyclic,
172 __entry->range_start,
176 #define DEFINE_WBC_EVENT(name) \
177 DEFINE_EVENT(wbc_class, name, \
178 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
180 DEFINE_WBC_EVENT(wbc_writepage);
182 TRACE_EVENT(writeback_queue_io,
183 TP_PROTO(struct bdi_writeback *wb,
184 unsigned long *older_than_this,
186 TP_ARGS(wb, older_than_this, moved),
188 __array(char, name, 32)
189 __field(unsigned long, older)
194 strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
195 __entry->older = older_than_this ? *older_than_this : 0;
196 __entry->age = older_than_this ?
197 (jiffies - *older_than_this) * 1000 / HZ : -1;
198 __entry->moved = moved;
200 TP_printk("bdi %s: older=%lu age=%ld enqueue=%d",
202 __entry->older, /* older_than_this in jiffies */
203 __entry->age, /* older_than_this in relative milliseconds */
207 DECLARE_EVENT_CLASS(writeback_congest_waited_template,
209 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
211 TP_ARGS(usec_timeout, usec_delayed),
214 __field( unsigned int, usec_timeout )
215 __field( unsigned int, usec_delayed )
219 __entry->usec_timeout = usec_timeout;
220 __entry->usec_delayed = usec_delayed;
223 TP_printk("usec_timeout=%u usec_delayed=%u",
224 __entry->usec_timeout,
225 __entry->usec_delayed)
228 DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait,
230 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
232 TP_ARGS(usec_timeout, usec_delayed)
235 DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested,
237 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
239 TP_ARGS(usec_timeout, usec_delayed)
242 DECLARE_EVENT_CLASS(writeback_single_inode_template,
244 TP_PROTO(struct inode *inode,
245 struct writeback_control *wbc,
246 unsigned long nr_to_write
249 TP_ARGS(inode, wbc, nr_to_write),
252 __array(char, name, 32)
253 __field(unsigned long, ino)
254 __field(unsigned long, state)
255 __field(unsigned long, age)
256 __field(unsigned long, writeback_index)
257 __field(long, nr_to_write)
258 __field(unsigned long, wrote)
262 strncpy(__entry->name,
263 dev_name(inode->i_mapping->backing_dev_info->dev), 32);
264 __entry->ino = inode->i_ino;
265 __entry->state = inode->i_state;
266 __entry->age = (jiffies - inode->dirtied_when) *
268 __entry->writeback_index = inode->i_mapping->writeback_index;
269 __entry->nr_to_write = nr_to_write;
270 __entry->wrote = nr_to_write - wbc->nr_to_write;
273 TP_printk("bdi %s: ino=%lu state=%s age=%lu "
274 "index=%lu to_write=%ld wrote=%lu",
277 show_inode_state(__entry->state),
279 __entry->writeback_index,
280 __entry->nr_to_write,
285 DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode_requeue,
286 TP_PROTO(struct inode *inode,
287 struct writeback_control *wbc,
288 unsigned long nr_to_write),
289 TP_ARGS(inode, wbc, nr_to_write)
292 DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode,
293 TP_PROTO(struct inode *inode,
294 struct writeback_control *wbc,
295 unsigned long nr_to_write),
296 TP_ARGS(inode, wbc, nr_to_write)
299 #endif /* _TRACE_WRITEBACK_H */
301 /* This part must be outside protection */
302 #include <trace/define_trace.h>