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