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