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