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 TRACE_EVENT(global_dirty_state
,
209 TP_PROTO(unsigned long background_thresh
,
210 unsigned long dirty_thresh
213 TP_ARGS(background_thresh
,
218 __field(unsigned long, nr_dirty
)
219 __field(unsigned long, nr_writeback
)
220 __field(unsigned long, nr_unstable
)
221 __field(unsigned long, background_thresh
)
222 __field(unsigned long, dirty_thresh
)
223 __field(unsigned long, dirty_limit
)
224 __field(unsigned long, nr_dirtied
)
225 __field(unsigned long, nr_written
)
229 __entry
->nr_dirty
= global_page_state(NR_FILE_DIRTY
);
230 __entry
->nr_writeback
= global_page_state(NR_WRITEBACK
);
231 __entry
->nr_unstable
= global_page_state(NR_UNSTABLE_NFS
);
232 __entry
->nr_dirtied
= global_page_state(NR_DIRTIED
);
233 __entry
->nr_written
= global_page_state(NR_WRITTEN
);
234 __entry
->background_thresh
= background_thresh
;
235 __entry
->dirty_thresh
= dirty_thresh
;
236 __entry
->dirty_limit
= global_dirty_limit
;
239 TP_printk("dirty=%lu writeback=%lu unstable=%lu "
240 "bg_thresh=%lu thresh=%lu limit=%lu "
241 "dirtied=%lu written=%lu",
243 __entry
->nr_writeback
,
244 __entry
->nr_unstable
,
245 __entry
->background_thresh
,
246 __entry
->dirty_thresh
,
247 __entry
->dirty_limit
,
253 DECLARE_EVENT_CLASS(writeback_congest_waited_template
,
255 TP_PROTO(unsigned int usec_timeout
, unsigned int usec_delayed
),
257 TP_ARGS(usec_timeout
, usec_delayed
),
260 __field( unsigned int, usec_timeout
)
261 __field( unsigned int, usec_delayed
)
265 __entry
->usec_timeout
= usec_timeout
;
266 __entry
->usec_delayed
= usec_delayed
;
269 TP_printk("usec_timeout=%u usec_delayed=%u",
270 __entry
->usec_timeout
,
271 __entry
->usec_delayed
)
274 DEFINE_EVENT(writeback_congest_waited_template
, writeback_congestion_wait
,
276 TP_PROTO(unsigned int usec_timeout
, unsigned int usec_delayed
),
278 TP_ARGS(usec_timeout
, usec_delayed
)
281 DEFINE_EVENT(writeback_congest_waited_template
, writeback_wait_iff_congested
,
283 TP_PROTO(unsigned int usec_timeout
, unsigned int usec_delayed
),
285 TP_ARGS(usec_timeout
, usec_delayed
)
288 DECLARE_EVENT_CLASS(writeback_single_inode_template
,
290 TP_PROTO(struct inode
*inode
,
291 struct writeback_control
*wbc
,
292 unsigned long nr_to_write
295 TP_ARGS(inode
, wbc
, nr_to_write
),
298 __array(char, name
, 32)
299 __field(unsigned long, ino
)
300 __field(unsigned long, state
)
301 __field(unsigned long, dirtied_when
)
302 __field(unsigned long, writeback_index
)
303 __field(long, nr_to_write
)
304 __field(unsigned long, wrote
)
308 strncpy(__entry
->name
,
309 dev_name(inode
->i_mapping
->backing_dev_info
->dev
), 32);
310 __entry
->ino
= inode
->i_ino
;
311 __entry
->state
= inode
->i_state
;
312 __entry
->dirtied_when
= inode
->dirtied_when
;
313 __entry
->writeback_index
= inode
->i_mapping
->writeback_index
;
314 __entry
->nr_to_write
= nr_to_write
;
315 __entry
->wrote
= nr_to_write
- wbc
->nr_to_write
;
318 TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu "
319 "index=%lu to_write=%ld wrote=%lu",
322 show_inode_state(__entry
->state
),
323 __entry
->dirtied_when
,
324 (jiffies
- __entry
->dirtied_when
) / HZ
,
325 __entry
->writeback_index
,
326 __entry
->nr_to_write
,
331 DEFINE_EVENT(writeback_single_inode_template
, writeback_single_inode_requeue
,
332 TP_PROTO(struct inode
*inode
,
333 struct writeback_control
*wbc
,
334 unsigned long nr_to_write
),
335 TP_ARGS(inode
, wbc
, nr_to_write
)
338 DEFINE_EVENT(writeback_single_inode_template
, writeback_single_inode
,
339 TP_PROTO(struct inode
*inode
,
340 struct writeback_control
*wbc
,
341 unsigned long nr_to_write
),
342 TP_ARGS(inode
, wbc
, nr_to_write
)
345 #endif /* _TRACE_WRITEBACK_H */
347 /* This part must be outside protection */
348 #include <trace/define_trace.h>