Sync `show_inode_state()` macro with Ubuntu 4.15 kernel
[lttng-modules.git] / include / instrumentation / events / writeback.h
CommitLineData
b7cdc182 1/* SPDX-License-Identifier: GPL-2.0-only */
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
3b4aafcb 8#include <lttng/tracepoint-event.h>
aa634cd1 9#include <linux/tracepoint.h>
b87700e3
AG
10#include <linux/backing-dev.h>
11#include <linux/writeback.h>
5f4c791e 12#include <lttng/kernel-version.h>
b87700e3
AG
13
14#ifndef _TRACE_WRITEBACK_DEF_
15#define _TRACE_WRITEBACK_DEF_
99a570c8 16
dbabd729
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))
b1fdcb19
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 */
5f4c791e 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}
5f4c791e 64#endif /* #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(4,0,0)) */
99a570c8 65
b87700e3
AG
66#endif
67
f26997df
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 */
4140ad5d 74#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,9,0) || \
f26997df
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))
084a3c41
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 )
5f4c791e 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 )
5f4c791e 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 )
5f4c791e 118#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,0,0)) */
b87700e3 119
5f4c791e 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(
b1fdcb19 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 */
b1fdcb19 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(
b1fdcb19 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
5f4c791e 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(
b1fdcb19 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 */
b1fdcb19 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(
b1fdcb19 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
5f4c791e 214#endif /* (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,9,0)) */
aa634cd1 215
5f4c791e 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(
b1fdcb19 222 ctf_string(name, lttng_bdi_dev_name(wb->bdi))
a40cb509
MD
223 )
224)
225
b1fdcb19 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(
b1fdcb19 232 ctf_string(name, lttng_bdi_dev_name(bdi))
b87700e3 233 )
b87700e3 234)
99a570c8 235
b1fdcb19 236#endif /* #else if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0)) */
99a570c8 237
5f4c791e 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
5f4c791e 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
5f4c791e 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)
5f4c791e 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
5f4c791e 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(
b1fdcb19 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(
b1fdcb19 296 ctf_string(name, lttng_bdi_dev_name(bdi))
a40cb509
MD
297 )
298)
299
5f4c791e 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(
b1fdcb19 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
5f4c791e 323#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0)) */
a40cb509 324
b87700e3 325DEFINE_WRITEBACK_EVENT(writeback_nowork)
b87700e3 326DEFINE_WRITEBACK_EVENT(writeback_wake_background)
b87700e3
AG
327DEFINE_WRITEBACK_EVENT(writeback_wake_thread)
328DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread)
b87700e3
AG
329DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister)
330DEFINE_WRITEBACK_EVENT(writeback_thread_start)
331DEFINE_WRITEBACK_EVENT(writeback_thread_stop)
332#if (LTTNG_KERNEL_RANGE(3,1,0, 3,2,0))
9cf29d3e
MD
333DEFINE_WRITEBACK_EVENT_MAP(balance_dirty_start, writeback_balance_dirty_start)
334DEFINE_WRITEBACK_EVENT_MAP(balance_dirty_wait, writeback_balance_dirty_wait)
335
3bc29f0a 336LTTNG_TRACEPOINT_EVENT_MAP(balance_dirty_written,
b87700e3 337
9cf29d3e 338 writeback_balance_dirty_written,
b87700e3
AG
339
340 TP_PROTO(struct backing_dev_info *bdi, int written),
341
342 TP_ARGS(bdi, written),
343
f127e61e 344 TP_FIELDS(
b1fdcb19 345 ctf_string(name, lttng_bdi_dev_name(bdi))
f127e61e 346 ctf_integer(int, written, written)
b87700e3
AG
347 )
348)
349#endif
350
3bc29f0a 351LTTNG_TRACEPOINT_EVENT_CLASS(writeback_wbc_class,
b87700e3
AG
352 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
353 TP_ARGS(wbc, bdi),
f127e61e 354 TP_FIELDS(
b1fdcb19 355 ctf_string(name, lttng_bdi_dev_name(bdi))
f127e61e
MD
356 ctf_integer(long, nr_to_write, wbc->nr_to_write)
357 ctf_integer(long, pages_skipped, wbc->pages_skipped)
358 ctf_integer(int, sync_mode, wbc->sync_mode)
359 ctf_integer(int, for_kupdate, wbc->for_kupdate)
360 ctf_integer(int, for_background, wbc->for_background)
361 ctf_integer(int, for_reclaim, wbc->for_reclaim)
362 ctf_integer(int, range_cyclic, wbc->range_cyclic)
5f4c791e 363#if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,1,0))
f127e61e
MD
364 ctf_integer(int, more_io, wbc->more_io)
365 ctf_integer(unsigned long, older_than_this,
366 wbc->older_than_this ? *wbc->older_than_this : 0)
b87700e3 367#endif
f127e61e
MD
368 ctf_integer(long, range_start, (long) wbc->range_start)
369 ctf_integer(long, range_end, (long) wbc->range_end)
370 )
b87700e3
AG
371)
372
9cf29d3e 373#undef DEFINE_WBC_EVENT
3bc29f0a
MD
374#define LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(name, map) \
375LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(writeback_wbc_class, name, map, \
b87700e3
AG
376 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
377 TP_ARGS(wbc, bdi))
5f4c791e 378#if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,1,0))
3bc29f0a
MD
379LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writeback_start, writeback_wbc_writeback_start)
380LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writeback_written, writeback_wbc_writeback_written)
381LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writeback_wait, writeback_wbc_writeback_wait)
382LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_balance_dirty_start, writeback_wbc_balance_dirty_start)
383LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_balance_dirty_written, writeback_wbc_balance_dirty_written)
384LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_balance_dirty_wait, writeback_wbc_balance_dirty_wait)
b87700e3 385#endif
3bc29f0a 386LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writepage, writeback_wbc_writepage)
b87700e3 387
5f4c791e 388#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,9,0) || \
b6af46d1
MJ
389 LTTNG_KERNEL_RANGE(5,8,6, 5,9,0) || \
390 LTTNG_KERNEL_RANGE(5,4,62, 5,5,0) || \
391 LTTNG_KERNEL_RANGE(4,19,143, 4,20,0) || \
392 LTTNG_KERNEL_RANGE(4,14,196, 4,15,0) || \
393 LTTNG_KERNEL_RANGE(4,9,235, 4,10,0) || \
da139c48
MJ
394 LTTNG_KERNEL_RANGE(4,4,235, 4,5,0) || \
395 LTTNG_UBUNTU_KERNEL_RANGE(4,15,18,119, 4,16,0,0))
817e02f9
MJ
396LTTNG_TRACEPOINT_EVENT(writeback_queue_io,
397 TP_PROTO(struct bdi_writeback *wb,
398 struct wb_writeback_work *work,
399 unsigned long dirtied_before,
400 int moved),
401 TP_ARGS(wb, work, dirtied_before, moved),
402 TP_FIELDS(
b1fdcb19 403 ctf_string(name, lttng_bdi_dev_name(wb->bdi))
817e02f9
MJ
404 ctf_integer(unsigned long, older, dirtied_before)
405 ctf_integer(int, moved, moved)
406 )
407)
5f4c791e 408#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,2,0))
3bc29f0a 409LTTNG_TRACEPOINT_EVENT(writeback_queue_io,
b87700e3 410 TP_PROTO(struct bdi_writeback *wb,
b87700e3 411 struct wb_writeback_work *work,
b87700e3 412 int moved),
b87700e3 413 TP_ARGS(wb, work, moved),
817e02f9 414 TP_FIELDS(
b1fdcb19 415 ctf_string(name, lttng_bdi_dev_name(wb->bdi))
817e02f9
MJ
416 ctf_integer(int, moved, moved)
417 )
418)
5f4c791e 419#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,1,0))
817e02f9
MJ
420LTTNG_TRACEPOINT_EVENT(writeback_queue_io,
421 TP_PROTO(struct bdi_writeback *wb,
422 unsigned long *older_than_this,
423 int moved),
b87700e3 424 TP_ARGS(wb, older_than_this, moved),
f127e61e 425 TP_FIELDS(
b1fdcb19 426 ctf_string(name, lttng_bdi_dev_name(wb->bdi))
f127e61e
MD
427 ctf_integer(unsigned long, older,
428 older_than_this ? *older_than_this : 0)
429 ctf_integer(long, age,
430 older_than_this ?
431 (jiffies - *older_than_this) * 1000 / HZ
432 : -1)
f127e61e 433 ctf_integer(int, moved, moved)
b87700e3 434 )
b87700e3 435)
817e02f9 436#endif
b87700e3 437
5f4c791e 438#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,8,0))
0b1facd4
MJ
439LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
440
441 writeback_global_dirty_state,
442
443 TP_PROTO(unsigned long background_thresh,
444 unsigned long dirty_thresh
445 ),
446
447 TP_ARGS(background_thresh,
448 dirty_thresh
449 ),
450
451 TP_FIELDS(
452 ctf_integer(unsigned long, nr_dirty, global_node_page_state(NR_FILE_DIRTY))
453 ctf_integer(unsigned long, nr_writeback, global_node_page_state(NR_WRITEBACK))
454 ctf_integer(unsigned long, nr_dirtied, global_node_page_state(NR_DIRTIED))
455 ctf_integer(unsigned long, nr_written, global_node_page_state(NR_WRITTEN))
456 ctf_integer(unsigned long, background_thresh, background_thresh)
457 ctf_integer(unsigned long, dirty_thresh, dirty_thresh)
458 ctf_integer(unsigned long, dirty_limit, global_dirty_limit)
459 )
460)
5f4c791e 461#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,14,0))
7ceeb15d
MJ
462LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
463
464 writeback_global_dirty_state,
465
466 TP_PROTO(unsigned long background_thresh,
467 unsigned long dirty_thresh
468 ),
469
470 TP_ARGS(background_thresh,
471 dirty_thresh
472 ),
473
474 TP_FIELDS(
475 ctf_integer(unsigned long, nr_dirty, global_node_page_state(NR_FILE_DIRTY))
476 ctf_integer(unsigned long, nr_writeback, global_node_page_state(NR_WRITEBACK))
477 ctf_integer(unsigned long, nr_unstable, global_node_page_state(NR_UNSTABLE_NFS))
478 ctf_integer(unsigned long, nr_dirtied, global_node_page_state(NR_DIRTIED))
479 ctf_integer(unsigned long, nr_written, global_node_page_state(NR_WRITTEN))
480 ctf_integer(unsigned long, background_thresh, background_thresh)
481 ctf_integer(unsigned long, dirty_thresh, dirty_thresh)
482 ctf_integer(unsigned long, dirty_limit, global_dirty_limit)
483 )
484)
5f4c791e 485#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,1,0))
3bc29f0a 486LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
9cf29d3e
MD
487
488 writeback_global_dirty_state,
b87700e3
AG
489
490 TP_PROTO(unsigned long background_thresh,
491 unsigned long dirty_thresh
492 ),
493
494 TP_ARGS(background_thresh,
495 dirty_thresh
496 ),
497
f127e61e
MD
498 TP_FIELDS(
499 ctf_integer(unsigned long, nr_dirty, global_page_state(NR_FILE_DIRTY))
500 ctf_integer(unsigned long, nr_writeback, global_page_state(NR_WRITEBACK))
501 ctf_integer(unsigned long, nr_unstable, global_page_state(NR_UNSTABLE_NFS))
502 ctf_integer(unsigned long, nr_dirtied, global_page_state(NR_DIRTIED))
503 ctf_integer(unsigned long, nr_written, global_page_state(NR_WRITTEN))
504 ctf_integer(unsigned long, background_thresh, background_thresh)
505 ctf_integer(unsigned long, dirty_thresh, dirty_thresh)
506 ctf_integer(unsigned long, dirty_limit, global_dirty_limit)
b87700e3
AG
507 )
508)
509#endif
510
5f4c791e 511#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,2,0))
b87700e3
AG
512
513#define KBps(x) ((x) << (PAGE_SHIFT - 10))
514
5f4c791e 515#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0))
a40cb509
MD
516
517LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit,
518
519 writeback_bdi_dirty_ratelimit,
520
521 TP_PROTO(struct bdi_writeback *wb,
522 unsigned long dirty_rate,
523 unsigned long task_ratelimit),
524
525 TP_ARGS(wb, dirty_rate, task_ratelimit),
526
527 TP_FIELDS(
b1fdcb19 528 ctf_string(bdi, lttng_bdi_dev_name(wb->bdi))
a40cb509
MD
529 ctf_integer(unsigned long, write_bw, KBps(wb->bdi->wb.write_bandwidth))
530 ctf_integer(unsigned long, avg_write_bw, KBps(wb->bdi->wb.avg_write_bandwidth))
531 ctf_integer(unsigned long, dirty_rate, KBps(dirty_rate))
532 ctf_integer(unsigned long, dirty_ratelimit, KBps(wb->bdi->wb.dirty_ratelimit))
533 ctf_integer(unsigned long, task_ratelimit, KBps(task_ratelimit))
534 ctf_integer(unsigned long, balanced_dirty_ratelimit,
535 KBps(wb->bdi->wb.balanced_dirty_ratelimit))
536 )
537)
538
5f4c791e 539#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,2,0))
c7d89a6d 540
3bc29f0a 541LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit,
9cf29d3e
MD
542
543 writeback_bdi_dirty_ratelimit,
b87700e3
AG
544
545 TP_PROTO(struct backing_dev_info *bdi,
546 unsigned long dirty_rate,
547 unsigned long task_ratelimit),
548
549 TP_ARGS(bdi, dirty_rate, task_ratelimit),
550
f127e61e 551 TP_FIELDS(
b1fdcb19 552 ctf_string(bdi, lttng_bdi_dev_name(bdi))
902947a4
MJ
553 ctf_integer(unsigned long, write_bw, KBps(bdi->wb.write_bandwidth))
554 ctf_integer(unsigned long, avg_write_bw, KBps(bdi->wb.avg_write_bandwidth))
f127e61e 555 ctf_integer(unsigned long, dirty_rate, KBps(dirty_rate))
902947a4 556 ctf_integer(unsigned long, dirty_ratelimit, KBps(bdi->wb.dirty_ratelimit))
f127e61e 557 ctf_integer(unsigned long, task_ratelimit, KBps(task_ratelimit))
902947a4
MJ
558 ctf_integer(unsigned long, balanced_dirty_ratelimit,
559 KBps(bdi->wb.balanced_dirty_ratelimit))
c7d89a6d
MD
560 )
561)
562
5f4c791e 563#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,2,0)) */
c7d89a6d
MD
564
565LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit,
566
567 writeback_bdi_dirty_ratelimit,
568
569 TP_PROTO(struct backing_dev_info *bdi,
570 unsigned long dirty_rate,
571 unsigned long task_ratelimit),
572
573 TP_ARGS(bdi, dirty_rate, task_ratelimit),
574
575 TP_FIELDS(
b1fdcb19 576 ctf_string(bdi, lttng_bdi_dev_name(bdi))
c7d89a6d
MD
577 ctf_integer(unsigned long, write_bw, KBps(bdi->write_bandwidth))
578 ctf_integer(unsigned long, avg_write_bw, KBps(bdi->avg_write_bandwidth))
579 ctf_integer(unsigned long, dirty_rate, KBps(dirty_rate))
580 ctf_integer(unsigned long, dirty_ratelimit, KBps(bdi->dirty_ratelimit))
581 ctf_integer(unsigned long, task_ratelimit, KBps(task_ratelimit))
f127e61e 582 ctf_integer(unsigned long, balanced_dirty_ratelimit,
b87700e3 583 KBps(bdi->balanced_dirty_ratelimit))
b87700e3
AG
584 )
585)
586
5f4c791e 587#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,2,0)) */
c7d89a6d 588
5f4c791e 589#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0))
a40cb509
MD
590
591LTTNG_TRACEPOINT_EVENT_MAP(balance_dirty_pages,
592
593 writeback_balance_dirty_pages,
594
595 TP_PROTO(struct bdi_writeback *wb,
596 unsigned long thresh,
597 unsigned long bg_thresh,
598 unsigned long dirty,
599 unsigned long bdi_thresh,
600 unsigned long bdi_dirty,
601 unsigned long dirty_ratelimit,
602 unsigned long task_ratelimit,
603 unsigned long dirtied,
604 unsigned long period,
605 long pause,
606 unsigned long start_time),
607
608 TP_ARGS(wb, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
609 dirty_ratelimit, task_ratelimit,
610 dirtied, period, pause, start_time
611 ),
612
613 TP_FIELDS(
b1fdcb19 614 ctf_string(bdi, lttng_bdi_dev_name(wb->bdi))
a40cb509
MD
615 ctf_integer(unsigned long, limit, global_dirty_limit)
616 ctf_integer(unsigned long, setpoint,
617 (global_dirty_limit + (thresh + bg_thresh) / 2) / 2)
618 ctf_integer(unsigned long, dirty, dirty)
619 ctf_integer(unsigned long, bdi_setpoint,
620 ((global_dirty_limit + (thresh + bg_thresh) / 2) / 2) *
621 bdi_thresh / (thresh + 1))
622 ctf_integer(unsigned long, bdi_dirty, bdi_dirty)
623 ctf_integer(unsigned long, dirty_ratelimit,
624 KBps(dirty_ratelimit))
625 ctf_integer(unsigned long, task_ratelimit,
626 KBps(task_ratelimit))
627 ctf_integer(unsigned int, dirtied, dirtied)
628 ctf_integer(unsigned int, dirtied_pause,
629 current->nr_dirtied_pause)
630 ctf_integer(unsigned long, paused,
631 (jiffies - start_time) * 1000 / HZ)
632 ctf_integer(long, pause, pause * 1000 / HZ)
633 ctf_integer(unsigned long, period,
634 period * 1000 / HZ)
635 ctf_integer(long, think,
636 current->dirty_paused_when == 0 ? 0 :
637 (long)(jiffies - current->dirty_paused_when) * 1000/HZ)
638 )
639)
640
5f4c791e 641#else /* #if LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0)) */
a40cb509 642
3bc29f0a 643LTTNG_TRACEPOINT_EVENT_MAP(balance_dirty_pages,
9cf29d3e
MD
644
645 writeback_balance_dirty_pages,
b87700e3
AG
646
647 TP_PROTO(struct backing_dev_info *bdi,
648 unsigned long thresh,
649 unsigned long bg_thresh,
650 unsigned long dirty,
651 unsigned long bdi_thresh,
652 unsigned long bdi_dirty,
653 unsigned long dirty_ratelimit,
654 unsigned long task_ratelimit,
655 unsigned long dirtied,
5f4c791e 656#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,3,0))
b87700e3
AG
657 unsigned long period,
658#endif
659 long pause,
660 unsigned long start_time),
661
662 TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
663 dirty_ratelimit, task_ratelimit,
5f4c791e 664#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,3,0))
f127e61e 665 dirtied, period, pause, start_time
b87700e3 666#else
f127e61e 667 dirtied, pause, start_time
b87700e3
AG
668#endif
669 ),
670
f127e61e 671 TP_FIELDS(
b1fdcb19 672 ctf_string(bdi, lttng_bdi_dev_name(bdi))
f127e61e
MD
673 ctf_integer(unsigned long, limit, global_dirty_limit)
674 ctf_integer(unsigned long, setpoint,
b87700e3 675 (global_dirty_limit + (thresh + bg_thresh) / 2) / 2)
f127e61e
MD
676 ctf_integer(unsigned long, dirty, dirty)
677 ctf_integer(unsigned long, bdi_setpoint,
b87700e3 678 ((global_dirty_limit + (thresh + bg_thresh) / 2) / 2) *
f127e61e
MD
679 bdi_thresh / (thresh + 1))
680 ctf_integer(unsigned long, bdi_dirty, bdi_dirty)
681 ctf_integer(unsigned long, dirty_ratelimit,
682 KBps(dirty_ratelimit))
683 ctf_integer(unsigned long, task_ratelimit,
684 KBps(task_ratelimit))
685 ctf_integer(unsigned int, dirtied, dirtied)
686 ctf_integer(unsigned int, dirtied_pause,
687 current->nr_dirtied_pause)
688 ctf_integer(unsigned long, paused,
689 (jiffies - start_time) * 1000 / HZ)
690 ctf_integer(long, pause, pause * 1000 / HZ)
5f4c791e 691#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,3,0))
f127e61e
MD
692 ctf_integer(unsigned long, period,
693 period * 1000 / HZ)
694 ctf_integer(long, think,
695 current->dirty_paused_when == 0 ? 0 :
696 (long)(jiffies - current->dirty_paused_when) * 1000/HZ)
b87700e3 697#endif
f127e61e 698 )
b87700e3 699)
5f4c791e 700#endif /* #else #if LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,3,0)) */
a40cb509 701
5f4c791e 702#endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,2,0)) */
b87700e3 703
5f4c791e 704#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,5,0))
3bc29f0a 705LTTNG_TRACEPOINT_EVENT(writeback_sb_inodes_requeue,
b87700e3
AG
706
707 TP_PROTO(struct inode *inode),
708 TP_ARGS(inode),
709
f127e61e 710 TP_FIELDS(
b1fdcb19 711 ctf_string(name, lttng_bdi_dev_name(lttng_inode_to_bdi(inode)))
f127e61e
MD
712 ctf_integer(unsigned long, ino, inode->i_ino)
713 ctf_integer(unsigned long, state, inode->i_state)
714 ctf_integer(unsigned long, dirtied_when, inode->dirtied_when)
b87700e3
AG
715 )
716)
717#endif
718
3bc29f0a 719LTTNG_TRACEPOINT_EVENT_CLASS(writeback_congest_waited_template,
b87700e3
AG
720
721 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
722
723 TP_ARGS(usec_timeout, usec_delayed),
724
f127e61e
MD
725 TP_FIELDS(
726 ctf_integer(unsigned int, usec_timeout, usec_timeout)
727 ctf_integer(unsigned int, usec_delayed, usec_delayed)
728 )
b87700e3
AG
729)
730
3bc29f0a 731LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_congest_waited_template, writeback_congestion_wait,
b87700e3
AG
732
733 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
734
735 TP_ARGS(usec_timeout, usec_delayed)
736)
737
3bc29f0a 738LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_congest_waited_template, writeback_wait_iff_congested,
b87700e3
AG
739
740 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
741
742 TP_ARGS(usec_timeout, usec_delayed)
743)
b87700e3 744
5f4c791e 745#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,1,0))
3bc29f0a 746LTTNG_TRACEPOINT_EVENT_CLASS(writeback_single_inode_template,
b87700e3
AG
747
748 TP_PROTO(struct inode *inode,
749 struct writeback_control *wbc,
750 unsigned long nr_to_write
751 ),
752
753 TP_ARGS(inode, wbc, nr_to_write),
754
f127e61e 755 TP_FIELDS(
b1fdcb19 756 ctf_string(name, lttng_bdi_dev_name(lttng_inode_to_bdi(inode)))
f127e61e
MD
757 ctf_integer(unsigned long, ino, inode->i_ino)
758 ctf_integer(unsigned long, state, inode->i_state)
759 ctf_integer(unsigned long, dirtied_when, inode->dirtied_when)
760 ctf_integer(unsigned long, writeback_index,
761 inode->i_mapping->writeback_index)
762 ctf_integer(long, nr_to_write, nr_to_write)
763 ctf_integer(unsigned long, wrote,
764 nr_to_write - wbc->nr_to_write)
b87700e3
AG
765 )
766)
767
5f4c791e 768#if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,5,0))
3bc29f0a 769LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_single_inode_template, writeback_single_inode_requeue,
b87700e3
AG
770 TP_PROTO(struct inode *inode,
771 struct writeback_control *wbc,
772 unsigned long nr_to_write),
773 TP_ARGS(inode, wbc, nr_to_write)
774)
775#endif
776
3bc29f0a 777LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_single_inode_template, writeback_single_inode,
b87700e3
AG
778 TP_PROTO(struct inode *inode,
779 struct writeback_control *wbc,
780 unsigned long nr_to_write),
781 TP_ARGS(inode, wbc, nr_to_write)
782)
783#endif
784
3bc29f0a 785#endif /* LTTNG_TRACE_WRITEBACK_H */
b87700e3
AG
786
787/* This part must be outside protection */
3b4aafcb 788#include <lttng/define_trace.h>
This page took 0.085616 seconds and 4 git commands to generate.