3e7662a0cfa38a4d3206949da8fbb507d3cad3fa
[platform/adaptation/renesas_rcar/renesas_kernel.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/device.h>
9 #include <linux/writeback.h>
10
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"}         \
22         )
23
24 struct wb_writeback_work;
25
26 DECLARE_EVENT_CLASS(writeback_work_class,
27         TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work),
28         TP_ARGS(bdi, work),
29         TP_STRUCT__entry(
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)
37         ),
38         TP_fast_assign(
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;
46         ),
47         TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
48                   "kupdate=%d range_cyclic=%d background=%d",
49                   __entry->name,
50                   MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev),
51                   __entry->nr_pages,
52                   __entry->sync_mode,
53                   __entry->for_kupdate,
54                   __entry->range_cyclic,
55                   __entry->for_background
56         )
57 );
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), \
61         TP_ARGS(bdi, 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);
68
69 TRACE_EVENT(writeback_pages_written,
70         TP_PROTO(long pages_written),
71         TP_ARGS(pages_written),
72         TP_STRUCT__entry(
73                 __field(long,           pages)
74         ),
75         TP_fast_assign(
76                 __entry->pages          = pages_written;
77         ),
78         TP_printk("%ld", __entry->pages)
79 );
80
81 DECLARE_EVENT_CLASS(writeback_class,
82         TP_PROTO(struct backing_dev_info *bdi),
83         TP_ARGS(bdi),
84         TP_STRUCT__entry(
85                 __array(char, name, 32)
86         ),
87         TP_fast_assign(
88                 strncpy(__entry->name, dev_name(bdi->dev), 32);
89         ),
90         TP_printk("bdi %s",
91                   __entry->name
92         )
93 );
94 #define DEFINE_WRITEBACK_EVENT(name) \
95 DEFINE_EVENT(writeback_class, name, \
96         TP_PROTO(struct backing_dev_info *bdi), \
97         TP_ARGS(bdi))
98
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);
109
110 TRACE_EVENT(balance_dirty_written,
111
112         TP_PROTO(struct backing_dev_info *bdi, int written),
113
114         TP_ARGS(bdi, written),
115
116         TP_STRUCT__entry(
117                 __array(char,   name, 32)
118                 __field(int,    written)
119         ),
120
121         TP_fast_assign(
122                 strncpy(__entry->name, dev_name(bdi->dev), 32);
123                 __entry->written = written;
124         ),
125
126         TP_printk("bdi %s written %d",
127                   __entry->name,
128                   __entry->written
129         )
130 );
131
132 DECLARE_EVENT_CLASS(wbc_class,
133         TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
134         TP_ARGS(wbc, bdi),
135         TP_STRUCT__entry(
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)
146         ),
147
148         TP_fast_assign(
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;
159         ),
160
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",
164                 __entry->name,
165                 __entry->nr_to_write,
166                 __entry->pages_skipped,
167                 __entry->sync_mode,
168                 __entry->for_kupdate,
169                 __entry->for_background,
170                 __entry->for_reclaim,
171                 __entry->range_cyclic,
172                 __entry->range_start,
173                 __entry->range_end)
174 )
175
176 #define DEFINE_WBC_EVENT(name) \
177 DEFINE_EVENT(wbc_class, name, \
178         TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
179         TP_ARGS(wbc, bdi))
180 DEFINE_WBC_EVENT(wbc_writepage);
181
182 TRACE_EVENT(writeback_queue_io,
183         TP_PROTO(struct bdi_writeback *wb,
184                  unsigned long *older_than_this,
185                  int moved),
186         TP_ARGS(wb, older_than_this, moved),
187         TP_STRUCT__entry(
188                 __array(char,           name, 32)
189                 __field(unsigned long,  older)
190                 __field(long,           age)
191                 __field(int,            moved)
192         ),
193         TP_fast_assign(
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;
199         ),
200         TP_printk("bdi %s: older=%lu age=%ld enqueue=%d",
201                 __entry->name,
202                 __entry->older, /* older_than_this in jiffies */
203                 __entry->age,   /* older_than_this in relative milliseconds */
204                 __entry->moved)
205 );
206
207 DECLARE_EVENT_CLASS(writeback_congest_waited_template,
208
209         TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
210
211         TP_ARGS(usec_timeout, usec_delayed),
212
213         TP_STRUCT__entry(
214                 __field(        unsigned int,   usec_timeout    )
215                 __field(        unsigned int,   usec_delayed    )
216         ),
217
218         TP_fast_assign(
219                 __entry->usec_timeout   = usec_timeout;
220                 __entry->usec_delayed   = usec_delayed;
221         ),
222
223         TP_printk("usec_timeout=%u usec_delayed=%u",
224                         __entry->usec_timeout,
225                         __entry->usec_delayed)
226 );
227
228 DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait,
229
230         TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
231
232         TP_ARGS(usec_timeout, usec_delayed)
233 );
234
235 DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested,
236
237         TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
238
239         TP_ARGS(usec_timeout, usec_delayed)
240 );
241
242 DECLARE_EVENT_CLASS(writeback_single_inode_template,
243
244         TP_PROTO(struct inode *inode,
245                  struct writeback_control *wbc,
246                  unsigned long nr_to_write
247         ),
248
249         TP_ARGS(inode, wbc, nr_to_write),
250
251         TP_STRUCT__entry(
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)
259         ),
260
261         TP_fast_assign(
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) *
267                                                                 1000 / HZ;
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;
271         ),
272
273         TP_printk("bdi %s: ino=%lu state=%s age=%lu "
274                   "index=%lu to_write=%ld wrote=%lu",
275                   __entry->name,
276                   __entry->ino,
277                   show_inode_state(__entry->state),
278                   __entry->age,
279                   __entry->writeback_index,
280                   __entry->nr_to_write,
281                   __entry->wrote
282         )
283 );
284
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)
290 );
291
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)
297 );
298
299 #endif /* _TRACE_WRITEBACK_H */
300
301 /* This part must be outside protection */
302 #include <trace/define_trace.h>