fix: mm/writeback: discard NR_UNSTABLE_NFS, use NR_WRITEBACK (v5.8)
[lttng-modules.git] / instrumentation / events / lttng-module / writeback.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM writeback
4
5 #if !defined(LTTNG_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define LTTNG_TRACE_WRITEBACK_H
7
8 #include <probes/lttng-tracepoint-event.h>
9 #include <linux/tracepoint.h>
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_
16
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)
27 {
28 struct super_block *sb;
29
30 if (!inode)
31 return &noop_backing_dev_info;
32
33 sb = inode->i_sb;
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 }
40 #else
41 static inline struct backing_dev_info *lttng_inode_to_bdi(struct inode *inode)
42 {
43 return inode_to_bdi(inode);
44 }
45 #endif /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)) */
46
47 #endif
48
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)) */
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 )
77 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)) */
78
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),
84 TP_FIELDS(
85 ctf_array_text(char, name,
86 mapping ? dev_name(lttng_inode_to_bdi(mapping->host)->dev) : "(unknown)", 32)
87 ctf_integer(unsigned long, ino, mapping ? mapping->host->i_ino : 0)
88 ctf_integer(pgoff_t, index, page->index)
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),
95 TP_FIELDS(
96 /* may be called for files on pseudo FSes w/ unregistered bdi */
97 ctf_array_text(char, name,
98 lttng_inode_to_bdi(inode)->dev ?
99 dev_name(lttng_inode_to_bdi(inode)->dev) : "(unknown)", 32)
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)
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),
116 TP_FIELDS(
117 ctf_array_text(char, name,
118 dev_name(lttng_inode_to_bdi(inode)->dev), 32)
119 ctf_integer(unsigned long, ino, inode->i_ino)
120 ctf_integer(int, sync_mode, wbc->sync_mode)
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
133 LTTNG_TRACEPOINT_EVENT(writeback_dirty_page,
134 TP_PROTO(struct page *page, struct address_space *mapping),
135 TP_ARGS(page, mapping),
136 TP_FIELDS(
137 ctf_array_text(char, name,
138 mapping ? dev_name(mapping->backing_dev_info->dev) : "(unknown)", 32)
139 ctf_integer(unsigned long, ino, mapping ? mapping->host->i_ino : 0)
140 ctf_integer(pgoff_t, index, page->index)
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),
147 TP_FIELDS(
148 /* may be called for files on pseudo FSes w/ unregistered bdi */
149 ctf_array_text(char, name,
150 inode->i_mapping->backing_dev_info->dev ?
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)
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),
167 TP_FIELDS(
168 ctf_array_text(char, name,
169 dev_name(inode->i_mapping->backing_dev_info->dev), 32)
170 ctf_integer(unsigned long, ino, inode->i_ino)
171 ctf_integer(int, sync_mode, wbc->sync_mode)
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)
181
182 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) */
183
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))
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),
200 TP_FIELDS(
201 ctf_array_text(char, name, bdi->dev ? dev_name(bdi->dev) :
202 "(unknown)", 32)
203 )
204 )
205
206 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)) */
207
208 LTTNG_TRACEPOINT_EVENT_CLASS(writeback_work_class,
209 TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work),
210 TP_ARGS(bdi, work),
211 TP_FIELDS(
212 ctf_array_text(char, name,
213 dev_name(bdi->dev ? bdi->dev :
214 default_backing_dev_info.dev), 32)
215 )
216 )
217
218 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)) */
219
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
229 #define LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(name) \
230 LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_work_class, name, \
231 TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \
232 TP_ARGS(bdi, work))
233
234 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */
235
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)
239 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
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)
243 #endif
244
245 LTTNG_TRACEPOINT_EVENT(writeback_pages_written,
246 TP_PROTO(long pages_written),
247 TP_ARGS(pages_written),
248 TP_FIELDS(
249 ctf_integer(long, pages, pages_written)
250 )
251 )
252
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
286 LTTNG_TRACEPOINT_EVENT_CLASS(writeback_class,
287 TP_PROTO(struct backing_dev_info *bdi),
288 TP_ARGS(bdi),
289 TP_FIELDS(
290 ctf_array_text(char, name,
291 dev_name(bdi->dev), 32)
292 )
293 )
294
295 #undef DEFINE_WRITEBACK_EVENT
296 #define DEFINE_WRITEBACK_EVENT(name) \
297 LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_class, name, \
298 TP_PROTO(struct backing_dev_info *bdi), \
299 TP_ARGS(bdi))
300
301 #define DEFINE_WRITEBACK_EVENT_MAP(name, map) \
302 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(writeback_class, name, map, \
303 TP_PROTO(struct backing_dev_info *bdi), \
304 TP_ARGS(bdi))
305
306 DEFINE_WRITEBACK_EVENT(writeback_bdi_register)
307
308 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */
309
310 DEFINE_WRITEBACK_EVENT(writeback_nowork)
311 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
312 DEFINE_WRITEBACK_EVENT(writeback_wake_background)
313 #endif
314 DEFINE_WRITEBACK_EVENT(writeback_wake_thread)
315 DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread)
316 DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister)
317 DEFINE_WRITEBACK_EVENT(writeback_thread_start)
318 DEFINE_WRITEBACK_EVENT(writeback_thread_stop)
319 #if (LTTNG_KERNEL_RANGE(3,1,0, 3,2,0))
320 DEFINE_WRITEBACK_EVENT_MAP(balance_dirty_start, writeback_balance_dirty_start)
321 DEFINE_WRITEBACK_EVENT_MAP(balance_dirty_wait, writeback_balance_dirty_wait)
322
323 LTTNG_TRACEPOINT_EVENT_MAP(balance_dirty_written,
324
325 writeback_balance_dirty_written,
326
327 TP_PROTO(struct backing_dev_info *bdi, int written),
328
329 TP_ARGS(bdi, written),
330
331 TP_FIELDS(
332 ctf_array_text(char, name, dev_name(bdi->dev), 32)
333 ctf_integer(int, written, written)
334 )
335 )
336 #endif
337
338 LTTNG_TRACEPOINT_EVENT_CLASS(writeback_wbc_class,
339 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
340 TP_ARGS(wbc, bdi),
341 TP_FIELDS(
342 ctf_array_text(char, name, dev_name(bdi->dev), 32)
343 ctf_integer(long, nr_to_write, wbc->nr_to_write)
344 ctf_integer(long, pages_skipped, wbc->pages_skipped)
345 ctf_integer(int, sync_mode, wbc->sync_mode)
346 ctf_integer(int, for_kupdate, wbc->for_kupdate)
347 ctf_integer(int, for_background, wbc->for_background)
348 ctf_integer(int, for_reclaim, wbc->for_reclaim)
349 ctf_integer(int, range_cyclic, wbc->range_cyclic)
350 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
351 ctf_integer(int, more_io, wbc->more_io)
352 ctf_integer(unsigned long, older_than_this,
353 wbc->older_than_this ? *wbc->older_than_this : 0)
354 #endif
355 ctf_integer(long, range_start, (long) wbc->range_start)
356 ctf_integer(long, range_end, (long) wbc->range_end)
357 )
358 )
359
360 #undef DEFINE_WBC_EVENT
361 #define LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(name, map) \
362 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(writeback_wbc_class, name, map, \
363 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
364 TP_ARGS(wbc, bdi))
365 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
366 LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writeback_start, writeback_wbc_writeback_start)
367 LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writeback_written, writeback_wbc_writeback_written)
368 LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writeback_wait, writeback_wbc_writeback_wait)
369 LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_balance_dirty_start, writeback_wbc_balance_dirty_start)
370 LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_balance_dirty_written, writeback_wbc_balance_dirty_written)
371 LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_balance_dirty_wait, writeback_wbc_balance_dirty_wait)
372 #endif
373 LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writepage, writeback_wbc_writepage)
374
375 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
376 LTTNG_TRACEPOINT_EVENT(writeback_queue_io,
377 TP_PROTO(struct bdi_writeback *wb,
378 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
379 struct wb_writeback_work *work,
380 #else
381 unsigned long *older_than_this,
382 #endif
383 int moved),
384 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
385 TP_ARGS(wb, work, moved),
386 #else
387 TP_ARGS(wb, older_than_this, moved),
388 #endif
389 TP_FIELDS(
390 ctf_array_text(char, name, dev_name(wb->bdi->dev), 32)
391 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
392 #else
393 ctf_integer(unsigned long, older,
394 older_than_this ? *older_than_this : 0)
395 ctf_integer(long, age,
396 older_than_this ?
397 (jiffies - *older_than_this) * 1000 / HZ
398 : -1)
399 #endif
400 ctf_integer(int, moved, moved)
401 )
402 )
403
404 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0))
405 LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
406
407 writeback_global_dirty_state,
408
409 TP_PROTO(unsigned long background_thresh,
410 unsigned long dirty_thresh
411 ),
412
413 TP_ARGS(background_thresh,
414 dirty_thresh
415 ),
416
417 TP_FIELDS(
418 ctf_integer(unsigned long, nr_dirty, global_node_page_state(NR_FILE_DIRTY))
419 ctf_integer(unsigned long, nr_writeback, global_node_page_state(NR_WRITEBACK))
420 ctf_integer(unsigned long, nr_dirtied, global_node_page_state(NR_DIRTIED))
421 ctf_integer(unsigned long, nr_written, global_node_page_state(NR_WRITTEN))
422 ctf_integer(unsigned long, background_thresh, background_thresh)
423 ctf_integer(unsigned long, dirty_thresh, dirty_thresh)
424 ctf_integer(unsigned long, dirty_limit, global_dirty_limit)
425 )
426 )
427 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0))
428 LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
429
430 writeback_global_dirty_state,
431
432 TP_PROTO(unsigned long background_thresh,
433 unsigned long dirty_thresh
434 ),
435
436 TP_ARGS(background_thresh,
437 dirty_thresh
438 ),
439
440 TP_FIELDS(
441 ctf_integer(unsigned long, nr_dirty, global_node_page_state(NR_FILE_DIRTY))
442 ctf_integer(unsigned long, nr_writeback, global_node_page_state(NR_WRITEBACK))
443 ctf_integer(unsigned long, nr_unstable, global_node_page_state(NR_UNSTABLE_NFS))
444 ctf_integer(unsigned long, nr_dirtied, global_node_page_state(NR_DIRTIED))
445 ctf_integer(unsigned long, nr_written, global_node_page_state(NR_WRITTEN))
446 ctf_integer(unsigned long, background_thresh, background_thresh)
447 ctf_integer(unsigned long, dirty_thresh, dirty_thresh)
448 ctf_integer(unsigned long, dirty_limit, global_dirty_limit)
449 )
450 )
451 #else
452 LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
453
454 writeback_global_dirty_state,
455
456 TP_PROTO(unsigned long background_thresh,
457 unsigned long dirty_thresh
458 ),
459
460 TP_ARGS(background_thresh,
461 dirty_thresh
462 ),
463
464 TP_FIELDS(
465 ctf_integer(unsigned long, nr_dirty, global_page_state(NR_FILE_DIRTY))
466 ctf_integer(unsigned long, nr_writeback, global_page_state(NR_WRITEBACK))
467 ctf_integer(unsigned long, nr_unstable, global_page_state(NR_UNSTABLE_NFS))
468 ctf_integer(unsigned long, nr_dirtied, global_page_state(NR_DIRTIED))
469 ctf_integer(unsigned long, nr_written, global_page_state(NR_WRITTEN))
470 ctf_integer(unsigned long, background_thresh, background_thresh)
471 ctf_integer(unsigned long, dirty_thresh, dirty_thresh)
472 ctf_integer(unsigned long, dirty_limit, global_dirty_limit)
473 )
474 )
475 #endif
476 #endif
477
478 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
479
480 #define KBps(x) ((x) << (PAGE_SHIFT - 10))
481
482 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0))
483
484 LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit,
485
486 writeback_bdi_dirty_ratelimit,
487
488 TP_PROTO(struct bdi_writeback *wb,
489 unsigned long dirty_rate,
490 unsigned long task_ratelimit),
491
492 TP_ARGS(wb, dirty_rate, task_ratelimit),
493
494 TP_FIELDS(
495 ctf_array_text(char, bdi, dev_name(wb->bdi->dev), 32)
496 ctf_integer(unsigned long, write_bw, KBps(wb->bdi->wb.write_bandwidth))
497 ctf_integer(unsigned long, avg_write_bw, KBps(wb->bdi->wb.avg_write_bandwidth))
498 ctf_integer(unsigned long, dirty_rate, KBps(dirty_rate))
499 ctf_integer(unsigned long, dirty_ratelimit, KBps(wb->bdi->wb.dirty_ratelimit))
500 ctf_integer(unsigned long, task_ratelimit, KBps(task_ratelimit))
501 ctf_integer(unsigned long, balanced_dirty_ratelimit,
502 KBps(wb->bdi->wb.balanced_dirty_ratelimit))
503 )
504 )
505
506 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0))
507
508 LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit,
509
510 writeback_bdi_dirty_ratelimit,
511
512 TP_PROTO(struct backing_dev_info *bdi,
513 unsigned long dirty_rate,
514 unsigned long task_ratelimit),
515
516 TP_ARGS(bdi, dirty_rate, task_ratelimit),
517
518 TP_FIELDS(
519 ctf_array_text(char, bdi, dev_name(bdi->dev), 32)
520 ctf_integer(unsigned long, write_bw, KBps(bdi->wb.write_bandwidth))
521 ctf_integer(unsigned long, avg_write_bw, KBps(bdi->wb.avg_write_bandwidth))
522 ctf_integer(unsigned long, dirty_rate, KBps(dirty_rate))
523 ctf_integer(unsigned long, dirty_ratelimit, KBps(bdi->wb.dirty_ratelimit))
524 ctf_integer(unsigned long, task_ratelimit, KBps(task_ratelimit))
525 ctf_integer(unsigned long, balanced_dirty_ratelimit,
526 KBps(bdi->wb.balanced_dirty_ratelimit))
527 )
528 )
529
530 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
531
532 LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit,
533
534 writeback_bdi_dirty_ratelimit,
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
542 TP_FIELDS(
543 ctf_array_text(char, bdi, dev_name(bdi->dev), 32)
544 ctf_integer(unsigned long, write_bw, KBps(bdi->write_bandwidth))
545 ctf_integer(unsigned long, avg_write_bw, KBps(bdi->avg_write_bandwidth))
546 ctf_integer(unsigned long, dirty_rate, KBps(dirty_rate))
547 ctf_integer(unsigned long, dirty_ratelimit, KBps(bdi->dirty_ratelimit))
548 ctf_integer(unsigned long, task_ratelimit, KBps(task_ratelimit))
549 ctf_integer(unsigned long, balanced_dirty_ratelimit,
550 KBps(bdi->balanced_dirty_ratelimit))
551 )
552 )
553
554 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
555
556 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0))
557
558 LTTNG_TRACEPOINT_EVENT_MAP(balance_dirty_pages,
559
560 writeback_balance_dirty_pages,
561
562 TP_PROTO(struct bdi_writeback *wb,
563 unsigned long thresh,
564 unsigned long bg_thresh,
565 unsigned long dirty,
566 unsigned long bdi_thresh,
567 unsigned long bdi_dirty,
568 unsigned long dirty_ratelimit,
569 unsigned long task_ratelimit,
570 unsigned long dirtied,
571 unsigned long period,
572 long pause,
573 unsigned long start_time),
574
575 TP_ARGS(wb, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
576 dirty_ratelimit, task_ratelimit,
577 dirtied, period, pause, start_time
578 ),
579
580 TP_FIELDS(
581 ctf_array_text(char, bdi, dev_name(wb->bdi->dev), 32)
582 ctf_integer(unsigned long, limit, global_dirty_limit)
583 ctf_integer(unsigned long, setpoint,
584 (global_dirty_limit + (thresh + bg_thresh) / 2) / 2)
585 ctf_integer(unsigned long, dirty, dirty)
586 ctf_integer(unsigned long, bdi_setpoint,
587 ((global_dirty_limit + (thresh + bg_thresh) / 2) / 2) *
588 bdi_thresh / (thresh + 1))
589 ctf_integer(unsigned long, bdi_dirty, bdi_dirty)
590 ctf_integer(unsigned long, dirty_ratelimit,
591 KBps(dirty_ratelimit))
592 ctf_integer(unsigned long, task_ratelimit,
593 KBps(task_ratelimit))
594 ctf_integer(unsigned int, dirtied, dirtied)
595 ctf_integer(unsigned int, dirtied_pause,
596 current->nr_dirtied_pause)
597 ctf_integer(unsigned long, paused,
598 (jiffies - start_time) * 1000 / HZ)
599 ctf_integer(long, pause, pause * 1000 / HZ)
600 ctf_integer(unsigned long, period,
601 period * 1000 / HZ)
602 ctf_integer(long, think,
603 current->dirty_paused_when == 0 ? 0 :
604 (long)(jiffies - current->dirty_paused_when) * 1000/HZ)
605 )
606 )
607
608 #else /* #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */
609
610 LTTNG_TRACEPOINT_EVENT_MAP(balance_dirty_pages,
611
612 writeback_balance_dirty_pages,
613
614 TP_PROTO(struct backing_dev_info *bdi,
615 unsigned long thresh,
616 unsigned long bg_thresh,
617 unsigned long dirty,
618 unsigned long bdi_thresh,
619 unsigned long bdi_dirty,
620 unsigned long dirty_ratelimit,
621 unsigned long task_ratelimit,
622 unsigned long dirtied,
623 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
624 unsigned long period,
625 #endif
626 long pause,
627 unsigned long start_time),
628
629 TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
630 dirty_ratelimit, task_ratelimit,
631 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
632 dirtied, period, pause, start_time
633 #else
634 dirtied, pause, start_time
635 #endif
636 ),
637
638 TP_FIELDS(
639 ctf_array_text(char, bdi, dev_name(bdi->dev), 32)
640 ctf_integer(unsigned long, limit, global_dirty_limit)
641 ctf_integer(unsigned long, setpoint,
642 (global_dirty_limit + (thresh + bg_thresh) / 2) / 2)
643 ctf_integer(unsigned long, dirty, dirty)
644 ctf_integer(unsigned long, bdi_setpoint,
645 ((global_dirty_limit + (thresh + bg_thresh) / 2) / 2) *
646 bdi_thresh / (thresh + 1))
647 ctf_integer(unsigned long, bdi_dirty, bdi_dirty)
648 ctf_integer(unsigned long, dirty_ratelimit,
649 KBps(dirty_ratelimit))
650 ctf_integer(unsigned long, task_ratelimit,
651 KBps(task_ratelimit))
652 ctf_integer(unsigned int, dirtied, dirtied)
653 ctf_integer(unsigned int, dirtied_pause,
654 current->nr_dirtied_pause)
655 ctf_integer(unsigned long, paused,
656 (jiffies - start_time) * 1000 / HZ)
657 ctf_integer(long, pause, pause * 1000 / HZ)
658 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
659 ctf_integer(unsigned long, period,
660 period * 1000 / HZ)
661 ctf_integer(long, think,
662 current->dirty_paused_when == 0 ? 0 :
663 (long)(jiffies - current->dirty_paused_when) * 1000/HZ)
664 #endif
665 )
666 )
667 #endif /* #else #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */
668
669 #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */
670
671 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
672 LTTNG_TRACEPOINT_EVENT(writeback_sb_inodes_requeue,
673
674 TP_PROTO(struct inode *inode),
675 TP_ARGS(inode),
676
677 TP_FIELDS(
678 ctf_array_text(char, name,
679 dev_name(lttng_inode_to_bdi(inode)->dev), 32)
680 ctf_integer(unsigned long, ino, inode->i_ino)
681 ctf_integer(unsigned long, state, inode->i_state)
682 ctf_integer(unsigned long, dirtied_when, inode->dirtied_when)
683 )
684 )
685 #endif
686
687 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
688 LTTNG_TRACEPOINT_EVENT_CLASS(writeback_congest_waited_template,
689
690 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
691
692 TP_ARGS(usec_timeout, usec_delayed),
693
694 TP_FIELDS(
695 ctf_integer(unsigned int, usec_timeout, usec_timeout)
696 ctf_integer(unsigned int, usec_delayed, usec_delayed)
697 )
698 )
699
700 LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_congest_waited_template, writeback_congestion_wait,
701
702 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
703
704 TP_ARGS(usec_timeout, usec_delayed)
705 )
706
707 LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_congest_waited_template, writeback_wait_iff_congested,
708
709 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
710
711 TP_ARGS(usec_timeout, usec_delayed)
712 )
713 #endif
714
715 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
716 LTTNG_TRACEPOINT_EVENT_CLASS(writeback_single_inode_template,
717
718 TP_PROTO(struct inode *inode,
719 struct writeback_control *wbc,
720 unsigned long nr_to_write
721 ),
722
723 TP_ARGS(inode, wbc, nr_to_write),
724
725 TP_FIELDS(
726 ctf_array_text(char, name,
727 dev_name(lttng_inode_to_bdi(inode)->dev), 32)
728 ctf_integer(unsigned long, ino, inode->i_ino)
729 ctf_integer(unsigned long, state, inode->i_state)
730 ctf_integer(unsigned long, dirtied_when, inode->dirtied_when)
731 ctf_integer(unsigned long, writeback_index,
732 inode->i_mapping->writeback_index)
733 ctf_integer(long, nr_to_write, nr_to_write)
734 ctf_integer(unsigned long, wrote,
735 nr_to_write - wbc->nr_to_write)
736 )
737 )
738
739 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
740 LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_single_inode_template, writeback_single_inode_requeue,
741 TP_PROTO(struct inode *inode,
742 struct writeback_control *wbc,
743 unsigned long nr_to_write),
744 TP_ARGS(inode, wbc, nr_to_write)
745 )
746 #endif
747
748 LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_single_inode_template, writeback_single_inode,
749 TP_PROTO(struct inode *inode,
750 struct writeback_control *wbc,
751 unsigned long nr_to_write),
752 TP_ARGS(inode, wbc, nr_to_write)
753 )
754 #endif
755
756 #endif /* LTTNG_TRACE_WRITEBACK_H */
757
758 /* This part must be outside protection */
759 #include <probes/define_trace.h>
This page took 0.044811 seconds and 4 git commands to generate.