1455b2864SDave Chinner #undef TRACE_SYSTEM 2455b2864SDave Chinner #define TRACE_SYSTEM writeback 3455b2864SDave Chinner 4455b2864SDave Chinner #if !defined(_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ) 5455b2864SDave Chinner #define _TRACE_WRITEBACK_H 6455b2864SDave Chinner 7455b2864SDave Chinner #include <linux/backing-dev.h> 896dccab1SRandy Dunlap #include <linux/device.h> 9455b2864SDave Chinner #include <linux/writeback.h> 10455b2864SDave Chinner 11251d6a47SWu Fengguang #define show_inode_state(state) \ 12251d6a47SWu Fengguang __print_flags(state, "|", \ 13251d6a47SWu Fengguang {I_DIRTY_SYNC, "I_DIRTY_SYNC"}, \ 14251d6a47SWu Fengguang {I_DIRTY_DATASYNC, "I_DIRTY_DATASYNC"}, \ 15251d6a47SWu Fengguang {I_DIRTY_PAGES, "I_DIRTY_PAGES"}, \ 16251d6a47SWu Fengguang {I_NEW, "I_NEW"}, \ 17251d6a47SWu Fengguang {I_WILL_FREE, "I_WILL_FREE"}, \ 18251d6a47SWu Fengguang {I_FREEING, "I_FREEING"}, \ 19251d6a47SWu Fengguang {I_CLEAR, "I_CLEAR"}, \ 20251d6a47SWu Fengguang {I_SYNC, "I_SYNC"}, \ 21251d6a47SWu Fengguang {I_REFERENCED, "I_REFERENCED"} \ 22251d6a47SWu Fengguang ) 23251d6a47SWu Fengguang 24455b2864SDave Chinner struct wb_writeback_work; 25455b2864SDave Chinner 26455b2864SDave Chinner DECLARE_EVENT_CLASS(writeback_work_class, 27455b2864SDave Chinner TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), 28455b2864SDave Chinner TP_ARGS(bdi, work), 29455b2864SDave Chinner TP_STRUCT__entry( 30455b2864SDave Chinner __array(char, name, 32) 31455b2864SDave Chinner __field(long, nr_pages) 32455b2864SDave Chinner __field(dev_t, sb_dev) 33455b2864SDave Chinner __field(int, sync_mode) 34455b2864SDave Chinner __field(int, for_kupdate) 35455b2864SDave Chinner __field(int, range_cyclic) 36455b2864SDave Chinner __field(int, for_background) 37455b2864SDave Chinner ), 38455b2864SDave Chinner TP_fast_assign( 39455b2864SDave Chinner strncpy(__entry->name, dev_name(bdi->dev), 32); 40455b2864SDave Chinner __entry->nr_pages = work->nr_pages; 41455b2864SDave Chinner __entry->sb_dev = work->sb ? work->sb->s_dev : 0; 42455b2864SDave Chinner __entry->sync_mode = work->sync_mode; 43455b2864SDave Chinner __entry->for_kupdate = work->for_kupdate; 44455b2864SDave Chinner __entry->range_cyclic = work->range_cyclic; 45455b2864SDave Chinner __entry->for_background = work->for_background; 46455b2864SDave Chinner ), 47455b2864SDave Chinner TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d " 48455b2864SDave Chinner "kupdate=%d range_cyclic=%d background=%d", 49455b2864SDave Chinner __entry->name, 50455b2864SDave Chinner MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev), 51455b2864SDave Chinner __entry->nr_pages, 52455b2864SDave Chinner __entry->sync_mode, 53455b2864SDave Chinner __entry->for_kupdate, 54455b2864SDave Chinner __entry->range_cyclic, 55455b2864SDave Chinner __entry->for_background 56455b2864SDave Chinner ) 57455b2864SDave Chinner ); 58455b2864SDave Chinner #define DEFINE_WRITEBACK_WORK_EVENT(name) \ 59455b2864SDave Chinner DEFINE_EVENT(writeback_work_class, name, \ 60455b2864SDave Chinner TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \ 61455b2864SDave Chinner TP_ARGS(bdi, work)) 62455b2864SDave Chinner DEFINE_WRITEBACK_WORK_EVENT(writeback_nothread); 63455b2864SDave Chinner DEFINE_WRITEBACK_WORK_EVENT(writeback_queue); 64455b2864SDave Chinner DEFINE_WRITEBACK_WORK_EVENT(writeback_exec); 65455b2864SDave Chinner 66455b2864SDave Chinner TRACE_EVENT(writeback_pages_written, 67455b2864SDave Chinner TP_PROTO(long pages_written), 68455b2864SDave Chinner TP_ARGS(pages_written), 69455b2864SDave Chinner TP_STRUCT__entry( 70455b2864SDave Chinner __field(long, pages) 71455b2864SDave Chinner ), 72455b2864SDave Chinner TP_fast_assign( 73455b2864SDave Chinner __entry->pages = pages_written; 74455b2864SDave Chinner ), 75455b2864SDave Chinner TP_printk("%ld", __entry->pages) 76455b2864SDave Chinner ); 77455b2864SDave Chinner 78455b2864SDave Chinner DECLARE_EVENT_CLASS(writeback_class, 79455b2864SDave Chinner TP_PROTO(struct backing_dev_info *bdi), 80455b2864SDave Chinner TP_ARGS(bdi), 81455b2864SDave Chinner TP_STRUCT__entry( 82455b2864SDave Chinner __array(char, name, 32) 83455b2864SDave Chinner ), 84455b2864SDave Chinner TP_fast_assign( 85455b2864SDave Chinner strncpy(__entry->name, dev_name(bdi->dev), 32); 86455b2864SDave Chinner ), 87455b2864SDave Chinner TP_printk("bdi %s", 88455b2864SDave Chinner __entry->name 89455b2864SDave Chinner ) 90455b2864SDave Chinner ); 91455b2864SDave Chinner #define DEFINE_WRITEBACK_EVENT(name) \ 92455b2864SDave Chinner DEFINE_EVENT(writeback_class, name, \ 93455b2864SDave Chinner TP_PROTO(struct backing_dev_info *bdi), \ 94455b2864SDave Chinner TP_ARGS(bdi)) 95455b2864SDave Chinner 96455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_nowork); 9771927e84SWu Fengguang DEFINE_WRITEBACK_EVENT(writeback_wake_background); 9860332023SArtem Bityutskiy DEFINE_WRITEBACK_EVENT(writeback_wake_thread); 9960332023SArtem Bityutskiy DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread); 100455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_bdi_register); 101455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister); 102455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_thread_start); 103455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_thread_stop); 104455b2864SDave Chinner 105028c2dd1SDave Chinner DECLARE_EVENT_CLASS(wbc_class, 106028c2dd1SDave Chinner TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), 107028c2dd1SDave Chinner TP_ARGS(wbc, bdi), 108028c2dd1SDave Chinner TP_STRUCT__entry( 109028c2dd1SDave Chinner __array(char, name, 32) 110028c2dd1SDave Chinner __field(long, nr_to_write) 111028c2dd1SDave Chinner __field(long, pages_skipped) 112028c2dd1SDave Chinner __field(int, sync_mode) 113028c2dd1SDave Chinner __field(int, for_kupdate) 114028c2dd1SDave Chinner __field(int, for_background) 115028c2dd1SDave Chinner __field(int, for_reclaim) 116028c2dd1SDave Chinner __field(int, range_cyclic) 117028c2dd1SDave Chinner __field(unsigned long, older_than_this) 118028c2dd1SDave Chinner __field(long, range_start) 119028c2dd1SDave Chinner __field(long, range_end) 120028c2dd1SDave Chinner ), 121028c2dd1SDave Chinner 122028c2dd1SDave Chinner TP_fast_assign( 123028c2dd1SDave Chinner strncpy(__entry->name, dev_name(bdi->dev), 32); 124028c2dd1SDave Chinner __entry->nr_to_write = wbc->nr_to_write; 125028c2dd1SDave Chinner __entry->pages_skipped = wbc->pages_skipped; 126028c2dd1SDave Chinner __entry->sync_mode = wbc->sync_mode; 127028c2dd1SDave Chinner __entry->for_kupdate = wbc->for_kupdate; 128028c2dd1SDave Chinner __entry->for_background = wbc->for_background; 129028c2dd1SDave Chinner __entry->for_reclaim = wbc->for_reclaim; 130028c2dd1SDave Chinner __entry->range_cyclic = wbc->range_cyclic; 131028c2dd1SDave Chinner __entry->older_than_this = wbc->older_than_this ? 132028c2dd1SDave Chinner *wbc->older_than_this : 0; 133028c2dd1SDave Chinner __entry->range_start = (long)wbc->range_start; 134028c2dd1SDave Chinner __entry->range_end = (long)wbc->range_end; 135028c2dd1SDave Chinner ), 136028c2dd1SDave Chinner 137028c2dd1SDave Chinner TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d " 138b7a2441fSWu Fengguang "bgrd=%d reclm=%d cyclic=%d older=0x%lx " 139028c2dd1SDave Chinner "start=0x%lx end=0x%lx", 140028c2dd1SDave Chinner __entry->name, 141028c2dd1SDave Chinner __entry->nr_to_write, 142028c2dd1SDave Chinner __entry->pages_skipped, 143028c2dd1SDave Chinner __entry->sync_mode, 144028c2dd1SDave Chinner __entry->for_kupdate, 145028c2dd1SDave Chinner __entry->for_background, 146028c2dd1SDave Chinner __entry->for_reclaim, 147028c2dd1SDave Chinner __entry->range_cyclic, 148028c2dd1SDave Chinner __entry->older_than_this, 149028c2dd1SDave Chinner __entry->range_start, 150028c2dd1SDave Chinner __entry->range_end) 151028c2dd1SDave Chinner ) 152028c2dd1SDave Chinner 153028c2dd1SDave Chinner #define DEFINE_WBC_EVENT(name) \ 154028c2dd1SDave Chinner DEFINE_EVENT(wbc_class, name, \ 155028c2dd1SDave Chinner TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \ 156028c2dd1SDave Chinner TP_ARGS(wbc, bdi)) 157028c2dd1SDave Chinner DEFINE_WBC_EVENT(wbc_writeback_start); 158028c2dd1SDave Chinner DEFINE_WBC_EVENT(wbc_writeback_written); 159028c2dd1SDave Chinner DEFINE_WBC_EVENT(wbc_writeback_wait); 160028c2dd1SDave Chinner DEFINE_WBC_EVENT(wbc_balance_dirty_start); 161028c2dd1SDave Chinner DEFINE_WBC_EVENT(wbc_balance_dirty_written); 162028c2dd1SDave Chinner DEFINE_WBC_EVENT(wbc_balance_dirty_wait); 1639e094383SDave Chinner DEFINE_WBC_EVENT(wbc_writepage); 164028c2dd1SDave Chinner 165*e84d0a4fSWu Fengguang TRACE_EVENT(writeback_queue_io, 166*e84d0a4fSWu Fengguang TP_PROTO(struct bdi_writeback *wb, 167*e84d0a4fSWu Fengguang unsigned long *older_than_this, 168*e84d0a4fSWu Fengguang int moved), 169*e84d0a4fSWu Fengguang TP_ARGS(wb, older_than_this, moved), 170*e84d0a4fSWu Fengguang TP_STRUCT__entry( 171*e84d0a4fSWu Fengguang __array(char, name, 32) 172*e84d0a4fSWu Fengguang __field(unsigned long, older) 173*e84d0a4fSWu Fengguang __field(long, age) 174*e84d0a4fSWu Fengguang __field(int, moved) 175*e84d0a4fSWu Fengguang ), 176*e84d0a4fSWu Fengguang TP_fast_assign( 177*e84d0a4fSWu Fengguang strncpy(__entry->name, dev_name(wb->bdi->dev), 32); 178*e84d0a4fSWu Fengguang __entry->older = older_than_this ? *older_than_this : 0; 179*e84d0a4fSWu Fengguang __entry->age = older_than_this ? 180*e84d0a4fSWu Fengguang (jiffies - *older_than_this) * 1000 / HZ : -1; 181*e84d0a4fSWu Fengguang __entry->moved = moved; 182*e84d0a4fSWu Fengguang ), 183*e84d0a4fSWu Fengguang TP_printk("bdi %s: older=%lu age=%ld enqueue=%d", 184*e84d0a4fSWu Fengguang __entry->name, 185*e84d0a4fSWu Fengguang __entry->older, /* older_than_this in jiffies */ 186*e84d0a4fSWu Fengguang __entry->age, /* older_than_this in relative milliseconds */ 187*e84d0a4fSWu Fengguang __entry->moved) 188*e84d0a4fSWu Fengguang ); 189*e84d0a4fSWu Fengguang 19052bb9198SMel Gorman DECLARE_EVENT_CLASS(writeback_congest_waited_template, 19152bb9198SMel Gorman 19252bb9198SMel Gorman TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed), 19352bb9198SMel Gorman 19452bb9198SMel Gorman TP_ARGS(usec_timeout, usec_delayed), 19552bb9198SMel Gorman 19652bb9198SMel Gorman TP_STRUCT__entry( 19752bb9198SMel Gorman __field( unsigned int, usec_timeout ) 19852bb9198SMel Gorman __field( unsigned int, usec_delayed ) 19952bb9198SMel Gorman ), 20052bb9198SMel Gorman 20152bb9198SMel Gorman TP_fast_assign( 20252bb9198SMel Gorman __entry->usec_timeout = usec_timeout; 20352bb9198SMel Gorman __entry->usec_delayed = usec_delayed; 20452bb9198SMel Gorman ), 20552bb9198SMel Gorman 20652bb9198SMel Gorman TP_printk("usec_timeout=%u usec_delayed=%u", 20752bb9198SMel Gorman __entry->usec_timeout, 20852bb9198SMel Gorman __entry->usec_delayed) 20952bb9198SMel Gorman ); 21052bb9198SMel Gorman 21152bb9198SMel Gorman DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait, 21252bb9198SMel Gorman 21352bb9198SMel Gorman TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed), 21452bb9198SMel Gorman 21552bb9198SMel Gorman TP_ARGS(usec_timeout, usec_delayed) 21652bb9198SMel Gorman ); 21752bb9198SMel Gorman 2180e093d99SMel Gorman DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested, 2190e093d99SMel Gorman 2200e093d99SMel Gorman TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed), 2210e093d99SMel Gorman 2220e093d99SMel Gorman TP_ARGS(usec_timeout, usec_delayed) 2230e093d99SMel Gorman ); 2240e093d99SMel Gorman 225251d6a47SWu Fengguang DECLARE_EVENT_CLASS(writeback_single_inode_template, 226251d6a47SWu Fengguang 227251d6a47SWu Fengguang TP_PROTO(struct inode *inode, 228251d6a47SWu Fengguang struct writeback_control *wbc, 229251d6a47SWu Fengguang unsigned long nr_to_write 230251d6a47SWu Fengguang ), 231251d6a47SWu Fengguang 232251d6a47SWu Fengguang TP_ARGS(inode, wbc, nr_to_write), 233251d6a47SWu Fengguang 234251d6a47SWu Fengguang TP_STRUCT__entry( 235251d6a47SWu Fengguang __array(char, name, 32) 236251d6a47SWu Fengguang __field(unsigned long, ino) 237251d6a47SWu Fengguang __field(unsigned long, state) 238251d6a47SWu Fengguang __field(unsigned long, age) 239251d6a47SWu Fengguang __field(unsigned long, writeback_index) 240251d6a47SWu Fengguang __field(long, nr_to_write) 241251d6a47SWu Fengguang __field(unsigned long, wrote) 242251d6a47SWu Fengguang ), 243251d6a47SWu Fengguang 244251d6a47SWu Fengguang TP_fast_assign( 245251d6a47SWu Fengguang strncpy(__entry->name, 246251d6a47SWu Fengguang dev_name(inode->i_mapping->backing_dev_info->dev), 32); 247251d6a47SWu Fengguang __entry->ino = inode->i_ino; 248251d6a47SWu Fengguang __entry->state = inode->i_state; 249251d6a47SWu Fengguang __entry->age = (jiffies - inode->dirtied_when) * 250251d6a47SWu Fengguang 1000 / HZ; 251251d6a47SWu Fengguang __entry->writeback_index = inode->i_mapping->writeback_index; 252251d6a47SWu Fengguang __entry->nr_to_write = nr_to_write; 253251d6a47SWu Fengguang __entry->wrote = nr_to_write - wbc->nr_to_write; 254251d6a47SWu Fengguang ), 255251d6a47SWu Fengguang 256251d6a47SWu Fengguang TP_printk("bdi %s: ino=%lu state=%s age=%lu " 257251d6a47SWu Fengguang "index=%lu to_write=%ld wrote=%lu", 258251d6a47SWu Fengguang __entry->name, 259251d6a47SWu Fengguang __entry->ino, 260251d6a47SWu Fengguang show_inode_state(__entry->state), 261251d6a47SWu Fengguang __entry->age, 262251d6a47SWu Fengguang __entry->writeback_index, 263251d6a47SWu Fengguang __entry->nr_to_write, 264251d6a47SWu Fengguang __entry->wrote 265251d6a47SWu Fengguang ) 266251d6a47SWu Fengguang ); 267251d6a47SWu Fengguang 268251d6a47SWu Fengguang DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode_requeue, 269251d6a47SWu Fengguang TP_PROTO(struct inode *inode, 270251d6a47SWu Fengguang struct writeback_control *wbc, 271251d6a47SWu Fengguang unsigned long nr_to_write), 272251d6a47SWu Fengguang TP_ARGS(inode, wbc, nr_to_write) 273251d6a47SWu Fengguang ); 274251d6a47SWu Fengguang 275251d6a47SWu Fengguang DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode, 276251d6a47SWu Fengguang TP_PROTO(struct inode *inode, 277251d6a47SWu Fengguang struct writeback_control *wbc, 278251d6a47SWu Fengguang unsigned long nr_to_write), 279251d6a47SWu Fengguang TP_ARGS(inode, wbc, nr_to_write) 280251d6a47SWu Fengguang ); 281251d6a47SWu Fengguang 282455b2864SDave Chinner #endif /* _TRACE_WRITEBACK_H */ 283455b2864SDave Chinner 284455b2864SDave Chinner /* This part must be outside protection */ 285455b2864SDave Chinner #include <trace/define_trace.h> 286