Sync `show_inode_state()` macro with upstream stable kernels
[lttng-modules.git] / instrumentation / events / lttng-module / writeback.h
CommitLineData
9f36eaed 1/* SPDX-License-Identifier: GPL-2.0 */
b87700e3
AG
2#undef TRACE_SYSTEM
3#define TRACE_SYSTEM writeback
4
3bc29f0a
MD
5#if !defined(LTTNG_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ)
6#define LTTNG_TRACE_WRITEBACK_H
b87700e3 7
6ec43db8 8#include <probes/lttng-tracepoint-event.h>
aa634cd1 9#include <linux/tracepoint.h>
b87700e3
AG
10#include <linux/backing-dev.h>
11#include <linux/writeback.h>
b78104db 12#include <lttng-kernel-version.h>
b87700e3
AG
13
14#ifndef _TRACE_WRITEBACK_DEF_
15#define _TRACE_WRITEBACK_DEF_
99a570c8 16
3b158f7b
MD
17/*
18 * Use the GPL-exported bdi_dev_name introduced in kernel 5.7. Do not use
19 * static inline bdi_dev_name in prior kernels because it uses the bdi_unknown_name
20 * symbol which is not exported to GPL modules.
21 */
22#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,7,0))
1461bc67
MD
23static inline const char *lttng_bdi_dev_name(struct backing_dev_info *bdi)
24{
25 return bdi_dev_name(bdi);
26}
27#else
28static inline const char *lttng_bdi_dev_name(struct backing_dev_info *bdi)
29{
30 if (!bdi || !bdi->dev)
31 return "(unknown)";
32 return dev_name(bdi->dev);
33}
34#endif
35
70f6fc80
MJ
36/*
37 * Vanilla kernels before 4.0 do not implement inode_to_bdi
38 * RHEL kernels before 3.10.0-327.10.1 do not implement inode_to_bdi
39 * RHEL kernel 3.10.0-327.10.1 has inode_to_bdi
40 * RHEL kernel 3.10.0-327.13.1 includes a partial merge of upstream
41 * commit a212b105b07d75b48b1a166378282e8a77fbf53d which inlines
42 * inode_to_bdi but not sb_is_blkdev_sb making it unusable by modules.
43 */
b78104db 44#if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(4,0,0))
70f6fc80 45static inline struct backing_dev_info *lttng_inode_to_bdi(struct inode *inode)
b87700e3 46{
70f6fc80
MJ
47 struct super_block *sb;
48
49 if (!inode)
50 return &noop_backing_dev_info;
51
52 sb = inode->i_sb;
b87700e3
AG
53
54 if (strcmp(sb->s_type->name, "bdev") == 0)
55 return inode->i_mapping->backing_dev_info;
56
57 return sb->s_bdi;
58}
70f6fc80
MJ
59#else
60static inline struct backing_dev_info *lttng_inode_to_bdi(struct inode *inode)
61{
62 return inode_to_bdi(inode);
63}
b78104db 64#endif /* #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(4,0,0)) */
99a570c8 65
b87700e3
AG
66#endif
67
4643974c
FD
68/*
69 * Keep this macro around to track changes in the valid values for `state`.
70 * Eventually, we will have a enum to describe that field. If the macro is
71 * changed by an upstream kernel, the fact that we have a redefinition here
72 * will generate a compiler warning.
73 */
2855acb9 74#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,9,0) || \
e71c0a44
MJ
75 LTTNG_KERNEL_RANGE(4,14,218, 4,15,0) || \
76 LTTNG_KERNEL_RANGE(4,19,172, 4,20,0) || \
77 LTTNG_KERNEL_RANGE(5,4,94, 5,5,0) || \
4643974c 78 LTTNG_UBUNTU_KERNEL_RANGE(4,15,18,141, 4,16,0,0))
e1eb6145
MJ
79#define show_inode_state(state) \
80 __print_flags(state, "|", \
81 {I_DIRTY_SYNC, "I_DIRTY_SYNC"}, \
82 {I_DIRTY_DATASYNC, "I_DIRTY_DATASYNC"}, \
83 {I_DIRTY_PAGES, "I_DIRTY_PAGES"}, \
84 {I_NEW, "I_NEW"}, \
85 {I_WILL_FREE, "I_WILL_FREE"}, \
86 {I_FREEING, "I_FREEING"}, \
87 {I_CLEAR, "I_CLEAR"}, \
88 {I_SYNC, "I_SYNC"}, \
89 {I_DIRTY_TIME, "I_DIRTY_TIME"}, \
90 {I_REFERENCED, "I_REFERENCED"} \
91 )
b78104db 92#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,0,0))
99a570c8
MD
93#define show_inode_state(state) \
94 __print_flags(state, "|", \
95 {I_DIRTY_SYNC, "I_DIRTY_SYNC"}, \
96 {I_DIRTY_DATASYNC, "I_DIRTY_DATASYNC"}, \
97 {I_DIRTY_PAGES, "I_DIRTY_PAGES"}, \
98 {I_NEW, "I_NEW"}, \
99 {I_WILL_FREE, "I_WILL_FREE"}, \
100 {I_FREEING, "I_FREEING"}, \
101 {I_CLEAR, "I_CLEAR"}, \
102 {I_SYNC, "I_SYNC"}, \
103 {I_DIRTY_TIME, "I_DIRTY_TIME"}, \
104 {I_DIRTY_TIME_EXPIRED, "I_DIRTY_TIME_EXPIRED"}, \
105 {I_REFERENCED, "I_REFERENCED"} \
106 )
b78104db 107#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,0,0)) */
b87700e3
AG
108#define show_inode_state(state) \
109 __print_flags(state, "|", \
110 {I_DIRTY_SYNC, "I_DIRTY_SYNC"}, \
111 {I_DIRTY_DATASYNC, "I_DIRTY_DATASYNC"}, \
112 {I_DIRTY_PAGES, "I_DIRTY_PAGES"}, \
113 {I_NEW, "I_NEW"}, \
114 {I_WILL_FREE, "I_WILL_FREE"}, \
115 {I_FREEING, "I_FREEING"}, \
116 {I_CLEAR, "I_CLEAR"}, \
117 {I_SYNC, "I_SYNC"}, \
118 {I_REFERENCED, "I_REFERENCED"} \
119 )
b78104db 120#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,0,0)) */
b87700e3 121
b78104db 122#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,0,0))
99a570c8
MD
123
124LTTNG_TRACEPOINT_EVENT(writeback_dirty_page,
125 TP_PROTO(struct page *page, struct address_space *mapping),
126 TP_ARGS(page, mapping),
f127e61e 127 TP_FIELDS(
1461bc67 128 ctf_string(name, lttng_bdi_dev_name(mapping ? lttng_inode_to_bdi(mapping->host) : NULL))
f127e61e
MD
129 ctf_integer(unsigned long, ino, mapping ? mapping->host->i_ino : 0)
130 ctf_integer(pgoff_t, index, page->index)
99a570c8
MD
131 )
132)
133
134LTTNG_TRACEPOINT_EVENT_CLASS(writeback_dirty_inode_template,
135 TP_PROTO(struct inode *inode, int flags),
136 TP_ARGS(inode, flags),
f127e61e 137 TP_FIELDS(
99a570c8 138 /* may be called for files on pseudo FSes w/ unregistered bdi */
1461bc67 139 ctf_string(name, lttng_bdi_dev_name(lttng_inode_to_bdi(inode)))
f127e61e
MD
140 ctf_integer(unsigned long, ino, inode->i_ino)
141 ctf_integer(unsigned long, state, inode->i_state)
142 ctf_integer(unsigned long, flags, flags)
99a570c8
MD
143 )
144)
145#define LTTNG_TRACEPOINT_EVENT_WRITEBACK_DIRTY_INODE_TEMPLATE(name) \
146LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_dirty_inode_template, name, \
147 TP_PROTO(struct inode *inode, int flags), \
148 TP_ARGS(inode, flags))
149LTTNG_TRACEPOINT_EVENT_WRITEBACK_DIRTY_INODE_TEMPLATE(writeback_dirty_inode_start)
150LTTNG_TRACEPOINT_EVENT_WRITEBACK_DIRTY_INODE_TEMPLATE(writeback_dirty_inode)
151LTTNG_TRACEPOINT_EVENT_WRITEBACK_DIRTY_INODE_TEMPLATE(writeback_mark_inode_dirty)
152
153LTTNG_TRACEPOINT_EVENT_CLASS(writeback_write_inode_template,
154 TP_PROTO(struct inode *inode, struct writeback_control *wbc),
155 TP_ARGS(inode, wbc),
f127e61e 156 TP_FIELDS(
1461bc67 157 ctf_string(name, lttng_bdi_dev_name(lttng_inode_to_bdi(inode)))
f127e61e
MD
158 ctf_integer(unsigned long, ino, inode->i_ino)
159 ctf_integer(int, sync_mode, wbc->sync_mode)
99a570c8
MD
160 )
161)
162
163#define LTTNG_TRACEPOINT_EVENT_WRITEBACK_WRITE_INODE(name) \
164LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_write_inode_template, name, \
165 TP_PROTO(struct inode *inode, struct writeback_control *wbc), \
166 TP_ARGS(inode, wbc))
167LTTNG_TRACEPOINT_EVENT_WRITEBACK_WRITE_INODE(writeback_write_inode_start)
168LTTNG_TRACEPOINT_EVENT_WRITEBACK_WRITE_INODE(writeback_write_inode)
169
b78104db 170#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,9,0))
99a570c8 171
aa634cd1
JD
172LTTNG_TRACEPOINT_EVENT(writeback_dirty_page,
173 TP_PROTO(struct page *page, struct address_space *mapping),
174 TP_ARGS(page, mapping),
f127e61e 175 TP_FIELDS(
1461bc67 176 ctf_string(name, lttng_bdi_dev_name(mapping ? mapping->backing_dev_info : NULL))
f127e61e
MD
177 ctf_integer(unsigned long, ino, mapping ? mapping->host->i_ino : 0)
178 ctf_integer(pgoff_t, index, page->index)
aa634cd1
JD
179 )
180)
181
182LTTNG_TRACEPOINT_EVENT_CLASS(writeback_dirty_inode_template,
183 TP_PROTO(struct inode *inode, int flags),
184 TP_ARGS(inode, flags),
f127e61e 185 TP_FIELDS(
aa634cd1 186 /* may be called for files on pseudo FSes w/ unregistered bdi */
1461bc67 187 ctf_string(name, lttng_bdi_dev_name(inode->i_mapping->backing_dev_info))
f127e61e
MD
188 ctf_integer(unsigned long, ino, inode->i_ino)
189 ctf_integer(unsigned long, flags, flags)
aa634cd1
JD
190 )
191)
192#define LTTNG_TRACEPOINT_EVENT_WRITEBACK_DIRTY_INODE_TEMPLATE(name) \
193LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_dirty_inode_template, name, \
194 TP_PROTO(struct inode *inode, int flags), \
195 TP_ARGS(inode, flags))
196LTTNG_TRACEPOINT_EVENT_WRITEBACK_DIRTY_INODE_TEMPLATE(writeback_dirty_inode_start)
197LTTNG_TRACEPOINT_EVENT_WRITEBACK_DIRTY_INODE_TEMPLATE(writeback_dirty_inode)
198
199LTTNG_TRACEPOINT_EVENT_CLASS(writeback_write_inode_template,
200 TP_PROTO(struct inode *inode, struct writeback_control *wbc),
201 TP_ARGS(inode, wbc),
f127e61e 202 TP_FIELDS(
1461bc67 203 ctf_string(name, lttng_bdi_dev_name(inode->i_mapping->backing_dev_info))
f127e61e
MD
204 ctf_integer(unsigned long, ino, inode->i_ino)
205 ctf_integer(int, sync_mode, wbc->sync_mode)
aa634cd1
JD
206 )
207)
208
209#define LTTNG_TRACEPOINT_EVENT_WRITEBACK_WRITE_INODE(name) \
210LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_write_inode_template, name, \
211 TP_PROTO(struct inode *inode, struct writeback_control *wbc), \
212 TP_ARGS(inode, wbc))
213LTTNG_TRACEPOINT_EVENT_WRITEBACK_WRITE_INODE(writeback_write_inode_start)
214LTTNG_TRACEPOINT_EVENT_WRITEBACK_WRITE_INODE(writeback_write_inode)
99a570c8 215
b78104db 216#endif /* (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,9,0)) */
aa634cd1 217
b78104db 218#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0))
a40cb509
MD
219
220LTTNG_TRACEPOINT_EVENT_CLASS(writeback_work_class,
221 TP_PROTO(struct bdi_writeback *wb, struct wb_writeback_work *work),
222 TP_ARGS(wb, work),
223 TP_FIELDS(
1461bc67 224 ctf_string(name, lttng_bdi_dev_name(wb->bdi))
a40cb509
MD
225 )
226)
227
1461bc67 228#else
99a570c8 229
3bc29f0a 230LTTNG_TRACEPOINT_EVENT_CLASS(writeback_work_class,
b87700e3
AG
231 TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work),
232 TP_ARGS(bdi, work),
f127e61e 233 TP_FIELDS(
1461bc67 234 ctf_string(name, lttng_bdi_dev_name(bdi))
b87700e3 235 )
b87700e3 236)
99a570c8 237
1461bc67 238#endif /* #else if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0)) */
99a570c8 239
b78104db 240#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0))
a40cb509
MD
241
242#define LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(name) \
243LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_work_class, name, \
244 TP_PROTO(struct bdi_writeback *wb, struct wb_writeback_work *work), \
245 TP_ARGS(wb, work))
246
b78104db 247#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0)) */
a40cb509 248
3bc29f0a
MD
249#define LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(name) \
250LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_work_class, name, \
b87700e3
AG
251 TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \
252 TP_ARGS(bdi, work))
a40cb509 253
b78104db 254#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0)) */
a40cb509 255
3bc29f0a
MD
256LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(writeback_nothread)
257LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(writeback_queue)
258LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(writeback_exec)
b78104db 259#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,1,0))
3bc29f0a
MD
260LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(writeback_start)
261LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(writeback_written)
262LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(writeback_wait)
b87700e3
AG
263#endif
264
3bc29f0a 265LTTNG_TRACEPOINT_EVENT(writeback_pages_written,
b87700e3
AG
266 TP_PROTO(long pages_written),
267 TP_ARGS(pages_written),
f127e61e
MD
268 TP_FIELDS(
269 ctf_integer(long, pages, pages_written)
270 )
b87700e3
AG
271)
272
b78104db 273#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0))
a40cb509
MD
274
275LTTNG_TRACEPOINT_EVENT_CLASS(writeback_class,
276 TP_PROTO(struct bdi_writeback *wb),
277 TP_ARGS(wb),
278 TP_FIELDS(
1461bc67 279 ctf_string(name, lttng_bdi_dev_name(wb->bdi))
a40cb509
MD
280 )
281)
282
283#undef DEFINE_WRITEBACK_EVENT
284#define DEFINE_WRITEBACK_EVENT(name) \
285LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_class, name, \
286 TP_PROTO(struct bdi_writeback *wb), \
287 TP_ARGS(wb))
288
289#define DEFINE_WRITEBACK_EVENT_MAP(name, map) \
290LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(writeback_class, name, map, \
291 TP_PROTO(struct bdi_writeback *wb), \
292 TP_ARGS(wb))
293
294LTTNG_TRACEPOINT_EVENT(writeback_bdi_register,
295 TP_PROTO(struct backing_dev_info *bdi),
296 TP_ARGS(bdi),
297 TP_FIELDS(
1461bc67 298 ctf_string(name, lttng_bdi_dev_name(bdi))
a40cb509
MD
299 )
300)
301
b78104db 302#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0)) */
a40cb509 303
3bc29f0a 304LTTNG_TRACEPOINT_EVENT_CLASS(writeback_class,
b87700e3
AG
305 TP_PROTO(struct backing_dev_info *bdi),
306 TP_ARGS(bdi),
f127e61e 307 TP_FIELDS(
1461bc67 308 ctf_string(name, lttng_bdi_dev_name(bdi))
b87700e3
AG
309 )
310)
a40cb509 311
59fecd6c 312#undef DEFINE_WRITEBACK_EVENT
b87700e3 313#define DEFINE_WRITEBACK_EVENT(name) \
3bc29f0a 314LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_class, name, \
b87700e3
AG
315 TP_PROTO(struct backing_dev_info *bdi), \
316 TP_ARGS(bdi))
317
9cf29d3e 318#define DEFINE_WRITEBACK_EVENT_MAP(name, map) \
3bc29f0a 319LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(writeback_class, name, map, \
9cf29d3e
MD
320 TP_PROTO(struct backing_dev_info *bdi), \
321 TP_ARGS(bdi))
322
a40cb509
MD
323DEFINE_WRITEBACK_EVENT(writeback_bdi_register)
324
b78104db 325#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0)) */
a40cb509 326
b87700e3 327DEFINE_WRITEBACK_EVENT(writeback_nowork)
b78104db 328#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,38))
b87700e3
AG
329DEFINE_WRITEBACK_EVENT(writeback_wake_background)
330#endif
331DEFINE_WRITEBACK_EVENT(writeback_wake_thread)
332DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread)
b87700e3
AG
333DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister)
334DEFINE_WRITEBACK_EVENT(writeback_thread_start)
335DEFINE_WRITEBACK_EVENT(writeback_thread_stop)
336#if (LTTNG_KERNEL_RANGE(3,1,0, 3,2,0))
9cf29d3e
MD
337DEFINE_WRITEBACK_EVENT_MAP(balance_dirty_start, writeback_balance_dirty_start)
338DEFINE_WRITEBACK_EVENT_MAP(balance_dirty_wait, writeback_balance_dirty_wait)
339
3bc29f0a 340LTTNG_TRACEPOINT_EVENT_MAP(balance_dirty_written,
b87700e3 341
9cf29d3e 342 writeback_balance_dirty_written,
b87700e3
AG
343
344 TP_PROTO(struct backing_dev_info *bdi, int written),
345
346 TP_ARGS(bdi, written),
347
f127e61e 348 TP_FIELDS(
1461bc67 349 ctf_string(name, lttng_bdi_dev_name(bdi))
f127e61e 350 ctf_integer(int, written, written)
b87700e3
AG
351 )
352)
353#endif
354
3bc29f0a 355LTTNG_TRACEPOINT_EVENT_CLASS(writeback_wbc_class,
b87700e3
AG
356 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
357 TP_ARGS(wbc, bdi),
f127e61e 358 TP_FIELDS(
1461bc67 359 ctf_string(name, lttng_bdi_dev_name(bdi))
f127e61e
MD
360 ctf_integer(long, nr_to_write, wbc->nr_to_write)
361 ctf_integer(long, pages_skipped, wbc->pages_skipped)
362 ctf_integer(int, sync_mode, wbc->sync_mode)
363 ctf_integer(int, for_kupdate, wbc->for_kupdate)
364 ctf_integer(int, for_background, wbc->for_background)
365 ctf_integer(int, for_reclaim, wbc->for_reclaim)
366 ctf_integer(int, range_cyclic, wbc->range_cyclic)
b78104db 367#if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,1,0))
f127e61e
MD
368 ctf_integer(int, more_io, wbc->more_io)
369 ctf_integer(unsigned long, older_than_this,
370 wbc->older_than_this ? *wbc->older_than_this : 0)
b87700e3 371#endif
f127e61e
MD
372 ctf_integer(long, range_start, (long) wbc->range_start)
373 ctf_integer(long, range_end, (long) wbc->range_end)
374 )
b87700e3
AG
375)
376
9cf29d3e 377#undef DEFINE_WBC_EVENT
3bc29f0a
MD
378#define LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(name, map) \
379LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(writeback_wbc_class, name, map, \
b87700e3
AG
380 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
381 TP_ARGS(wbc, bdi))
b78104db 382#if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,1,0))
3bc29f0a
MD
383LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writeback_start, writeback_wbc_writeback_start)
384LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writeback_written, writeback_wbc_writeback_written)
385LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writeback_wait, writeback_wbc_writeback_wait)
386LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_balance_dirty_start, writeback_wbc_balance_dirty_start)
387LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_balance_dirty_written, writeback_wbc_balance_dirty_written)
388LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_balance_dirty_wait, writeback_wbc_balance_dirty_wait)
b87700e3 389#endif
3bc29f0a 390LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writepage, writeback_wbc_writepage)
b87700e3 391
b78104db 392#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,9,0) || \
f60ce55b
MJ
393 LTTNG_KERNEL_RANGE(5,8,6, 5,9,0) || \
394 LTTNG_KERNEL_RANGE(5,4,62, 5,5,0) || \
395 LTTNG_KERNEL_RANGE(4,19,143, 4,20,0) || \
396 LTTNG_KERNEL_RANGE(4,14,196, 4,15,0) || \
397 LTTNG_KERNEL_RANGE(4,9,235, 4,10,0) || \
e85a3521
MJ
398 LTTNG_KERNEL_RANGE(4,4,235, 4,5,0) || \
399 LTTNG_UBUNTU_KERNEL_RANGE(4,15,18,119, 4,16,0,0))
31410cca
MJ
400LTTNG_TRACEPOINT_EVENT(writeback_queue_io,
401 TP_PROTO(struct bdi_writeback *wb,
402 struct wb_writeback_work *work,
403 unsigned long dirtied_before,
404 int moved),
405 TP_ARGS(wb, work, dirtied_before, moved),
406 TP_FIELDS(
1461bc67 407 ctf_string(name, lttng_bdi_dev_name(wb->bdi))
31410cca
MJ
408 ctf_integer(unsigned long, older, dirtied_before)
409 ctf_integer(int, moved, moved)
410 )
411)
b78104db 412#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,2,0))
3bc29f0a 413LTTNG_TRACEPOINT_EVENT(writeback_queue_io,
b87700e3 414 TP_PROTO(struct bdi_writeback *wb,
b87700e3 415 struct wb_writeback_work *work,
b87700e3 416 int moved),
b87700e3 417 TP_ARGS(wb, work, moved),
31410cca 418 TP_FIELDS(
1461bc67 419 ctf_string(name, lttng_bdi_dev_name(wb->bdi))
31410cca
MJ
420 ctf_integer(int, moved, moved)
421 )
422)
b78104db 423#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,1,0))
31410cca
MJ
424LTTNG_TRACEPOINT_EVENT(writeback_queue_io,
425 TP_PROTO(struct bdi_writeback *wb,
426 unsigned long *older_than_this,
427 int moved),
b87700e3 428 TP_ARGS(wb, older_than_this, moved),
f127e61e 429 TP_FIELDS(
1461bc67 430 ctf_string(name, lttng_bdi_dev_name(wb->bdi))
f127e61e
MD
431 ctf_integer(unsigned long, older,
432 older_than_this ? *older_than_this : 0)
433 ctf_integer(long, age,
434 older_than_this ?
435 (jiffies - *older_than_this) * 1000 / HZ
436 : -1)
f127e61e 437 ctf_integer(int, moved, moved)
b87700e3 438 )
b87700e3 439)
31410cca 440#endif
b87700e3 441
b78104db 442#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,8,0))
b87a9840
MJ
443LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
444
445 writeback_global_dirty_state,
446
447 TP_PROTO(unsigned long background_thresh,
448 unsigned long dirty_thresh
449 ),
450
451 TP_ARGS(background_thresh,
452 dirty_thresh
453 ),
454
455 TP_FIELDS(
456 ctf_integer(unsigned long, nr_dirty, global_node_page_state(NR_FILE_DIRTY))
457 ctf_integer(unsigned long, nr_writeback, global_node_page_state(NR_WRITEBACK))
458 ctf_integer(unsigned long, nr_dirtied, global_node_page_state(NR_DIRTIED))
459 ctf_integer(unsigned long, nr_written, global_node_page_state(NR_WRITTEN))
460 ctf_integer(unsigned long, background_thresh, background_thresh)
461 ctf_integer(unsigned long, dirty_thresh, dirty_thresh)
462 ctf_integer(unsigned long, dirty_limit, global_dirty_limit)
463 )
464)
b78104db 465#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,14,0))
7ceeb15d
MJ
466LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
467
468 writeback_global_dirty_state,
469
470 TP_PROTO(unsigned long background_thresh,
471 unsigned long dirty_thresh
472 ),
473
474 TP_ARGS(background_thresh,
475 dirty_thresh
476 ),
477
478 TP_FIELDS(
479 ctf_integer(unsigned long, nr_dirty, global_node_page_state(NR_FILE_DIRTY))
480 ctf_integer(unsigned long, nr_writeback, global_node_page_state(NR_WRITEBACK))
481 ctf_integer(unsigned long, nr_unstable, global_node_page_state(NR_UNSTABLE_NFS))
482 ctf_integer(unsigned long, nr_dirtied, global_node_page_state(NR_DIRTIED))
483 ctf_integer(unsigned long, nr_written, global_node_page_state(NR_WRITTEN))
484 ctf_integer(unsigned long, background_thresh, background_thresh)
485 ctf_integer(unsigned long, dirty_thresh, dirty_thresh)
486 ctf_integer(unsigned long, dirty_limit, global_dirty_limit)
487 )
488)
b78104db 489#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,1,0))
3bc29f0a 490LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
9cf29d3e
MD
491
492 writeback_global_dirty_state,
b87700e3
AG
493
494 TP_PROTO(unsigned long background_thresh,
495 unsigned long dirty_thresh
496 ),
497
498 TP_ARGS(background_thresh,
499 dirty_thresh
500 ),
501
f127e61e
MD
502 TP_FIELDS(
503 ctf_integer(unsigned long, nr_dirty, global_page_state(NR_FILE_DIRTY))
504 ctf_integer(unsigned long, nr_writeback, global_page_state(NR_WRITEBACK))
505 ctf_integer(unsigned long, nr_unstable, global_page_state(NR_UNSTABLE_NFS))
506 ctf_integer(unsigned long, nr_dirtied, global_page_state(NR_DIRTIED))
507 ctf_integer(unsigned long, nr_written, global_page_state(NR_WRITTEN))
508 ctf_integer(unsigned long, background_thresh, background_thresh)
509 ctf_integer(unsigned long, dirty_thresh, dirty_thresh)
510 ctf_integer(unsigned long, dirty_limit, global_dirty_limit)
b87700e3
AG
511 )
512)
513#endif
514
b78104db 515#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,2,0))
b87700e3
AG
516
517#define KBps(x) ((x) << (PAGE_SHIFT - 10))
518
b78104db 519#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0))
a40cb509
MD
520
521LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit,
522
523 writeback_bdi_dirty_ratelimit,
524
525 TP_PROTO(struct bdi_writeback *wb,
526 unsigned long dirty_rate,
527 unsigned long task_ratelimit),
528
529 TP_ARGS(wb, dirty_rate, task_ratelimit),
530
531 TP_FIELDS(
1461bc67 532 ctf_string(bdi, lttng_bdi_dev_name(wb->bdi))
a40cb509
MD
533 ctf_integer(unsigned long, write_bw, KBps(wb->bdi->wb.write_bandwidth))
534 ctf_integer(unsigned long, avg_write_bw, KBps(wb->bdi->wb.avg_write_bandwidth))
535 ctf_integer(unsigned long, dirty_rate, KBps(dirty_rate))
536 ctf_integer(unsigned long, dirty_ratelimit, KBps(wb->bdi->wb.dirty_ratelimit))
537 ctf_integer(unsigned long, task_ratelimit, KBps(task_ratelimit))
538 ctf_integer(unsigned long, balanced_dirty_ratelimit,
539 KBps(wb->bdi->wb.balanced_dirty_ratelimit))
540 )
541)
542
b78104db 543#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,2,0))
c7d89a6d 544
3bc29f0a 545LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit,
9cf29d3e
MD
546
547 writeback_bdi_dirty_ratelimit,
b87700e3
AG
548
549 TP_PROTO(struct backing_dev_info *bdi,
550 unsigned long dirty_rate,
551 unsigned long task_ratelimit),
552
553 TP_ARGS(bdi, dirty_rate, task_ratelimit),
554
f127e61e 555 TP_FIELDS(
1461bc67 556 ctf_string(bdi, lttng_bdi_dev_name(bdi))
902947a4
MJ
557 ctf_integer(unsigned long, write_bw, KBps(bdi->wb.write_bandwidth))
558 ctf_integer(unsigned long, avg_write_bw, KBps(bdi->wb.avg_write_bandwidth))
f127e61e 559 ctf_integer(unsigned long, dirty_rate, KBps(dirty_rate))
902947a4 560 ctf_integer(unsigned long, dirty_ratelimit, KBps(bdi->wb.dirty_ratelimit))
f127e61e 561 ctf_integer(unsigned long, task_ratelimit, KBps(task_ratelimit))
902947a4
MJ
562 ctf_integer(unsigned long, balanced_dirty_ratelimit,
563 KBps(bdi->wb.balanced_dirty_ratelimit))
c7d89a6d
MD
564 )
565)
566
b78104db 567#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,2,0)) */
c7d89a6d
MD
568
569LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit,
570
571 writeback_bdi_dirty_ratelimit,
572
573 TP_PROTO(struct backing_dev_info *bdi,
574 unsigned long dirty_rate,
575 unsigned long task_ratelimit),
576
577 TP_ARGS(bdi, dirty_rate, task_ratelimit),
578
579 TP_FIELDS(
1461bc67 580 ctf_string(bdi, lttng_bdi_dev_name(bdi))
c7d89a6d
MD
581 ctf_integer(unsigned long, write_bw, KBps(bdi->write_bandwidth))
582 ctf_integer(unsigned long, avg_write_bw, KBps(bdi->avg_write_bandwidth))
583 ctf_integer(unsigned long, dirty_rate, KBps(dirty_rate))
584 ctf_integer(unsigned long, dirty_ratelimit, KBps(bdi->dirty_ratelimit))
585 ctf_integer(unsigned long, task_ratelimit, KBps(task_ratelimit))
f127e61e 586 ctf_integer(unsigned long, balanced_dirty_ratelimit,
b87700e3 587 KBps(bdi->balanced_dirty_ratelimit))
b87700e3
AG
588 )
589)
590
b78104db 591#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,2,0)) */
c7d89a6d 592
b78104db 593#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0))
a40cb509
MD
594
595LTTNG_TRACEPOINT_EVENT_MAP(balance_dirty_pages,
596
597 writeback_balance_dirty_pages,
598
599 TP_PROTO(struct bdi_writeback *wb,
600 unsigned long thresh,
601 unsigned long bg_thresh,
602 unsigned long dirty,
603 unsigned long bdi_thresh,
604 unsigned long bdi_dirty,
605 unsigned long dirty_ratelimit,
606 unsigned long task_ratelimit,
607 unsigned long dirtied,
608 unsigned long period,
609 long pause,
610 unsigned long start_time),
611
612 TP_ARGS(wb, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
613 dirty_ratelimit, task_ratelimit,
614 dirtied, period, pause, start_time
615 ),
616
617 TP_FIELDS(
1461bc67 618 ctf_string(bdi, lttng_bdi_dev_name(wb->bdi))
a40cb509
MD
619 ctf_integer(unsigned long, limit, global_dirty_limit)
620 ctf_integer(unsigned long, setpoint,
621 (global_dirty_limit + (thresh + bg_thresh) / 2) / 2)
622 ctf_integer(unsigned long, dirty, dirty)
623 ctf_integer(unsigned long, bdi_setpoint,
624 ((global_dirty_limit + (thresh + bg_thresh) / 2) / 2) *
625 bdi_thresh / (thresh + 1))
626 ctf_integer(unsigned long, bdi_dirty, bdi_dirty)
627 ctf_integer(unsigned long, dirty_ratelimit,
628 KBps(dirty_ratelimit))
629 ctf_integer(unsigned long, task_ratelimit,
630 KBps(task_ratelimit))
631 ctf_integer(unsigned int, dirtied, dirtied)
632 ctf_integer(unsigned int, dirtied_pause,
633 current->nr_dirtied_pause)
634 ctf_integer(unsigned long, paused,
635 (jiffies - start_time) * 1000 / HZ)
636 ctf_integer(long, pause, pause * 1000 / HZ)
637 ctf_integer(unsigned long, period,
638 period * 1000 / HZ)
639 ctf_integer(long, think,
640 current->dirty_paused_when == 0 ? 0 :
641 (long)(jiffies - current->dirty_paused_when) * 1000/HZ)
642 )
643)
644
b78104db 645#else /* #if LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0)) */
a40cb509 646
3bc29f0a 647LTTNG_TRACEPOINT_EVENT_MAP(balance_dirty_pages,
9cf29d3e
MD
648
649 writeback_balance_dirty_pages,
b87700e3
AG
650
651 TP_PROTO(struct backing_dev_info *bdi,
652 unsigned long thresh,
653 unsigned long bg_thresh,
654 unsigned long dirty,
655 unsigned long bdi_thresh,
656 unsigned long bdi_dirty,
657 unsigned long dirty_ratelimit,
658 unsigned long task_ratelimit,
659 unsigned long dirtied,
b78104db 660#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,3,0))
b87700e3
AG
661 unsigned long period,
662#endif
663 long pause,
664 unsigned long start_time),
665
666 TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
667 dirty_ratelimit, task_ratelimit,
b78104db 668#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,3,0))
f127e61e 669 dirtied, period, pause, start_time
b87700e3 670#else
f127e61e 671 dirtied, pause, start_time
b87700e3
AG
672#endif
673 ),
674
f127e61e 675 TP_FIELDS(
1461bc67 676 ctf_string(bdi, lttng_bdi_dev_name(bdi))
f127e61e
MD
677 ctf_integer(unsigned long, limit, global_dirty_limit)
678 ctf_integer(unsigned long, setpoint,
b87700e3 679 (global_dirty_limit + (thresh + bg_thresh) / 2) / 2)
f127e61e
MD
680 ctf_integer(unsigned long, dirty, dirty)
681 ctf_integer(unsigned long, bdi_setpoint,
b87700e3 682 ((global_dirty_limit + (thresh + bg_thresh) / 2) / 2) *
f127e61e
MD
683 bdi_thresh / (thresh + 1))
684 ctf_integer(unsigned long, bdi_dirty, bdi_dirty)
685 ctf_integer(unsigned long, dirty_ratelimit,
686 KBps(dirty_ratelimit))
687 ctf_integer(unsigned long, task_ratelimit,
688 KBps(task_ratelimit))
689 ctf_integer(unsigned int, dirtied, dirtied)
690 ctf_integer(unsigned int, dirtied_pause,
691 current->nr_dirtied_pause)
692 ctf_integer(unsigned long, paused,
693 (jiffies - start_time) * 1000 / HZ)
694 ctf_integer(long, pause, pause * 1000 / HZ)
b78104db 695#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,3,0))
f127e61e
MD
696 ctf_integer(unsigned long, period,
697 period * 1000 / HZ)
698 ctf_integer(long, think,
699 current->dirty_paused_when == 0 ? 0 :
700 (long)(jiffies - current->dirty_paused_when) * 1000/HZ)
b87700e3 701#endif
f127e61e 702 )
b87700e3 703)
b78104db 704#endif /* #else #if LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0)) */
a40cb509 705
b78104db 706#endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,2,0)) */
b87700e3 707
b78104db 708#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,5,0))
3bc29f0a 709LTTNG_TRACEPOINT_EVENT(writeback_sb_inodes_requeue,
b87700e3
AG
710
711 TP_PROTO(struct inode *inode),
712 TP_ARGS(inode),
713
f127e61e 714 TP_FIELDS(
1461bc67 715 ctf_string(name, lttng_bdi_dev_name(lttng_inode_to_bdi(inode)))
f127e61e
MD
716 ctf_integer(unsigned long, ino, inode->i_ino)
717 ctf_integer(unsigned long, state, inode->i_state)
718 ctf_integer(unsigned long, dirtied_when, inode->dirtied_when)
b87700e3
AG
719 )
720)
721#endif
722
b78104db 723#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,37))
3bc29f0a 724LTTNG_TRACEPOINT_EVENT_CLASS(writeback_congest_waited_template,
b87700e3
AG
725
726 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
727
728 TP_ARGS(usec_timeout, usec_delayed),
729
f127e61e
MD
730 TP_FIELDS(
731 ctf_integer(unsigned int, usec_timeout, usec_timeout)
732 ctf_integer(unsigned int, usec_delayed, usec_delayed)
733 )
b87700e3
AG
734)
735
3bc29f0a 736LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_congest_waited_template, writeback_congestion_wait,
b87700e3
AG
737
738 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
739
740 TP_ARGS(usec_timeout, usec_delayed)
741)
742
3bc29f0a 743LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_congest_waited_template, writeback_wait_iff_congested,
b87700e3
AG
744
745 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
746
747 TP_ARGS(usec_timeout, usec_delayed)
748)
749#endif
750
b78104db 751#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,1,0))
3bc29f0a 752LTTNG_TRACEPOINT_EVENT_CLASS(writeback_single_inode_template,
b87700e3
AG
753
754 TP_PROTO(struct inode *inode,
755 struct writeback_control *wbc,
756 unsigned long nr_to_write
757 ),
758
759 TP_ARGS(inode, wbc, nr_to_write),
760
f127e61e 761 TP_FIELDS(
1461bc67 762 ctf_string(name, lttng_bdi_dev_name(lttng_inode_to_bdi(inode)))
f127e61e
MD
763 ctf_integer(unsigned long, ino, inode->i_ino)
764 ctf_integer(unsigned long, state, inode->i_state)
765 ctf_integer(unsigned long, dirtied_when, inode->dirtied_when)
766 ctf_integer(unsigned long, writeback_index,
767 inode->i_mapping->writeback_index)
768 ctf_integer(long, nr_to_write, nr_to_write)
769 ctf_integer(unsigned long, wrote,
770 nr_to_write - wbc->nr_to_write)
b87700e3
AG
771 )
772)
773
b78104db 774#if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,5,0))
3bc29f0a 775LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_single_inode_template, writeback_single_inode_requeue,
b87700e3
AG
776 TP_PROTO(struct inode *inode,
777 struct writeback_control *wbc,
778 unsigned long nr_to_write),
779 TP_ARGS(inode, wbc, nr_to_write)
780)
781#endif
782
3bc29f0a 783LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_single_inode_template, writeback_single_inode,
b87700e3
AG
784 TP_PROTO(struct inode *inode,
785 struct writeback_control *wbc,
786 unsigned long nr_to_write),
787 TP_ARGS(inode, wbc, nr_to_write)
788)
789#endif
790
3bc29f0a 791#endif /* LTTNG_TRACE_WRITEBACK_H */
b87700e3
AG
792
793/* This part must be outside protection */
6ec43db8 794#include <probes/define_trace.h>
This page took 0.080751 seconds and 4 git commands to generate.