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