blob: fff846b512e6e675043a37d3d5c7cb804b71cbe8 [file] [log] [blame]
Dave Chinner455b2862010-07-07 13:24:06 +10001#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
Steven Rostedt (Red Hat)f4794472014-02-26 12:52:13 -05007#include <linux/tracepoint.h>
Dave Chinner455b2862010-07-07 13:24:06 +10008#include <linux/backing-dev.h>
9#include <linux/writeback.h>
10
Wu Fengguang251d6a42010-12-01 17:33:37 -060011#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"}, \
Theodore Ts'o0ae45f62015-02-02 00:37:00 -050021 {I_DIRTY_TIME, "I_DIRTY_TIME"}, \
22 {I_DIRTY_TIME_EXPIRED, "I_DIRTY_TIME_EXPIRED"}, \
Wu Fengguang251d6a42010-12-01 17:33:37 -060023 {I_REFERENCED, "I_REFERENCED"} \
24 )
25
Steven Rostedt (Red Hat)91df6082015-03-27 17:08:41 -040026/* enums need to be exported to user space */
27#undef EM
28#undef EMe
29#define EM(a,b) TRACE_DEFINE_ENUM(a);
30#define EMe(a,b) TRACE_DEFINE_ENUM(a);
31
Wu Fengguangb3bba8722011-12-08 16:53:54 -060032#define WB_WORK_REASON \
Steven Rostedt (Red Hat)91df6082015-03-27 17:08:41 -040033 EM( WB_REASON_BACKGROUND, "background") \
34 EM( WB_REASON_TRY_TO_FREE_PAGES, "try_to_free_pages") \
35 EM( WB_REASON_SYNC, "sync") \
36 EM( WB_REASON_PERIODIC, "periodic") \
37 EM( WB_REASON_LAPTOP_TIMER, "laptop_timer") \
38 EM( WB_REASON_FREE_MORE_MEM, "free_more_memory") \
39 EM( WB_REASON_FS_FREE_SPACE, "fs_free_space") \
40 EMe(WB_REASON_FORKER_THREAD, "forker_thread")
41
42WB_WORK_REASON
43
44/*
45 * Now redefine the EM() and EMe() macros to map the enums to the strings
46 * that will be printed in the output.
47 */
48#undef EM
49#undef EMe
50#define EM(a,b) { a, b },
51#define EMe(a,b) { a, b }
Wu Fengguangb3bba8722011-12-08 16:53:54 -060052
Dave Chinner455b2862010-07-07 13:24:06 +100053struct wb_writeback_work;
54
Tejun Heo9fb0a7d2013-01-11 13:06:37 -080055TRACE_EVENT(writeback_dirty_page,
56
57 TP_PROTO(struct page *page, struct address_space *mapping),
58
59 TP_ARGS(page, mapping),
60
61 TP_STRUCT__entry (
62 __array(char, name, 32)
63 __field(unsigned long, ino)
64 __field(pgoff_t, index)
65 ),
66
67 TP_fast_assign(
68 strncpy(__entry->name,
Christoph Hellwigde1414a2015-01-14 10:42:36 +010069 mapping ? dev_name(inode_to_bdi(mapping->host)->dev) : "(unknown)", 32);
Tejun Heo9fb0a7d2013-01-11 13:06:37 -080070 __entry->ino = mapping ? mapping->host->i_ino : 0;
71 __entry->index = page->index;
72 ),
73
74 TP_printk("bdi %s: ino=%lu index=%lu",
75 __entry->name,
76 __entry->ino,
77 __entry->index
78 )
79);
80
81DECLARE_EVENT_CLASS(writeback_dirty_inode_template,
82
83 TP_PROTO(struct inode *inode, int flags),
84
85 TP_ARGS(inode, flags),
86
87 TP_STRUCT__entry (
88 __array(char, name, 32)
89 __field(unsigned long, ino)
Theodore Ts'o0ae45f62015-02-02 00:37:00 -050090 __field(unsigned long, state)
Tejun Heo9fb0a7d2013-01-11 13:06:37 -080091 __field(unsigned long, flags)
92 ),
93
94 TP_fast_assign(
Christoph Hellwigde1414a2015-01-14 10:42:36 +010095 struct backing_dev_info *bdi = inode_to_bdi(inode);
Tejun Heo9fb0a7d2013-01-11 13:06:37 -080096
97 /* may be called for files on pseudo FSes w/ unregistered bdi */
98 strncpy(__entry->name,
99 bdi->dev ? dev_name(bdi->dev) : "(unknown)", 32);
100 __entry->ino = inode->i_ino;
Theodore Ts'o0ae45f62015-02-02 00:37:00 -0500101 __entry->state = inode->i_state;
Tejun Heo9fb0a7d2013-01-11 13:06:37 -0800102 __entry->flags = flags;
103 ),
104
Theodore Ts'o0ae45f62015-02-02 00:37:00 -0500105 TP_printk("bdi %s: ino=%lu state=%s flags=%s",
Tejun Heo9fb0a7d2013-01-11 13:06:37 -0800106 __entry->name,
107 __entry->ino,
Theodore Ts'o0ae45f62015-02-02 00:37:00 -0500108 show_inode_state(__entry->state),
Tejun Heo9fb0a7d2013-01-11 13:06:37 -0800109 show_inode_state(__entry->flags)
110 )
111);
112
Theodore Ts'o0ae45f62015-02-02 00:37:00 -0500113DEFINE_EVENT(writeback_dirty_inode_template, writeback_mark_inode_dirty,
114
115 TP_PROTO(struct inode *inode, int flags),
116
117 TP_ARGS(inode, flags)
118);
119
Tejun Heo9fb0a7d2013-01-11 13:06:37 -0800120DEFINE_EVENT(writeback_dirty_inode_template, writeback_dirty_inode_start,
121
122 TP_PROTO(struct inode *inode, int flags),
123
124 TP_ARGS(inode, flags)
125);
126
127DEFINE_EVENT(writeback_dirty_inode_template, writeback_dirty_inode,
128
129 TP_PROTO(struct inode *inode, int flags),
130
131 TP_ARGS(inode, flags)
132);
133
Tejun Heo5634cc22015-08-18 14:54:56 -0700134#ifdef CREATE_TRACE_POINTS
135#ifdef CONFIG_CGROUP_WRITEBACK
136
137static inline size_t __trace_wb_cgroup_size(struct bdi_writeback *wb)
138{
139 return kernfs_path_len(wb->memcg_css->cgroup->kn) + 1;
140}
141
142static inline void __trace_wb_assign_cgroup(char *buf, struct bdi_writeback *wb)
143{
144 struct cgroup *cgrp = wb->memcg_css->cgroup;
145 char *path;
146
147 path = cgroup_path(cgrp, buf, kernfs_path_len(cgrp->kn) + 1);
148 WARN_ON_ONCE(path != buf);
149}
150
151static inline size_t __trace_wbc_cgroup_size(struct writeback_control *wbc)
152{
153 if (wbc->wb)
154 return __trace_wb_cgroup_size(wbc->wb);
155 else
156 return 2;
157}
158
159static inline void __trace_wbc_assign_cgroup(char *buf,
160 struct writeback_control *wbc)
161{
162 if (wbc->wb)
163 __trace_wb_assign_cgroup(buf, wbc->wb);
164 else
165 strcpy(buf, "/");
166}
167
168#else /* CONFIG_CGROUP_WRITEBACK */
169
170static inline size_t __trace_wb_cgroup_size(struct bdi_writeback *wb)
171{
172 return 2;
173}
174
175static inline void __trace_wb_assign_cgroup(char *buf, struct bdi_writeback *wb)
176{
177 strcpy(buf, "/");
178}
179
180static inline size_t __trace_wbc_cgroup_size(struct writeback_control *wbc)
181{
182 return 2;
183}
184
185static inline void __trace_wbc_assign_cgroup(char *buf,
186 struct writeback_control *wbc)
187{
188 strcpy(buf, "/");
189}
190
191#endif /* CONFIG_CGROUP_WRITEBACK */
192#endif /* CREATE_TRACE_POINTS */
193
Tejun Heo9fb0a7d2013-01-11 13:06:37 -0800194DECLARE_EVENT_CLASS(writeback_write_inode_template,
195
196 TP_PROTO(struct inode *inode, struct writeback_control *wbc),
197
198 TP_ARGS(inode, wbc),
199
200 TP_STRUCT__entry (
201 __array(char, name, 32)
202 __field(unsigned long, ino)
203 __field(int, sync_mode)
Tejun Heo5634cc22015-08-18 14:54:56 -0700204 __dynamic_array(char, cgroup, __trace_wbc_cgroup_size(wbc))
Tejun Heo9fb0a7d2013-01-11 13:06:37 -0800205 ),
206
207 TP_fast_assign(
208 strncpy(__entry->name,
Christoph Hellwigde1414a2015-01-14 10:42:36 +0100209 dev_name(inode_to_bdi(inode)->dev), 32);
Tejun Heo9fb0a7d2013-01-11 13:06:37 -0800210 __entry->ino = inode->i_ino;
211 __entry->sync_mode = wbc->sync_mode;
Tejun Heo5634cc22015-08-18 14:54:56 -0700212 __trace_wbc_assign_cgroup(__get_str(cgroup), wbc);
Tejun Heo9fb0a7d2013-01-11 13:06:37 -0800213 ),
214
Tejun Heo5634cc22015-08-18 14:54:56 -0700215 TP_printk("bdi %s: ino=%lu sync_mode=%d cgroup=%s",
Tejun Heo9fb0a7d2013-01-11 13:06:37 -0800216 __entry->name,
217 __entry->ino,
Tejun Heo5634cc22015-08-18 14:54:56 -0700218 __entry->sync_mode,
219 __get_str(cgroup)
Tejun Heo9fb0a7d2013-01-11 13:06:37 -0800220 )
221);
222
223DEFINE_EVENT(writeback_write_inode_template, writeback_write_inode_start,
224
225 TP_PROTO(struct inode *inode, struct writeback_control *wbc),
226
227 TP_ARGS(inode, wbc)
228);
229
230DEFINE_EVENT(writeback_write_inode_template, writeback_write_inode,
231
232 TP_PROTO(struct inode *inode, struct writeback_control *wbc),
233
234 TP_ARGS(inode, wbc)
235);
236
Dave Chinner455b2862010-07-07 13:24:06 +1000237DECLARE_EVENT_CLASS(writeback_work_class,
Tejun Heo5634cc22015-08-18 14:54:56 -0700238 TP_PROTO(struct bdi_writeback *wb, struct wb_writeback_work *work),
239 TP_ARGS(wb, work),
Dave Chinner455b2862010-07-07 13:24:06 +1000240 TP_STRUCT__entry(
241 __array(char, name, 32)
242 __field(long, nr_pages)
243 __field(dev_t, sb_dev)
244 __field(int, sync_mode)
245 __field(int, for_kupdate)
246 __field(int, range_cyclic)
247 __field(int, for_background)
Curt Wohlgemuth0e175a12011-10-07 21:54:10 -0600248 __field(int, reason)
Tejun Heo5634cc22015-08-18 14:54:56 -0700249 __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb))
Dave Chinner455b2862010-07-07 13:24:06 +1000250 ),
251 TP_fast_assign(
Christoph Hellwigdf0ce262015-01-14 10:42:41 +0100252 strncpy(__entry->name,
Tejun Heo5634cc22015-08-18 14:54:56 -0700253 wb->bdi->dev ? dev_name(wb->bdi->dev) : "(unknown)", 32);
Dave Chinner455b2862010-07-07 13:24:06 +1000254 __entry->nr_pages = work->nr_pages;
255 __entry->sb_dev = work->sb ? work->sb->s_dev : 0;
256 __entry->sync_mode = work->sync_mode;
257 __entry->for_kupdate = work->for_kupdate;
258 __entry->range_cyclic = work->range_cyclic;
259 __entry->for_background = work->for_background;
Curt Wohlgemuth0e175a12011-10-07 21:54:10 -0600260 __entry->reason = work->reason;
Tejun Heo5634cc22015-08-18 14:54:56 -0700261 __trace_wb_assign_cgroup(__get_str(cgroup), wb);
Dave Chinner455b2862010-07-07 13:24:06 +1000262 ),
263 TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
Tejun Heo5634cc22015-08-18 14:54:56 -0700264 "kupdate=%d range_cyclic=%d background=%d reason=%s cgroup=%s",
Dave Chinner455b2862010-07-07 13:24:06 +1000265 __entry->name,
266 MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev),
267 __entry->nr_pages,
268 __entry->sync_mode,
269 __entry->for_kupdate,
270 __entry->range_cyclic,
Curt Wohlgemuth0e175a12011-10-07 21:54:10 -0600271 __entry->for_background,
Tejun Heo5634cc22015-08-18 14:54:56 -0700272 __print_symbolic(__entry->reason, WB_WORK_REASON),
273 __get_str(cgroup)
Dave Chinner455b2862010-07-07 13:24:06 +1000274 )
275);
276#define DEFINE_WRITEBACK_WORK_EVENT(name) \
277DEFINE_EVENT(writeback_work_class, name, \
Tejun Heo5634cc22015-08-18 14:54:56 -0700278 TP_PROTO(struct bdi_writeback *wb, struct wb_writeback_work *work), \
279 TP_ARGS(wb, work))
Dave Chinner455b2862010-07-07 13:24:06 +1000280DEFINE_WRITEBACK_WORK_EVENT(writeback_queue);
281DEFINE_WRITEBACK_WORK_EVENT(writeback_exec);
Wu Fengguangd46db3d2011-05-04 19:54:37 -0600282DEFINE_WRITEBACK_WORK_EVENT(writeback_start);
283DEFINE_WRITEBACK_WORK_EVENT(writeback_written);
284DEFINE_WRITEBACK_WORK_EVENT(writeback_wait);
Dave Chinner455b2862010-07-07 13:24:06 +1000285
286TRACE_EVENT(writeback_pages_written,
287 TP_PROTO(long pages_written),
288 TP_ARGS(pages_written),
289 TP_STRUCT__entry(
290 __field(long, pages)
291 ),
292 TP_fast_assign(
293 __entry->pages = pages_written;
294 ),
295 TP_printk("%ld", __entry->pages)
296);
297
298DECLARE_EVENT_CLASS(writeback_class,
Tejun Heo5634cc22015-08-18 14:54:56 -0700299 TP_PROTO(struct bdi_writeback *wb),
300 TP_ARGS(wb),
301 TP_STRUCT__entry(
302 __array(char, name, 32)
303 __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb))
304 ),
305 TP_fast_assign(
306 strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
307 __trace_wb_assign_cgroup(__get_str(cgroup), wb);
308 ),
309 TP_printk("bdi %s: cgroup=%s",
310 __entry->name,
311 __get_str(cgroup)
312 )
313);
314#define DEFINE_WRITEBACK_EVENT(name) \
315DEFINE_EVENT(writeback_class, name, \
316 TP_PROTO(struct bdi_writeback *wb), \
317 TP_ARGS(wb))
318
319DEFINE_WRITEBACK_EVENT(writeback_nowork);
320DEFINE_WRITEBACK_EVENT(writeback_wake_background);
321
322TRACE_EVENT(writeback_bdi_register,
Dave Chinner455b2862010-07-07 13:24:06 +1000323 TP_PROTO(struct backing_dev_info *bdi),
324 TP_ARGS(bdi),
325 TP_STRUCT__entry(
326 __array(char, name, 32)
327 ),
328 TP_fast_assign(
329 strncpy(__entry->name, dev_name(bdi->dev), 32);
330 ),
331 TP_printk("bdi %s",
Tejun Heo5634cc22015-08-18 14:54:56 -0700332 __entry->name
Dave Chinner455b2862010-07-07 13:24:06 +1000333 )
334);
Dave Chinner455b2862010-07-07 13:24:06 +1000335
Dave Chinner028c2dd2010-07-07 13:24:07 +1000336DECLARE_EVENT_CLASS(wbc_class,
337 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
338 TP_ARGS(wbc, bdi),
339 TP_STRUCT__entry(
340 __array(char, name, 32)
341 __field(long, nr_to_write)
342 __field(long, pages_skipped)
343 __field(int, sync_mode)
Dave Chinner028c2dd2010-07-07 13:24:07 +1000344 __field(int, for_kupdate)
345 __field(int, for_background)
346 __field(int, for_reclaim)
347 __field(int, range_cyclic)
Dave Chinner028c2dd2010-07-07 13:24:07 +1000348 __field(long, range_start)
349 __field(long, range_end)
Tejun Heo5634cc22015-08-18 14:54:56 -0700350 __dynamic_array(char, cgroup, __trace_wbc_cgroup_size(wbc))
Dave Chinner028c2dd2010-07-07 13:24:07 +1000351 ),
352
353 TP_fast_assign(
354 strncpy(__entry->name, dev_name(bdi->dev), 32);
355 __entry->nr_to_write = wbc->nr_to_write;
356 __entry->pages_skipped = wbc->pages_skipped;
357 __entry->sync_mode = wbc->sync_mode;
358 __entry->for_kupdate = wbc->for_kupdate;
359 __entry->for_background = wbc->for_background;
360 __entry->for_reclaim = wbc->for_reclaim;
361 __entry->range_cyclic = wbc->range_cyclic;
Dave Chinner028c2dd2010-07-07 13:24:07 +1000362 __entry->range_start = (long)wbc->range_start;
363 __entry->range_end = (long)wbc->range_end;
Tejun Heo5634cc22015-08-18 14:54:56 -0700364 __trace_wbc_assign_cgroup(__get_str(cgroup), wbc);
Dave Chinner028c2dd2010-07-07 13:24:07 +1000365 ),
366
367 TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
Wu Fengguangd46db3d2011-05-04 19:54:37 -0600368 "bgrd=%d reclm=%d cyclic=%d "
Tejun Heo5634cc22015-08-18 14:54:56 -0700369 "start=0x%lx end=0x%lx cgroup=%s",
Dave Chinner028c2dd2010-07-07 13:24:07 +1000370 __entry->name,
371 __entry->nr_to_write,
372 __entry->pages_skipped,
373 __entry->sync_mode,
374 __entry->for_kupdate,
375 __entry->for_background,
376 __entry->for_reclaim,
377 __entry->range_cyclic,
Dave Chinner028c2dd2010-07-07 13:24:07 +1000378 __entry->range_start,
Tejun Heo5634cc22015-08-18 14:54:56 -0700379 __entry->range_end,
380 __get_str(cgroup)
381 )
Dave Chinner028c2dd2010-07-07 13:24:07 +1000382)
383
384#define DEFINE_WBC_EVENT(name) \
385DEFINE_EVENT(wbc_class, name, \
386 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
387 TP_ARGS(wbc, bdi))
Dave Chinner9e094382010-07-07 13:24:08 +1000388DEFINE_WBC_EVENT(wbc_writepage);
Dave Chinner028c2dd2010-07-07 13:24:07 +1000389
Wu Fengguange84d0a42011-04-23 12:27:27 -0600390TRACE_EVENT(writeback_queue_io,
391 TP_PROTO(struct bdi_writeback *wb,
Curt Wohlgemuthad4e38d2011-10-07 21:51:56 -0600392 struct wb_writeback_work *work,
Wu Fengguange84d0a42011-04-23 12:27:27 -0600393 int moved),
Curt Wohlgemuthad4e38d2011-10-07 21:51:56 -0600394 TP_ARGS(wb, work, moved),
Wu Fengguange84d0a42011-04-23 12:27:27 -0600395 TP_STRUCT__entry(
396 __array(char, name, 32)
397 __field(unsigned long, older)
398 __field(long, age)
399 __field(int, moved)
Curt Wohlgemuth0e175a12011-10-07 21:54:10 -0600400 __field(int, reason)
Tejun Heo5634cc22015-08-18 14:54:56 -0700401 __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb))
Wu Fengguange84d0a42011-04-23 12:27:27 -0600402 ),
403 TP_fast_assign(
Jan Kara0dc83bd2014-02-21 11:19:04 +0100404 unsigned long *older_than_this = work->older_than_this;
Wu Fengguange84d0a42011-04-23 12:27:27 -0600405 strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
Jan Kara0dc83bd2014-02-21 11:19:04 +0100406 __entry->older = older_than_this ? *older_than_this : 0;
Wu Fengguange84d0a42011-04-23 12:27:27 -0600407 __entry->age = older_than_this ?
Jan Kara0dc83bd2014-02-21 11:19:04 +0100408 (jiffies - *older_than_this) * 1000 / HZ : -1;
Wu Fengguange84d0a42011-04-23 12:27:27 -0600409 __entry->moved = moved;
Curt Wohlgemuth0e175a12011-10-07 21:54:10 -0600410 __entry->reason = work->reason;
Tejun Heo5634cc22015-08-18 14:54:56 -0700411 __trace_wb_assign_cgroup(__get_str(cgroup), wb);
Wu Fengguange84d0a42011-04-23 12:27:27 -0600412 ),
Tejun Heo5634cc22015-08-18 14:54:56 -0700413 TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s cgroup=%s",
Wu Fengguange84d0a42011-04-23 12:27:27 -0600414 __entry->name,
415 __entry->older, /* older_than_this in jiffies */
416 __entry->age, /* older_than_this in relative milliseconds */
Curt Wohlgemuth0e175a12011-10-07 21:54:10 -0600417 __entry->moved,
Tejun Heo5634cc22015-08-18 14:54:56 -0700418 __print_symbolic(__entry->reason, WB_WORK_REASON),
419 __get_str(cgroup)
Wu Fengguangb3bba8722011-12-08 16:53:54 -0600420 )
Wu Fengguange84d0a42011-04-23 12:27:27 -0600421);
422
Wu Fengguange1cbe232010-12-06 22:34:29 -0600423TRACE_EVENT(global_dirty_state,
424
425 TP_PROTO(unsigned long background_thresh,
426 unsigned long dirty_thresh
427 ),
428
429 TP_ARGS(background_thresh,
430 dirty_thresh
431 ),
432
433 TP_STRUCT__entry(
434 __field(unsigned long, nr_dirty)
435 __field(unsigned long, nr_writeback)
436 __field(unsigned long, nr_unstable)
437 __field(unsigned long, background_thresh)
438 __field(unsigned long, dirty_thresh)
439 __field(unsigned long, dirty_limit)
440 __field(unsigned long, nr_dirtied)
441 __field(unsigned long, nr_written)
442 ),
443
444 TP_fast_assign(
445 __entry->nr_dirty = global_page_state(NR_FILE_DIRTY);
446 __entry->nr_writeback = global_page_state(NR_WRITEBACK);
447 __entry->nr_unstable = global_page_state(NR_UNSTABLE_NFS);
448 __entry->nr_dirtied = global_page_state(NR_DIRTIED);
449 __entry->nr_written = global_page_state(NR_WRITTEN);
450 __entry->background_thresh = background_thresh;
451 __entry->dirty_thresh = dirty_thresh;
Tejun Heodcc25ae2015-05-22 18:23:22 -0400452 __entry->dirty_limit = global_wb_domain.dirty_limit;
Wu Fengguange1cbe232010-12-06 22:34:29 -0600453 ),
454
455 TP_printk("dirty=%lu writeback=%lu unstable=%lu "
456 "bg_thresh=%lu thresh=%lu limit=%lu "
457 "dirtied=%lu written=%lu",
458 __entry->nr_dirty,
459 __entry->nr_writeback,
460 __entry->nr_unstable,
461 __entry->background_thresh,
462 __entry->dirty_thresh,
463 __entry->dirty_limit,
464 __entry->nr_dirtied,
465 __entry->nr_written
466 )
467);
468
Wu Fengguangb48c1042011-03-02 17:22:49 -0600469#define KBps(x) ((x) << (PAGE_SHIFT - 10))
470
471TRACE_EVENT(bdi_dirty_ratelimit,
472
Tejun Heo5634cc22015-08-18 14:54:56 -0700473 TP_PROTO(struct bdi_writeback *wb,
Wu Fengguangb48c1042011-03-02 17:22:49 -0600474 unsigned long dirty_rate,
475 unsigned long task_ratelimit),
476
Tejun Heo5634cc22015-08-18 14:54:56 -0700477 TP_ARGS(wb, dirty_rate, task_ratelimit),
Wu Fengguangb48c1042011-03-02 17:22:49 -0600478
479 TP_STRUCT__entry(
480 __array(char, bdi, 32)
481 __field(unsigned long, write_bw)
482 __field(unsigned long, avg_write_bw)
483 __field(unsigned long, dirty_rate)
484 __field(unsigned long, dirty_ratelimit)
485 __field(unsigned long, task_ratelimit)
486 __field(unsigned long, balanced_dirty_ratelimit)
Tejun Heo5634cc22015-08-18 14:54:56 -0700487 __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb))
Wu Fengguangb48c1042011-03-02 17:22:49 -0600488 ),
489
490 TP_fast_assign(
Tejun Heo5634cc22015-08-18 14:54:56 -0700491 strlcpy(__entry->bdi, dev_name(wb->bdi->dev), 32);
492 __entry->write_bw = KBps(wb->write_bandwidth);
493 __entry->avg_write_bw = KBps(wb->avg_write_bandwidth);
Wu Fengguangb48c1042011-03-02 17:22:49 -0600494 __entry->dirty_rate = KBps(dirty_rate);
Tejun Heo5634cc22015-08-18 14:54:56 -0700495 __entry->dirty_ratelimit = KBps(wb->dirty_ratelimit);
Wu Fengguangb48c1042011-03-02 17:22:49 -0600496 __entry->task_ratelimit = KBps(task_ratelimit);
497 __entry->balanced_dirty_ratelimit =
Tejun Heo5634cc22015-08-18 14:54:56 -0700498 KBps(wb->balanced_dirty_ratelimit);
499 __trace_wb_assign_cgroup(__get_str(cgroup), wb);
Wu Fengguangb48c1042011-03-02 17:22:49 -0600500 ),
501
502 TP_printk("bdi %s: "
503 "write_bw=%lu awrite_bw=%lu dirty_rate=%lu "
504 "dirty_ratelimit=%lu task_ratelimit=%lu "
Tejun Heo5634cc22015-08-18 14:54:56 -0700505 "balanced_dirty_ratelimit=%lu cgroup=%s",
Wu Fengguangb48c1042011-03-02 17:22:49 -0600506 __entry->bdi,
507 __entry->write_bw, /* write bandwidth */
508 __entry->avg_write_bw, /* avg write bandwidth */
509 __entry->dirty_rate, /* bdi dirty rate */
510 __entry->dirty_ratelimit, /* base ratelimit */
511 __entry->task_ratelimit, /* ratelimit with position control */
Tejun Heo5634cc22015-08-18 14:54:56 -0700512 __entry->balanced_dirty_ratelimit, /* the balanced ratelimit */
513 __get_str(cgroup)
Wu Fengguangb48c1042011-03-02 17:22:49 -0600514 )
515);
516
Wu Fengguangece13ac32010-08-29 23:33:20 -0600517TRACE_EVENT(balance_dirty_pages,
518
Tejun Heo5634cc22015-08-18 14:54:56 -0700519 TP_PROTO(struct bdi_writeback *wb,
Wu Fengguangece13ac32010-08-29 23:33:20 -0600520 unsigned long thresh,
521 unsigned long bg_thresh,
522 unsigned long dirty,
523 unsigned long bdi_thresh,
524 unsigned long bdi_dirty,
525 unsigned long dirty_ratelimit,
526 unsigned long task_ratelimit,
527 unsigned long dirtied,
Wu Fengguang83712352011-06-11 19:25:42 -0600528 unsigned long period,
Wu Fengguangece13ac32010-08-29 23:33:20 -0600529 long pause,
530 unsigned long start_time),
531
Tejun Heo5634cc22015-08-18 14:54:56 -0700532 TP_ARGS(wb, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
Wu Fengguangece13ac32010-08-29 23:33:20 -0600533 dirty_ratelimit, task_ratelimit,
Wu Fengguang83712352011-06-11 19:25:42 -0600534 dirtied, period, pause, start_time),
Wu Fengguangece13ac32010-08-29 23:33:20 -0600535
536 TP_STRUCT__entry(
537 __array( char, bdi, 32)
538 __field(unsigned long, limit)
539 __field(unsigned long, setpoint)
540 __field(unsigned long, dirty)
541 __field(unsigned long, bdi_setpoint)
542 __field(unsigned long, bdi_dirty)
543 __field(unsigned long, dirty_ratelimit)
544 __field(unsigned long, task_ratelimit)
545 __field(unsigned int, dirtied)
546 __field(unsigned int, dirtied_pause)
547 __field(unsigned long, paused)
548 __field( long, pause)
Wu Fengguang83712352011-06-11 19:25:42 -0600549 __field(unsigned long, period)
550 __field( long, think)
Tejun Heo5634cc22015-08-18 14:54:56 -0700551 __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb))
Wu Fengguangece13ac32010-08-29 23:33:20 -0600552 ),
553
554 TP_fast_assign(
555 unsigned long freerun = (thresh + bg_thresh) / 2;
Tejun Heo5634cc22015-08-18 14:54:56 -0700556 strlcpy(__entry->bdi, dev_name(wb->bdi->dev), 32);
Wu Fengguangece13ac32010-08-29 23:33:20 -0600557
Tejun Heodcc25ae2015-05-22 18:23:22 -0400558 __entry->limit = global_wb_domain.dirty_limit;
559 __entry->setpoint = (global_wb_domain.dirty_limit +
560 freerun) / 2;
Wu Fengguangece13ac32010-08-29 23:33:20 -0600561 __entry->dirty = dirty;
562 __entry->bdi_setpoint = __entry->setpoint *
563 bdi_thresh / (thresh + 1);
564 __entry->bdi_dirty = bdi_dirty;
565 __entry->dirty_ratelimit = KBps(dirty_ratelimit);
566 __entry->task_ratelimit = KBps(task_ratelimit);
567 __entry->dirtied = dirtied;
568 __entry->dirtied_pause = current->nr_dirtied_pause;
Wu Fengguang83712352011-06-11 19:25:42 -0600569 __entry->think = current->dirty_paused_when == 0 ? 0 :
570 (long)(jiffies - current->dirty_paused_when) * 1000/HZ;
571 __entry->period = period * 1000 / HZ;
Wu Fengguangece13ac32010-08-29 23:33:20 -0600572 __entry->pause = pause * 1000 / HZ;
573 __entry->paused = (jiffies - start_time) * 1000 / HZ;
Tejun Heo5634cc22015-08-18 14:54:56 -0700574 __trace_wb_assign_cgroup(__get_str(cgroup), wb);
Wu Fengguangece13ac32010-08-29 23:33:20 -0600575 ),
576
577
578 TP_printk("bdi %s: "
579 "limit=%lu setpoint=%lu dirty=%lu "
580 "bdi_setpoint=%lu bdi_dirty=%lu "
581 "dirty_ratelimit=%lu task_ratelimit=%lu "
582 "dirtied=%u dirtied_pause=%u "
Tejun Heo5634cc22015-08-18 14:54:56 -0700583 "paused=%lu pause=%ld period=%lu think=%ld cgroup=%s",
Wu Fengguangece13ac32010-08-29 23:33:20 -0600584 __entry->bdi,
585 __entry->limit,
586 __entry->setpoint,
587 __entry->dirty,
588 __entry->bdi_setpoint,
589 __entry->bdi_dirty,
590 __entry->dirty_ratelimit,
591 __entry->task_ratelimit,
592 __entry->dirtied,
593 __entry->dirtied_pause,
594 __entry->paused, /* ms */
Wu Fengguang83712352011-06-11 19:25:42 -0600595 __entry->pause, /* ms */
596 __entry->period, /* ms */
Tejun Heo5634cc22015-08-18 14:54:56 -0700597 __entry->think, /* ms */
598 __get_str(cgroup)
Wu Fengguangece13ac32010-08-29 23:33:20 -0600599 )
600);
601
Jan Karacc1676d2012-05-03 14:47:56 +0200602TRACE_EVENT(writeback_sb_inodes_requeue,
603
604 TP_PROTO(struct inode *inode),
605 TP_ARGS(inode),
606
607 TP_STRUCT__entry(
608 __array(char, name, 32)
609 __field(unsigned long, ino)
610 __field(unsigned long, state)
611 __field(unsigned long, dirtied_when)
Tejun Heo5634cc22015-08-18 14:54:56 -0700612 __dynamic_array(char, cgroup,
613 __trace_wb_cgroup_size(inode_to_wb(inode)))
Jan Karacc1676d2012-05-03 14:47:56 +0200614 ),
615
616 TP_fast_assign(
617 strncpy(__entry->name,
618 dev_name(inode_to_bdi(inode)->dev), 32);
619 __entry->ino = inode->i_ino;
620 __entry->state = inode->i_state;
621 __entry->dirtied_when = inode->dirtied_when;
Tejun Heo5634cc22015-08-18 14:54:56 -0700622 __trace_wb_assign_cgroup(__get_str(cgroup), inode_to_wb(inode));
Jan Karacc1676d2012-05-03 14:47:56 +0200623 ),
624
Tejun Heo5634cc22015-08-18 14:54:56 -0700625 TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu cgroup=%s",
Jan Karacc1676d2012-05-03 14:47:56 +0200626 __entry->name,
627 __entry->ino,
628 show_inode_state(__entry->state),
629 __entry->dirtied_when,
Tejun Heo5634cc22015-08-18 14:54:56 -0700630 (jiffies - __entry->dirtied_when) / HZ,
631 __get_str(cgroup)
Jan Karacc1676d2012-05-03 14:47:56 +0200632 )
633);
634
Mel Gorman52bb9192010-10-26 14:21:41 -0700635DECLARE_EVENT_CLASS(writeback_congest_waited_template,
636
637 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
638
639 TP_ARGS(usec_timeout, usec_delayed),
640
641 TP_STRUCT__entry(
642 __field( unsigned int, usec_timeout )
643 __field( unsigned int, usec_delayed )
644 ),
645
646 TP_fast_assign(
647 __entry->usec_timeout = usec_timeout;
648 __entry->usec_delayed = usec_delayed;
649 ),
650
651 TP_printk("usec_timeout=%u usec_delayed=%u",
652 __entry->usec_timeout,
653 __entry->usec_delayed)
654);
655
656DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait,
657
658 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
659
660 TP_ARGS(usec_timeout, usec_delayed)
661);
662
Mel Gorman0e093d992010-10-26 14:21:45 -0700663DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested,
664
665 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
666
667 TP_ARGS(usec_timeout, usec_delayed)
668);
669
Wu Fengguang251d6a42010-12-01 17:33:37 -0600670DECLARE_EVENT_CLASS(writeback_single_inode_template,
671
672 TP_PROTO(struct inode *inode,
673 struct writeback_control *wbc,
674 unsigned long nr_to_write
675 ),
676
677 TP_ARGS(inode, wbc, nr_to_write),
678
679 TP_STRUCT__entry(
680 __array(char, name, 32)
681 __field(unsigned long, ino)
682 __field(unsigned long, state)
Wu Fengguangc8ad6202011-08-29 09:52:23 -0600683 __field(unsigned long, dirtied_when)
Wu Fengguang251d6a42010-12-01 17:33:37 -0600684 __field(unsigned long, writeback_index)
685 __field(long, nr_to_write)
686 __field(unsigned long, wrote)
Tejun Heo5634cc22015-08-18 14:54:56 -0700687 __dynamic_array(char, cgroup, __trace_wbc_cgroup_size(wbc))
Wu Fengguang251d6a42010-12-01 17:33:37 -0600688 ),
689
690 TP_fast_assign(
691 strncpy(__entry->name,
Wu Fengguang15eb77a2012-01-17 11:18:56 -0600692 dev_name(inode_to_bdi(inode)->dev), 32);
Wu Fengguang251d6a42010-12-01 17:33:37 -0600693 __entry->ino = inode->i_ino;
694 __entry->state = inode->i_state;
Wu Fengguangc8ad6202011-08-29 09:52:23 -0600695 __entry->dirtied_when = inode->dirtied_when;
Wu Fengguang251d6a42010-12-01 17:33:37 -0600696 __entry->writeback_index = inode->i_mapping->writeback_index;
697 __entry->nr_to_write = nr_to_write;
698 __entry->wrote = nr_to_write - wbc->nr_to_write;
Tejun Heo5634cc22015-08-18 14:54:56 -0700699 __trace_wbc_assign_cgroup(__get_str(cgroup), wbc);
Wu Fengguang251d6a42010-12-01 17:33:37 -0600700 ),
701
Wu Fengguangc8ad6202011-08-29 09:52:23 -0600702 TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu "
Tejun Heo5634cc22015-08-18 14:54:56 -0700703 "index=%lu to_write=%ld wrote=%lu cgroup=%s",
Wu Fengguang251d6a42010-12-01 17:33:37 -0600704 __entry->name,
705 __entry->ino,
706 show_inode_state(__entry->state),
Wu Fengguangc8ad6202011-08-29 09:52:23 -0600707 __entry->dirtied_when,
708 (jiffies - __entry->dirtied_when) / HZ,
Wu Fengguang251d6a42010-12-01 17:33:37 -0600709 __entry->writeback_index,
710 __entry->nr_to_write,
Tejun Heo5634cc22015-08-18 14:54:56 -0700711 __entry->wrote,
712 __get_str(cgroup)
Wu Fengguang251d6a42010-12-01 17:33:37 -0600713 )
714);
715
Tejun Heo9fb0a7d2013-01-11 13:06:37 -0800716DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode_start,
717 TP_PROTO(struct inode *inode,
718 struct writeback_control *wbc,
719 unsigned long nr_to_write),
720 TP_ARGS(inode, wbc, nr_to_write)
721);
722
Wu Fengguang251d6a42010-12-01 17:33:37 -0600723DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode,
724 TP_PROTO(struct inode *inode,
725 struct writeback_control *wbc,
726 unsigned long nr_to_write),
727 TP_ARGS(inode, wbc, nr_to_write)
728);
729
Theodore Ts'o0ae45f62015-02-02 00:37:00 -0500730DECLARE_EVENT_CLASS(writeback_lazytime_template,
731 TP_PROTO(struct inode *inode),
732
733 TP_ARGS(inode),
734
735 TP_STRUCT__entry(
736 __field( dev_t, dev )
737 __field(unsigned long, ino )
738 __field(unsigned long, state )
739 __field( __u16, mode )
740 __field(unsigned long, dirtied_when )
741 ),
742
743 TP_fast_assign(
744 __entry->dev = inode->i_sb->s_dev;
745 __entry->ino = inode->i_ino;
746 __entry->state = inode->i_state;
747 __entry->mode = inode->i_mode;
748 __entry->dirtied_when = inode->dirtied_when;
749 ),
750
751 TP_printk("dev %d,%d ino %lu dirtied %lu state %s mode 0%o",
752 MAJOR(__entry->dev), MINOR(__entry->dev),
753 __entry->ino, __entry->dirtied_when,
754 show_inode_state(__entry->state), __entry->mode)
755);
756
757DEFINE_EVENT(writeback_lazytime_template, writeback_lazytime,
758 TP_PROTO(struct inode *inode),
759
760 TP_ARGS(inode)
761);
762
763DEFINE_EVENT(writeback_lazytime_template, writeback_lazytime_iput,
764 TP_PROTO(struct inode *inode),
765
766 TP_ARGS(inode)
767);
768
769DEFINE_EVENT(writeback_lazytime_template, writeback_dirty_inode_enqueue,
770
771 TP_PROTO(struct inode *inode),
772
773 TP_ARGS(inode)
774);
775
Dave Chinner455b2862010-07-07 13:24:06 +1000776#endif /* _TRACE_WRITEBACK_H */
777
778/* This part must be outside protection */
779#include <trace/define_trace.h>