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