SHM_UNLOCK: fix long unpreemptible section
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / trace / events / writeback.h
blob99d1d0decf88e41a7c0c038d463330e8351046b1
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 strncpy(__entry->name, dev_name(bdi->dev), 32);
51 __entry->nr_pages = work->nr_pages;
52 __entry->sb_dev = work->sb ? work->sb->s_dev : 0;
53 __entry->sync_mode = work->sync_mode;
54 __entry->for_kupdate = work->for_kupdate;
55 __entry->range_cyclic = work->range_cyclic;
56 __entry->for_background = work->for_background;
57 __entry->reason = work->reason;
59 TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
60 "kupdate=%d range_cyclic=%d background=%d reason=%s",
61 __entry->name,
62 MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev),
63 __entry->nr_pages,
64 __entry->sync_mode,
65 __entry->for_kupdate,
66 __entry->range_cyclic,
67 __entry->for_background,
68 __print_symbolic(__entry->reason, WB_WORK_REASON)
71 #define DEFINE_WRITEBACK_WORK_EVENT(name) \
72 DEFINE_EVENT(writeback_work_class, name, \
73 TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \
74 TP_ARGS(bdi, work))
75 DEFINE_WRITEBACK_WORK_EVENT(writeback_nothread);
76 DEFINE_WRITEBACK_WORK_EVENT(writeback_queue);
77 DEFINE_WRITEBACK_WORK_EVENT(writeback_exec);
78 DEFINE_WRITEBACK_WORK_EVENT(writeback_start);
79 DEFINE_WRITEBACK_WORK_EVENT(writeback_written);
80 DEFINE_WRITEBACK_WORK_EVENT(writeback_wait);
82 TRACE_EVENT(writeback_pages_written,
83 TP_PROTO(long pages_written),
84 TP_ARGS(pages_written),
85 TP_STRUCT__entry(
86 __field(long, pages)
88 TP_fast_assign(
89 __entry->pages = pages_written;
91 TP_printk("%ld", __entry->pages)
94 DECLARE_EVENT_CLASS(writeback_class,
95 TP_PROTO(struct backing_dev_info *bdi),
96 TP_ARGS(bdi),
97 TP_STRUCT__entry(
98 __array(char, name, 32)
100 TP_fast_assign(
101 strncpy(__entry->name, dev_name(bdi->dev), 32);
103 TP_printk("bdi %s",
104 __entry->name
107 #define DEFINE_WRITEBACK_EVENT(name) \
108 DEFINE_EVENT(writeback_class, name, \
109 TP_PROTO(struct backing_dev_info *bdi), \
110 TP_ARGS(bdi))
112 DEFINE_WRITEBACK_EVENT(writeback_nowork);
113 DEFINE_WRITEBACK_EVENT(writeback_wake_background);
114 DEFINE_WRITEBACK_EVENT(writeback_wake_thread);
115 DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread);
116 DEFINE_WRITEBACK_EVENT(writeback_bdi_register);
117 DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister);
118 DEFINE_WRITEBACK_EVENT(writeback_thread_start);
119 DEFINE_WRITEBACK_EVENT(writeback_thread_stop);
121 DECLARE_EVENT_CLASS(wbc_class,
122 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
123 TP_ARGS(wbc, bdi),
124 TP_STRUCT__entry(
125 __array(char, name, 32)
126 __field(long, nr_to_write)
127 __field(long, pages_skipped)
128 __field(int, sync_mode)
129 __field(int, for_kupdate)
130 __field(int, for_background)
131 __field(int, for_reclaim)
132 __field(int, range_cyclic)
133 __field(long, range_start)
134 __field(long, range_end)
137 TP_fast_assign(
138 strncpy(__entry->name, dev_name(bdi->dev), 32);
139 __entry->nr_to_write = wbc->nr_to_write;
140 __entry->pages_skipped = wbc->pages_skipped;
141 __entry->sync_mode = wbc->sync_mode;
142 __entry->for_kupdate = wbc->for_kupdate;
143 __entry->for_background = wbc->for_background;
144 __entry->for_reclaim = wbc->for_reclaim;
145 __entry->range_cyclic = wbc->range_cyclic;
146 __entry->range_start = (long)wbc->range_start;
147 __entry->range_end = (long)wbc->range_end;
150 TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
151 "bgrd=%d reclm=%d cyclic=%d "
152 "start=0x%lx end=0x%lx",
153 __entry->name,
154 __entry->nr_to_write,
155 __entry->pages_skipped,
156 __entry->sync_mode,
157 __entry->for_kupdate,
158 __entry->for_background,
159 __entry->for_reclaim,
160 __entry->range_cyclic,
161 __entry->range_start,
162 __entry->range_end)
165 #define DEFINE_WBC_EVENT(name) \
166 DEFINE_EVENT(wbc_class, name, \
167 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
168 TP_ARGS(wbc, bdi))
169 DEFINE_WBC_EVENT(wbc_writepage);
171 TRACE_EVENT(writeback_queue_io,
172 TP_PROTO(struct bdi_writeback *wb,
173 struct wb_writeback_work *work,
174 int moved),
175 TP_ARGS(wb, work, moved),
176 TP_STRUCT__entry(
177 __array(char, name, 32)
178 __field(unsigned long, older)
179 __field(long, age)
180 __field(int, moved)
181 __field(int, reason)
183 TP_fast_assign(
184 unsigned long *older_than_this = work->older_than_this;
185 strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
186 __entry->older = older_than_this ? *older_than_this : 0;
187 __entry->age = older_than_this ?
188 (jiffies - *older_than_this) * 1000 / HZ : -1;
189 __entry->moved = moved;
190 __entry->reason = work->reason;
192 TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s",
193 __entry->name,
194 __entry->older, /* older_than_this in jiffies */
195 __entry->age, /* older_than_this in relative milliseconds */
196 __entry->moved,
197 __print_symbolic(__entry->reason, WB_WORK_REASON)
201 TRACE_EVENT(global_dirty_state,
203 TP_PROTO(unsigned long background_thresh,
204 unsigned long dirty_thresh
207 TP_ARGS(background_thresh,
208 dirty_thresh
211 TP_STRUCT__entry(
212 __field(unsigned long, nr_dirty)
213 __field(unsigned long, nr_writeback)
214 __field(unsigned long, nr_unstable)
215 __field(unsigned long, background_thresh)
216 __field(unsigned long, dirty_thresh)
217 __field(unsigned long, dirty_limit)
218 __field(unsigned long, nr_dirtied)
219 __field(unsigned long, nr_written)
222 TP_fast_assign(
223 __entry->nr_dirty = global_page_state(NR_FILE_DIRTY);
224 __entry->nr_writeback = global_page_state(NR_WRITEBACK);
225 __entry->nr_unstable = global_page_state(NR_UNSTABLE_NFS);
226 __entry->nr_dirtied = global_page_state(NR_DIRTIED);
227 __entry->nr_written = global_page_state(NR_WRITTEN);
228 __entry->background_thresh = background_thresh;
229 __entry->dirty_thresh = dirty_thresh;
230 __entry->dirty_limit = global_dirty_limit;
233 TP_printk("dirty=%lu writeback=%lu unstable=%lu "
234 "bg_thresh=%lu thresh=%lu limit=%lu "
235 "dirtied=%lu written=%lu",
236 __entry->nr_dirty,
237 __entry->nr_writeback,
238 __entry->nr_unstable,
239 __entry->background_thresh,
240 __entry->dirty_thresh,
241 __entry->dirty_limit,
242 __entry->nr_dirtied,
243 __entry->nr_written
247 #define KBps(x) ((x) << (PAGE_SHIFT - 10))
249 TRACE_EVENT(bdi_dirty_ratelimit,
251 TP_PROTO(struct backing_dev_info *bdi,
252 unsigned long dirty_rate,
253 unsigned long task_ratelimit),
255 TP_ARGS(bdi, dirty_rate, task_ratelimit),
257 TP_STRUCT__entry(
258 __array(char, bdi, 32)
259 __field(unsigned long, write_bw)
260 __field(unsigned long, avg_write_bw)
261 __field(unsigned long, dirty_rate)
262 __field(unsigned long, dirty_ratelimit)
263 __field(unsigned long, task_ratelimit)
264 __field(unsigned long, balanced_dirty_ratelimit)
267 TP_fast_assign(
268 strlcpy(__entry->bdi, dev_name(bdi->dev), 32);
269 __entry->write_bw = KBps(bdi->write_bandwidth);
270 __entry->avg_write_bw = KBps(bdi->avg_write_bandwidth);
271 __entry->dirty_rate = KBps(dirty_rate);
272 __entry->dirty_ratelimit = KBps(bdi->dirty_ratelimit);
273 __entry->task_ratelimit = KBps(task_ratelimit);
274 __entry->balanced_dirty_ratelimit =
275 KBps(bdi->balanced_dirty_ratelimit);
278 TP_printk("bdi %s: "
279 "write_bw=%lu awrite_bw=%lu dirty_rate=%lu "
280 "dirty_ratelimit=%lu task_ratelimit=%lu "
281 "balanced_dirty_ratelimit=%lu",
282 __entry->bdi,
283 __entry->write_bw, /* write bandwidth */
284 __entry->avg_write_bw, /* avg write bandwidth */
285 __entry->dirty_rate, /* bdi dirty rate */
286 __entry->dirty_ratelimit, /* base ratelimit */
287 __entry->task_ratelimit, /* ratelimit with position control */
288 __entry->balanced_dirty_ratelimit /* the balanced ratelimit */
292 TRACE_EVENT(balance_dirty_pages,
294 TP_PROTO(struct backing_dev_info *bdi,
295 unsigned long thresh,
296 unsigned long bg_thresh,
297 unsigned long dirty,
298 unsigned long bdi_thresh,
299 unsigned long bdi_dirty,
300 unsigned long dirty_ratelimit,
301 unsigned long task_ratelimit,
302 unsigned long dirtied,
303 long pause,
304 unsigned long start_time),
306 TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
307 dirty_ratelimit, task_ratelimit,
308 dirtied, pause, start_time),
310 TP_STRUCT__entry(
311 __array( char, bdi, 32)
312 __field(unsigned long, limit)
313 __field(unsigned long, setpoint)
314 __field(unsigned long, dirty)
315 __field(unsigned long, bdi_setpoint)
316 __field(unsigned long, bdi_dirty)
317 __field(unsigned long, dirty_ratelimit)
318 __field(unsigned long, task_ratelimit)
319 __field(unsigned int, dirtied)
320 __field(unsigned int, dirtied_pause)
321 __field(unsigned long, paused)
322 __field( long, pause)
325 TP_fast_assign(
326 unsigned long freerun = (thresh + bg_thresh) / 2;
327 strlcpy(__entry->bdi, dev_name(bdi->dev), 32);
329 __entry->limit = global_dirty_limit;
330 __entry->setpoint = (global_dirty_limit + freerun) / 2;
331 __entry->dirty = dirty;
332 __entry->bdi_setpoint = __entry->setpoint *
333 bdi_thresh / (thresh + 1);
334 __entry->bdi_dirty = bdi_dirty;
335 __entry->dirty_ratelimit = KBps(dirty_ratelimit);
336 __entry->task_ratelimit = KBps(task_ratelimit);
337 __entry->dirtied = dirtied;
338 __entry->dirtied_pause = current->nr_dirtied_pause;
339 __entry->pause = pause * 1000 / HZ;
340 __entry->paused = (jiffies - start_time) * 1000 / HZ;
344 TP_printk("bdi %s: "
345 "limit=%lu setpoint=%lu dirty=%lu "
346 "bdi_setpoint=%lu bdi_dirty=%lu "
347 "dirty_ratelimit=%lu task_ratelimit=%lu "
348 "dirtied=%u dirtied_pause=%u "
349 "paused=%lu pause=%ld",
350 __entry->bdi,
351 __entry->limit,
352 __entry->setpoint,
353 __entry->dirty,
354 __entry->bdi_setpoint,
355 __entry->bdi_dirty,
356 __entry->dirty_ratelimit,
357 __entry->task_ratelimit,
358 __entry->dirtied,
359 __entry->dirtied_pause,
360 __entry->paused, /* ms */
361 __entry->pause /* ms */
365 DECLARE_EVENT_CLASS(writeback_congest_waited_template,
367 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
369 TP_ARGS(usec_timeout, usec_delayed),
371 TP_STRUCT__entry(
372 __field( unsigned int, usec_timeout )
373 __field( unsigned int, usec_delayed )
376 TP_fast_assign(
377 __entry->usec_timeout = usec_timeout;
378 __entry->usec_delayed = usec_delayed;
381 TP_printk("usec_timeout=%u usec_delayed=%u",
382 __entry->usec_timeout,
383 __entry->usec_delayed)
386 DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait,
388 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
390 TP_ARGS(usec_timeout, usec_delayed)
393 DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested,
395 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
397 TP_ARGS(usec_timeout, usec_delayed)
400 DECLARE_EVENT_CLASS(writeback_single_inode_template,
402 TP_PROTO(struct inode *inode,
403 struct writeback_control *wbc,
404 unsigned long nr_to_write
407 TP_ARGS(inode, wbc, nr_to_write),
409 TP_STRUCT__entry(
410 __array(char, name, 32)
411 __field(unsigned long, ino)
412 __field(unsigned long, state)
413 __field(unsigned long, dirtied_when)
414 __field(unsigned long, writeback_index)
415 __field(long, nr_to_write)
416 __field(unsigned long, wrote)
419 TP_fast_assign(
420 strncpy(__entry->name,
421 dev_name(inode->i_mapping->backing_dev_info->dev), 32);
422 __entry->ino = inode->i_ino;
423 __entry->state = inode->i_state;
424 __entry->dirtied_when = inode->dirtied_when;
425 __entry->writeback_index = inode->i_mapping->writeback_index;
426 __entry->nr_to_write = nr_to_write;
427 __entry->wrote = nr_to_write - wbc->nr_to_write;
430 TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu "
431 "index=%lu to_write=%ld wrote=%lu",
432 __entry->name,
433 __entry->ino,
434 show_inode_state(__entry->state),
435 __entry->dirtied_when,
436 (jiffies - __entry->dirtied_when) / HZ,
437 __entry->writeback_index,
438 __entry->nr_to_write,
439 __entry->wrote
443 DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode_requeue,
444 TP_PROTO(struct inode *inode,
445 struct writeback_control *wbc,
446 unsigned long nr_to_write),
447 TP_ARGS(inode, wbc, nr_to_write)
450 DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode,
451 TP_PROTO(struct inode *inode,
452 struct writeback_control *wbc,
453 unsigned long nr_to_write),
454 TP_ARGS(inode, wbc, nr_to_write)
457 #endif /* _TRACE_WRITEBACK_H */
459 /* This part must be outside protection */
460 #include <trace/define_trace.h>