writeback: Add tracing to write_cache_pages
[linux-2.6.git] / include / trace / events / writeback.h
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 struct wb_writeback_work;
11
12 DECLARE_EVENT_CLASS(writeback_work_class,
13         TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work),
14         TP_ARGS(bdi, work),
15         TP_STRUCT__entry(
16                 __array(char, name, 32)
17                 __field(long, nr_pages)
18                 __field(dev_t, sb_dev)
19                 __field(int, sync_mode)
20                 __field(int, for_kupdate)
21                 __field(int, range_cyclic)
22                 __field(int, for_background)
23         ),
24         TP_fast_assign(
25                 strncpy(__entry->name, dev_name(bdi->dev), 32);
26                 __entry->nr_pages = work->nr_pages;
27                 __entry->sb_dev = work->sb ? work->sb->s_dev : 0;
28                 __entry->sync_mode = work->sync_mode;
29                 __entry->for_kupdate = work->for_kupdate;
30                 __entry->range_cyclic = work->range_cyclic;
31                 __entry->for_background = work->for_background;
32         ),
33         TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
34                   "kupdate=%d range_cyclic=%d background=%d",
35                   __entry->name,
36                   MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev),
37                   __entry->nr_pages,
38                   __entry->sync_mode,
39                   __entry->for_kupdate,
40                   __entry->range_cyclic,
41                   __entry->for_background
42         )
43 );
44 #define DEFINE_WRITEBACK_WORK_EVENT(name) \
45 DEFINE_EVENT(writeback_work_class, name, \
46         TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \
47         TP_ARGS(bdi, work))
48 DEFINE_WRITEBACK_WORK_EVENT(writeback_nothread);
49 DEFINE_WRITEBACK_WORK_EVENT(writeback_queue);
50 DEFINE_WRITEBACK_WORK_EVENT(writeback_exec);
51
52 TRACE_EVENT(writeback_pages_written,
53         TP_PROTO(long pages_written),
54         TP_ARGS(pages_written),
55         TP_STRUCT__entry(
56                 __field(long,           pages)
57         ),
58         TP_fast_assign(
59                 __entry->pages          = pages_written;
60         ),
61         TP_printk("%ld", __entry->pages)
62 );
63
64 DECLARE_EVENT_CLASS(writeback_class,
65         TP_PROTO(struct backing_dev_info *bdi),
66         TP_ARGS(bdi),
67         TP_STRUCT__entry(
68                 __array(char, name, 32)
69         ),
70         TP_fast_assign(
71                 strncpy(__entry->name, dev_name(bdi->dev), 32);
72         ),
73         TP_printk("bdi %s",
74                   __entry->name
75         )
76 );
77 #define DEFINE_WRITEBACK_EVENT(name) \
78 DEFINE_EVENT(writeback_class, name, \
79         TP_PROTO(struct backing_dev_info *bdi), \
80         TP_ARGS(bdi))
81
82 DEFINE_WRITEBACK_EVENT(writeback_nowork);
83 DEFINE_WRITEBACK_EVENT(writeback_bdi_register);
84 DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister);
85 DEFINE_WRITEBACK_EVENT(writeback_thread_start);
86 DEFINE_WRITEBACK_EVENT(writeback_thread_stop);
87
88 DECLARE_EVENT_CLASS(wbc_class,
89         TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
90         TP_ARGS(wbc, bdi),
91         TP_STRUCT__entry(
92                 __array(char, name, 32)
93                 __field(long, nr_to_write)
94                 __field(long, pages_skipped)
95                 __field(int, sync_mode)
96                 __field(int, nonblocking)
97                 __field(int, encountered_congestion)
98                 __field(int, for_kupdate)
99                 __field(int, for_background)
100                 __field(int, for_reclaim)
101                 __field(int, range_cyclic)
102                 __field(int, more_io)
103                 __field(unsigned long, older_than_this)
104                 __field(long, range_start)
105                 __field(long, range_end)
106         ),
107
108         TP_fast_assign(
109                 strncpy(__entry->name, dev_name(bdi->dev), 32);
110                 __entry->nr_to_write    = wbc->nr_to_write;
111                 __entry->pages_skipped  = wbc->pages_skipped;
112                 __entry->sync_mode      = wbc->sync_mode;
113                 __entry->for_kupdate    = wbc->for_kupdate;
114                 __entry->for_background = wbc->for_background;
115                 __entry->for_reclaim    = wbc->for_reclaim;
116                 __entry->range_cyclic   = wbc->range_cyclic;
117                 __entry->more_io        = wbc->more_io;
118                 __entry->older_than_this = wbc->older_than_this ?
119                                                 *wbc->older_than_this : 0;
120                 __entry->range_start    = (long)wbc->range_start;
121                 __entry->range_end      = (long)wbc->range_end;
122         ),
123
124         TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
125                 "bgrd=%d reclm=%d cyclic=%d more=%d older=0x%lx "
126                 "start=0x%lx end=0x%lx",
127                 __entry->name,
128                 __entry->nr_to_write,
129                 __entry->pages_skipped,
130                 __entry->sync_mode,
131                 __entry->for_kupdate,
132                 __entry->for_background,
133                 __entry->for_reclaim,
134                 __entry->range_cyclic,
135                 __entry->more_io,
136                 __entry->older_than_this,
137                 __entry->range_start,
138                 __entry->range_end)
139 )
140
141 #define DEFINE_WBC_EVENT(name) \
142 DEFINE_EVENT(wbc_class, name, \
143         TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
144         TP_ARGS(wbc, bdi))
145 DEFINE_WBC_EVENT(wbc_writeback_start);
146 DEFINE_WBC_EVENT(wbc_writeback_written);
147 DEFINE_WBC_EVENT(wbc_writeback_wait);
148 DEFINE_WBC_EVENT(wbc_balance_dirty_start);
149 DEFINE_WBC_EVENT(wbc_balance_dirty_written);
150 DEFINE_WBC_EVENT(wbc_balance_dirty_wait);
151 DEFINE_WBC_EVENT(wbc_writepage);
152
153 #endif /* _TRACE_WRITEBACK_H */
154
155 /* This part must be outside protection */
156 #include <trace/define_trace.h>