X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=instrumentation%2Fevents%2Flttng-module%2Fwriteback.h;h=36b6c5e34e2210e6ef29ad2fe971c9e7c5e6abcf;hb=ee33121c8ff05b44ab6e3d61800701acc5ead2b0;hp=111decf069aab41ad20de8c77c402b5d547a6264;hpb=aa634cd14131f2d4f0f53af68fc534c476de228a;p=lttng-modules.git diff --git a/instrumentation/events/lttng-module/writeback.h b/instrumentation/events/lttng-module/writeback.h index 111decf0..36b6c5e3 100644 --- a/instrumentation/events/lttng-module/writeback.h +++ b/instrumentation/events/lttng-module/writeback.h @@ -12,6 +12,8 @@ #ifndef _TRACE_WRITEBACK_DEF_ #define _TRACE_WRITEBACK_DEF_ + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)) static inline struct backing_dev_info *inode_to_bdi(struct inode *inode) { struct super_block *sb = inode->i_sb; @@ -21,8 +23,11 @@ static inline struct backing_dev_info *inode_to_bdi(struct inode *inode) return sb->s_bdi; } +#endif /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)) */ + #endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)) #define show_inode_state(state) \ __print_flags(state, "|", \ {I_DIRTY_SYNC, "I_DIRTY_SYNC"}, \ @@ -33,22 +38,110 @@ static inline struct backing_dev_info *inode_to_bdi(struct inode *inode) {I_FREEING, "I_FREEING"}, \ {I_CLEAR, "I_CLEAR"}, \ {I_SYNC, "I_SYNC"}, \ + {I_DIRTY_TIME, "I_DIRTY_TIME"}, \ + {I_DIRTY_TIME_EXPIRED, "I_DIRTY_TIME_EXPIRED"}, \ {I_REFERENCED, "I_REFERENCED"} \ ) +#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)) */ +#define show_inode_state(state) \ + __print_flags(state, "|", \ + {I_DIRTY_SYNC, "I_DIRTY_SYNC"}, \ + {I_DIRTY_DATASYNC, "I_DIRTY_DATASYNC"}, \ + {I_DIRTY_PAGES, "I_DIRTY_PAGES"}, \ + {I_NEW, "I_NEW"}, \ + {I_WILL_FREE, "I_WILL_FREE"}, \ + {I_FREEING, "I_FREEING"}, \ + {I_CLEAR, "I_CLEAR"}, \ + {I_SYNC, "I_SYNC"}, \ + {I_REFERENCED, "I_REFERENCED"} \ + ) +#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)) */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) -#define WB_WORK_REASON \ - {WB_REASON_BACKGROUND, "background"}, \ - {WB_REASON_TRY_TO_FREE_PAGES, "try_to_free_pages"}, \ - {WB_REASON_SYNC, "sync"}, \ - {WB_REASON_PERIODIC, "periodic"}, \ - {WB_REASON_LAPTOP_TIMER, "laptop_timer"}, \ - {WB_REASON_FREE_MORE_MEM, "free_more_memory"}, \ - {WB_REASON_FS_FREE_SPACE, "fs_free_space"}, \ - {WB_REASON_FORKER_THREAD, "forker_thread"} -#endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)) + +LTTNG_TRACEPOINT_EVENT(writeback_dirty_page, + TP_PROTO(struct page *page, struct address_space *mapping), + TP_ARGS(page, mapping), + TP_STRUCT__entry ( + __array_text(char, name, 32) + __field(unsigned long, ino) + __field(pgoff_t, index) + ), + TP_fast_assign( + tp_memcpy(name, + mapping ? dev_name(inode_to_bdi(mapping->host)->dev) : "(unknown)", 32) + tp_assign(ino, mapping ? mapping->host->i_ino : 0) + tp_assign(index, page->index) + ), + TP_printk("bdi %s: ino=%lu index=%lu", + __entry->name, + __entry->ino, + __entry->index + ) +) + +LTTNG_TRACEPOINT_EVENT_CLASS(writeback_dirty_inode_template, + TP_PROTO(struct inode *inode, int flags), + TP_ARGS(inode, flags), + TP_STRUCT__entry ( + __array_text(char, name, 32) + __field(unsigned long, ino) + __field(unsigned long, state) + __field(unsigned long, flags) + ), + TP_fast_assign( + /* may be called for files on pseudo FSes w/ unregistered bdi */ + tp_memcpy(name, + inode_to_bdi(inode)->dev ? + dev_name(inode_to_bdi(inode)->dev) : "(unknown)", 32) + tp_assign(ino, inode->i_ino) + tp_assign(state, inode->i_state) + tp_assign(flags, flags) + ), + TP_printk("bdi %s: ino=%lu flags=%s", + __entry->name, + __entry->ino, + show_inode_state(__entry->flags) + ) +) +#define LTTNG_TRACEPOINT_EVENT_WRITEBACK_DIRTY_INODE_TEMPLATE(name) \ +LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_dirty_inode_template, name, \ + TP_PROTO(struct inode *inode, int flags), \ + TP_ARGS(inode, flags)) +LTTNG_TRACEPOINT_EVENT_WRITEBACK_DIRTY_INODE_TEMPLATE(writeback_dirty_inode_start) +LTTNG_TRACEPOINT_EVENT_WRITEBACK_DIRTY_INODE_TEMPLATE(writeback_dirty_inode) +LTTNG_TRACEPOINT_EVENT_WRITEBACK_DIRTY_INODE_TEMPLATE(writeback_mark_inode_dirty) + +LTTNG_TRACEPOINT_EVENT_CLASS(writeback_write_inode_template, + TP_PROTO(struct inode *inode, struct writeback_control *wbc), + TP_ARGS(inode, wbc), + TP_STRUCT__entry ( + __array_text(char, name, 32) + __field(unsigned long, ino) + __field(int, sync_mode) + ), + TP_fast_assign( + tp_memcpy(name, + dev_name(inode_to_bdi(inode)->dev), 32) + tp_assign(ino, inode->i_ino) + tp_assign(sync_mode, wbc->sync_mode) + ), + TP_printk("bdi %s: ino=%lu sync_mode=%d", + __entry->name, + __entry->ino, + __entry->sync_mode + ) +) + +#define LTTNG_TRACEPOINT_EVENT_WRITEBACK_WRITE_INODE(name) \ +LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_write_inode_template, name, \ + TP_PROTO(struct inode *inode, struct writeback_control *wbc), \ + TP_ARGS(inode, wbc)) +LTTNG_TRACEPOINT_EVENT_WRITEBACK_WRITE_INODE(writeback_write_inode_start) +LTTNG_TRACEPOINT_EVENT_WRITEBACK_WRITE_INODE(writeback_write_inode) + +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) LTTNG_TRACEPOINT_EVENT(writeback_dirty_page, TP_PROTO(struct page *page, struct address_space *mapping), TP_ARGS(page, mapping), @@ -126,13 +219,44 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_write_inode_template, name, \ TP_ARGS(inode, wbc)) LTTNG_TRACEPOINT_EVENT_WRITEBACK_WRITE_INODE(writeback_write_inode_start) LTTNG_TRACEPOINT_EVENT_WRITEBACK_WRITE_INODE(writeback_write_inode) + #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) + +LTTNG_TRACEPOINT_EVENT_CLASS(writeback_work_class, + TP_PROTO(struct bdi_writeback *wb, struct wb_writeback_work *work), + TP_ARGS(wb, work), + TP_FIELDS( + ctf_array_text(char, name, wb->bdi->dev ? dev_name(wb->bdi->dev) : + "(unknown)", 32) + ) +) + +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)) + LTTNG_TRACEPOINT_EVENT_CLASS(writeback_work_class, TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), TP_ARGS(bdi, work), TP_STRUCT__entry( - __array(char, name, 32) + __array_text(char, name, 32) + ), + TP_fast_assign( + tp_memcpy(name, bdi->dev ? dev_name(bdi->dev) : + "(unknown)", 32) + ), + TP_printk("bdi %s", + __entry->name + ) +) + +#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)) */ + +LTTNG_TRACEPOINT_EVENT_CLASS(writeback_work_class, + TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), + TP_ARGS(bdi, work), + TP_STRUCT__entry( + __array_text(char, name, 32) ), TP_fast_assign( tp_memcpy(name, dev_name(bdi->dev ? bdi->dev : @@ -142,10 +266,25 @@ LTTNG_TRACEPOINT_EVENT_CLASS(writeback_work_class, __entry->name ) ) + +#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)) */ + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) + +#define LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(name) \ +LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_work_class, name, \ + TP_PROTO(struct bdi_writeback *wb, struct wb_writeback_work *work), \ + TP_ARGS(wb, work)) + +#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */ + #define LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(name) \ LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_work_class, name, \ TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \ TP_ARGS(bdi, work)) + +#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */ + LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(writeback_nothread) LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(writeback_queue) LTTNG_TRACEPOINT_EVENT_WRITEBACK_WORK_INSTANCE(writeback_exec) @@ -167,11 +306,44 @@ LTTNG_TRACEPOINT_EVENT(writeback_pages_written, TP_printk("%ld", __entry->pages) ) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) + +LTTNG_TRACEPOINT_EVENT_CLASS(writeback_class, + TP_PROTO(struct bdi_writeback *wb), + TP_ARGS(wb), + TP_FIELDS( + ctf_array_text(char, name, + dev_name(wb->bdi->dev), 32) + ) +) + +#undef DEFINE_WRITEBACK_EVENT +#define DEFINE_WRITEBACK_EVENT(name) \ +LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_class, name, \ + TP_PROTO(struct bdi_writeback *wb), \ + TP_ARGS(wb)) + +#define DEFINE_WRITEBACK_EVENT_MAP(name, map) \ +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(writeback_class, name, map, \ + TP_PROTO(struct bdi_writeback *wb), \ + TP_ARGS(wb)) + +LTTNG_TRACEPOINT_EVENT(writeback_bdi_register, + TP_PROTO(struct backing_dev_info *bdi), + TP_ARGS(bdi), + TP_FIELDS( + ctf_array_text(char, name, + dev_name(bdi->dev), 32) + ) +) + +#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */ + LTTNG_TRACEPOINT_EVENT_CLASS(writeback_class, TP_PROTO(struct backing_dev_info *bdi), TP_ARGS(bdi), TP_STRUCT__entry( - __array(char, name, 32) + __array_text(char, name, 32) ), TP_fast_assign( tp_memcpy(name, dev_name(bdi->dev), 32) @@ -180,6 +352,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(writeback_class, __entry->name ) ) + #undef DEFINE_WRITEBACK_EVENT #define DEFINE_WRITEBACK_EVENT(name) \ LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_class, name, \ @@ -191,13 +364,16 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(writeback_class, name, map, \ TP_PROTO(struct backing_dev_info *bdi), \ TP_ARGS(bdi)) +DEFINE_WRITEBACK_EVENT(writeback_bdi_register) + +#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */ + DEFINE_WRITEBACK_EVENT(writeback_nowork) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) DEFINE_WRITEBACK_EVENT(writeback_wake_background) #endif DEFINE_WRITEBACK_EVENT(writeback_wake_thread) DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread) -DEFINE_WRITEBACK_EVENT(writeback_bdi_register) DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister) DEFINE_WRITEBACK_EVENT(writeback_thread_start) DEFINE_WRITEBACK_EVENT(writeback_thread_stop) @@ -234,7 +410,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(writeback_wbc_class, TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), TP_ARGS(wbc, bdi), TP_STRUCT__entry( - __array(char, name, 32) + __array_text(char, name, 32) __field(long, nr_to_write) __field(long, pages_skipped) __field(int, sync_mode) @@ -407,6 +583,79 @@ LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state, #define KBps(x) ((x) << (PAGE_SHIFT - 10)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) + +LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit, + + writeback_bdi_dirty_ratelimit, + + TP_PROTO(struct bdi_writeback *wb, + unsigned long dirty_rate, + unsigned long task_ratelimit), + + TP_ARGS(wb, dirty_rate, task_ratelimit), + + TP_FIELDS( + ctf_array_text(char, bdi, dev_name(wb->bdi->dev), 32) + ctf_integer(unsigned long, write_bw, KBps(wb->bdi->wb.write_bandwidth)) + ctf_integer(unsigned long, avg_write_bw, KBps(wb->bdi->wb.avg_write_bandwidth)) + ctf_integer(unsigned long, dirty_rate, KBps(dirty_rate)) + ctf_integer(unsigned long, dirty_ratelimit, KBps(wb->bdi->wb.dirty_ratelimit)) + ctf_integer(unsigned long, task_ratelimit, KBps(task_ratelimit)) + ctf_integer(unsigned long, balanced_dirty_ratelimit, + KBps(wb->bdi->wb.balanced_dirty_ratelimit)) + ) +) + +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) + +LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit, + + writeback_bdi_dirty_ratelimit, + + TP_PROTO(struct backing_dev_info *bdi, + unsigned long dirty_rate, + unsigned long task_ratelimit), + + TP_ARGS(bdi, dirty_rate, task_ratelimit), + + TP_STRUCT__entry( + __array(char, bdi, 32) + __field(unsigned long, write_bw) + __field(unsigned long, avg_write_bw) + __field(unsigned long, dirty_rate) + __field(unsigned long, dirty_ratelimit) + __field(unsigned long, task_ratelimit) + __field(unsigned long, balanced_dirty_ratelimit) + ), + + TP_fast_assign( + tp_memcpy(bdi, dev_name(bdi->dev), 32) + tp_assign(write_bw, KBps(bdi->wb.write_bandwidth)) + tp_assign(avg_write_bw, KBps(bdi->wb.avg_write_bandwidth)) + tp_assign(dirty_rate, KBps(dirty_rate)) + tp_assign(dirty_ratelimit, KBps(bdi->wb.dirty_ratelimit)) + tp_assign(task_ratelimit, KBps(task_ratelimit)) + tp_assign(balanced_dirty_ratelimit, + KBps(bdi->wb.balanced_dirty_ratelimit)) + ), + + TP_printk("bdi %s: " + "write_bw=%lu awrite_bw=%lu dirty_rate=%lu " + "dirty_ratelimit=%lu task_ratelimit=%lu " + "balanced_dirty_ratelimit=%lu", + __entry->bdi, + __entry->write_bw, /* write bandwidth */ + __entry->avg_write_bw, /* avg write bandwidth */ + __entry->dirty_rate, /* bdi dirty rate */ + __entry->dirty_ratelimit, /* base ratelimit */ + __entry->task_ratelimit, /* ratelimit with position control */ + __entry->balanced_dirty_ratelimit /* the balanced ratelimit */ + ) +) + +#else + LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit, writeback_bdi_dirty_ratelimit, @@ -452,6 +701,62 @@ LTTNG_TRACEPOINT_EVENT_MAP(bdi_dirty_ratelimit, ) ) +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) + +LTTNG_TRACEPOINT_EVENT_MAP(balance_dirty_pages, + + writeback_balance_dirty_pages, + + TP_PROTO(struct bdi_writeback *wb, + unsigned long thresh, + unsigned long bg_thresh, + unsigned long dirty, + unsigned long bdi_thresh, + unsigned long bdi_dirty, + unsigned long dirty_ratelimit, + unsigned long task_ratelimit, + unsigned long dirtied, + unsigned long period, + long pause, + unsigned long start_time), + + TP_ARGS(wb, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty, + dirty_ratelimit, task_ratelimit, + dirtied, period, pause, start_time + ), + + TP_FIELDS( + ctf_array_text(char, bdi, dev_name(wb->bdi->dev), 32) + ctf_integer(unsigned long, limit, global_dirty_limit) + ctf_integer(unsigned long, setpoint, + (global_dirty_limit + (thresh + bg_thresh) / 2) / 2) + ctf_integer(unsigned long, dirty, dirty) + ctf_integer(unsigned long, bdi_setpoint, + ((global_dirty_limit + (thresh + bg_thresh) / 2) / 2) * + bdi_thresh / (thresh + 1)) + ctf_integer(unsigned long, bdi_dirty, bdi_dirty) + ctf_integer(unsigned long, dirty_ratelimit, + KBps(dirty_ratelimit)) + ctf_integer(unsigned long, task_ratelimit, + KBps(task_ratelimit)) + ctf_integer(unsigned int, dirtied, dirtied) + ctf_integer(unsigned int, dirtied_pause, + current->nr_dirtied_pause) + ctf_integer(unsigned long, paused, + (jiffies - start_time) * 1000 / HZ) + ctf_integer(long, pause, pause * 1000 / HZ) + ctf_integer(unsigned long, period, + period * 1000 / HZ) + ctf_integer(long, think, + current->dirty_paused_when == 0 ? 0 : + (long)(jiffies - current->dirty_paused_when) * 1000/HZ) + ) +) + +#else /* #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */ + LTTNG_TRACEPOINT_EVENT_MAP(balance_dirty_pages, writeback_balance_dirty_pages, @@ -565,7 +870,9 @@ LTTNG_TRACEPOINT_EVENT_MAP(balance_dirty_pages, ) #endif ) -#endif +#endif /* #else #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */ + +#endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) LTTNG_TRACEPOINT_EVENT(writeback_sb_inodes_requeue, @@ -574,7 +881,7 @@ LTTNG_TRACEPOINT_EVENT(writeback_sb_inodes_requeue, TP_ARGS(inode), TP_STRUCT__entry( - __array(char, name, 32) + __array_text(char, name, 32) __field(unsigned long, ino) __field(unsigned long, state) __field(unsigned long, dirtied_when) @@ -645,7 +952,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(writeback_single_inode_template, TP_ARGS(inode, wbc, nr_to_write), TP_STRUCT__entry( - __array(char, name, 32) + __array_text(char, name, 32) __field(unsigned long, ino) __field(unsigned long, state) __field(unsigned long, dirtied_when)