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 7f479447aSSteven Rostedt (Red Hat) #include <linux/tracepoint.h> 8455b2864SDave Chinner #include <linux/backing-dev.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"}, \ 210ae45f63STheodore Ts'o {I_DIRTY_TIME, "I_DIRTY_TIME"}, \ 220ae45f63STheodore Ts'o {I_DIRTY_TIME_EXPIRED, "I_DIRTY_TIME_EXPIRED"}, \ 23251d6a47SWu Fengguang {I_REFERENCED, "I_REFERENCED"} \ 24251d6a47SWu Fengguang ) 25251d6a47SWu Fengguang 26*91df6089SSteven Rostedt (Red Hat) /* enums need to be exported to user space */ 27*91df6089SSteven Rostedt (Red Hat) #undef EM 28*91df6089SSteven Rostedt (Red Hat) #undef EMe 29*91df6089SSteven Rostedt (Red Hat) #define EM(a,b) TRACE_DEFINE_ENUM(a); 30*91df6089SSteven Rostedt (Red Hat) #define EMe(a,b) TRACE_DEFINE_ENUM(a); 31*91df6089SSteven Rostedt (Red Hat) 32b3bba872SWu Fengguang #define WB_WORK_REASON \ 33*91df6089SSteven Rostedt (Red Hat) EM( WB_REASON_BACKGROUND, "background") \ 34*91df6089SSteven Rostedt (Red Hat) EM( WB_REASON_TRY_TO_FREE_PAGES, "try_to_free_pages") \ 35*91df6089SSteven Rostedt (Red Hat) EM( WB_REASON_SYNC, "sync") \ 36*91df6089SSteven Rostedt (Red Hat) EM( WB_REASON_PERIODIC, "periodic") \ 37*91df6089SSteven Rostedt (Red Hat) EM( WB_REASON_LAPTOP_TIMER, "laptop_timer") \ 38*91df6089SSteven Rostedt (Red Hat) EM( WB_REASON_FREE_MORE_MEM, "free_more_memory") \ 39*91df6089SSteven Rostedt (Red Hat) EM( WB_REASON_FS_FREE_SPACE, "fs_free_space") \ 40*91df6089SSteven Rostedt (Red Hat) EMe(WB_REASON_FORKER_THREAD, "forker_thread") 41*91df6089SSteven Rostedt (Red Hat) 42*91df6089SSteven Rostedt (Red Hat) WB_WORK_REASON 43*91df6089SSteven Rostedt (Red Hat) 44*91df6089SSteven Rostedt (Red Hat) /* 45*91df6089SSteven Rostedt (Red Hat) * Now redefine the EM() and EMe() macros to map the enums to the strings 46*91df6089SSteven Rostedt (Red Hat) * that will be printed in the output. 47*91df6089SSteven Rostedt (Red Hat) */ 48*91df6089SSteven Rostedt (Red Hat) #undef EM 49*91df6089SSteven Rostedt (Red Hat) #undef EMe 50*91df6089SSteven Rostedt (Red Hat) #define EM(a,b) { a, b }, 51*91df6089SSteven Rostedt (Red Hat) #define EMe(a,b) { a, b } 52b3bba872SWu Fengguang 53455b2864SDave Chinner struct wb_writeback_work; 54455b2864SDave Chinner 559fb0a7daSTejun Heo TRACE_EVENT(writeback_dirty_page, 569fb0a7daSTejun Heo 579fb0a7daSTejun Heo TP_PROTO(struct page *page, struct address_space *mapping), 589fb0a7daSTejun Heo 599fb0a7daSTejun Heo TP_ARGS(page, mapping), 609fb0a7daSTejun Heo 619fb0a7daSTejun Heo TP_STRUCT__entry ( 629fb0a7daSTejun Heo __array(char, name, 32) 639fb0a7daSTejun Heo __field(unsigned long, ino) 649fb0a7daSTejun Heo __field(pgoff_t, index) 659fb0a7daSTejun Heo ), 669fb0a7daSTejun Heo 679fb0a7daSTejun Heo TP_fast_assign( 689fb0a7daSTejun Heo strncpy(__entry->name, 69de1414a6SChristoph Hellwig mapping ? dev_name(inode_to_bdi(mapping->host)->dev) : "(unknown)", 32); 709fb0a7daSTejun Heo __entry->ino = mapping ? mapping->host->i_ino : 0; 719fb0a7daSTejun Heo __entry->index = page->index; 729fb0a7daSTejun Heo ), 739fb0a7daSTejun Heo 749fb0a7daSTejun Heo TP_printk("bdi %s: ino=%lu index=%lu", 759fb0a7daSTejun Heo __entry->name, 769fb0a7daSTejun Heo __entry->ino, 779fb0a7daSTejun Heo __entry->index 789fb0a7daSTejun Heo ) 799fb0a7daSTejun Heo ); 809fb0a7daSTejun Heo 819fb0a7daSTejun Heo DECLARE_EVENT_CLASS(writeback_dirty_inode_template, 829fb0a7daSTejun Heo 839fb0a7daSTejun Heo TP_PROTO(struct inode *inode, int flags), 849fb0a7daSTejun Heo 859fb0a7daSTejun Heo TP_ARGS(inode, flags), 869fb0a7daSTejun Heo 879fb0a7daSTejun Heo TP_STRUCT__entry ( 889fb0a7daSTejun Heo __array(char, name, 32) 899fb0a7daSTejun Heo __field(unsigned long, ino) 900ae45f63STheodore Ts'o __field(unsigned long, state) 919fb0a7daSTejun Heo __field(unsigned long, flags) 929fb0a7daSTejun Heo ), 939fb0a7daSTejun Heo 949fb0a7daSTejun Heo TP_fast_assign( 95de1414a6SChristoph Hellwig struct backing_dev_info *bdi = inode_to_bdi(inode); 969fb0a7daSTejun Heo 979fb0a7daSTejun Heo /* may be called for files on pseudo FSes w/ unregistered bdi */ 989fb0a7daSTejun Heo strncpy(__entry->name, 999fb0a7daSTejun Heo bdi->dev ? dev_name(bdi->dev) : "(unknown)", 32); 1009fb0a7daSTejun Heo __entry->ino = inode->i_ino; 1010ae45f63STheodore Ts'o __entry->state = inode->i_state; 1029fb0a7daSTejun Heo __entry->flags = flags; 1039fb0a7daSTejun Heo ), 1049fb0a7daSTejun Heo 1050ae45f63STheodore Ts'o TP_printk("bdi %s: ino=%lu state=%s flags=%s", 1069fb0a7daSTejun Heo __entry->name, 1079fb0a7daSTejun Heo __entry->ino, 1080ae45f63STheodore Ts'o show_inode_state(__entry->state), 1099fb0a7daSTejun Heo show_inode_state(__entry->flags) 1109fb0a7daSTejun Heo ) 1119fb0a7daSTejun Heo ); 1129fb0a7daSTejun Heo 1130ae45f63STheodore Ts'o DEFINE_EVENT(writeback_dirty_inode_template, writeback_mark_inode_dirty, 1140ae45f63STheodore Ts'o 1150ae45f63STheodore Ts'o TP_PROTO(struct inode *inode, int flags), 1160ae45f63STheodore Ts'o 1170ae45f63STheodore Ts'o TP_ARGS(inode, flags) 1180ae45f63STheodore Ts'o ); 1190ae45f63STheodore Ts'o 1209fb0a7daSTejun Heo DEFINE_EVENT(writeback_dirty_inode_template, writeback_dirty_inode_start, 1219fb0a7daSTejun Heo 1229fb0a7daSTejun Heo TP_PROTO(struct inode *inode, int flags), 1239fb0a7daSTejun Heo 1249fb0a7daSTejun Heo TP_ARGS(inode, flags) 1259fb0a7daSTejun Heo ); 1269fb0a7daSTejun Heo 1279fb0a7daSTejun Heo DEFINE_EVENT(writeback_dirty_inode_template, writeback_dirty_inode, 1289fb0a7daSTejun Heo 1299fb0a7daSTejun Heo TP_PROTO(struct inode *inode, int flags), 1309fb0a7daSTejun Heo 1319fb0a7daSTejun Heo TP_ARGS(inode, flags) 1329fb0a7daSTejun Heo ); 1339fb0a7daSTejun Heo 1349fb0a7daSTejun Heo DECLARE_EVENT_CLASS(writeback_write_inode_template, 1359fb0a7daSTejun Heo 1369fb0a7daSTejun Heo TP_PROTO(struct inode *inode, struct writeback_control *wbc), 1379fb0a7daSTejun Heo 1389fb0a7daSTejun Heo TP_ARGS(inode, wbc), 1399fb0a7daSTejun Heo 1409fb0a7daSTejun Heo TP_STRUCT__entry ( 1419fb0a7daSTejun Heo __array(char, name, 32) 1429fb0a7daSTejun Heo __field(unsigned long, ino) 1439fb0a7daSTejun Heo __field(int, sync_mode) 1449fb0a7daSTejun Heo ), 1459fb0a7daSTejun Heo 1469fb0a7daSTejun Heo TP_fast_assign( 1479fb0a7daSTejun Heo strncpy(__entry->name, 148de1414a6SChristoph Hellwig dev_name(inode_to_bdi(inode)->dev), 32); 1499fb0a7daSTejun Heo __entry->ino = inode->i_ino; 1509fb0a7daSTejun Heo __entry->sync_mode = wbc->sync_mode; 1519fb0a7daSTejun Heo ), 1529fb0a7daSTejun Heo 1539fb0a7daSTejun Heo TP_printk("bdi %s: ino=%lu sync_mode=%d", 1549fb0a7daSTejun Heo __entry->name, 1559fb0a7daSTejun Heo __entry->ino, 1569fb0a7daSTejun Heo __entry->sync_mode 1579fb0a7daSTejun Heo ) 1589fb0a7daSTejun Heo ); 1599fb0a7daSTejun Heo 1609fb0a7daSTejun Heo DEFINE_EVENT(writeback_write_inode_template, writeback_write_inode_start, 1619fb0a7daSTejun Heo 1629fb0a7daSTejun Heo TP_PROTO(struct inode *inode, struct writeback_control *wbc), 1639fb0a7daSTejun Heo 1649fb0a7daSTejun Heo TP_ARGS(inode, wbc) 1659fb0a7daSTejun Heo ); 1669fb0a7daSTejun Heo 1679fb0a7daSTejun Heo DEFINE_EVENT(writeback_write_inode_template, writeback_write_inode, 1689fb0a7daSTejun Heo 1699fb0a7daSTejun Heo TP_PROTO(struct inode *inode, struct writeback_control *wbc), 1709fb0a7daSTejun Heo 1719fb0a7daSTejun Heo TP_ARGS(inode, wbc) 1729fb0a7daSTejun Heo ); 1739fb0a7daSTejun Heo 174455b2864SDave Chinner DECLARE_EVENT_CLASS(writeback_work_class, 175455b2864SDave Chinner TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), 176455b2864SDave Chinner TP_ARGS(bdi, work), 177455b2864SDave Chinner TP_STRUCT__entry( 178455b2864SDave Chinner __array(char, name, 32) 179455b2864SDave Chinner __field(long, nr_pages) 180455b2864SDave Chinner __field(dev_t, sb_dev) 181455b2864SDave Chinner __field(int, sync_mode) 182455b2864SDave Chinner __field(int, for_kupdate) 183455b2864SDave Chinner __field(int, range_cyclic) 184455b2864SDave Chinner __field(int, for_background) 1850e175a18SCurt Wohlgemuth __field(int, reason) 186455b2864SDave Chinner ), 187455b2864SDave Chinner TP_fast_assign( 188df0ce26cSChristoph Hellwig strncpy(__entry->name, 189df0ce26cSChristoph Hellwig bdi->dev ? dev_name(bdi->dev) : "(unknown)", 32); 190455b2864SDave Chinner __entry->nr_pages = work->nr_pages; 191455b2864SDave Chinner __entry->sb_dev = work->sb ? work->sb->s_dev : 0; 192455b2864SDave Chinner __entry->sync_mode = work->sync_mode; 193455b2864SDave Chinner __entry->for_kupdate = work->for_kupdate; 194455b2864SDave Chinner __entry->range_cyclic = work->range_cyclic; 195455b2864SDave Chinner __entry->for_background = work->for_background; 1960e175a18SCurt Wohlgemuth __entry->reason = work->reason; 197455b2864SDave Chinner ), 198455b2864SDave Chinner TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d " 1990e175a18SCurt Wohlgemuth "kupdate=%d range_cyclic=%d background=%d reason=%s", 200455b2864SDave Chinner __entry->name, 201455b2864SDave Chinner MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev), 202455b2864SDave Chinner __entry->nr_pages, 203455b2864SDave Chinner __entry->sync_mode, 204455b2864SDave Chinner __entry->for_kupdate, 205455b2864SDave Chinner __entry->range_cyclic, 2060e175a18SCurt Wohlgemuth __entry->for_background, 207b3bba872SWu Fengguang __print_symbolic(__entry->reason, WB_WORK_REASON) 208455b2864SDave Chinner ) 209455b2864SDave Chinner ); 210455b2864SDave Chinner #define DEFINE_WRITEBACK_WORK_EVENT(name) \ 211455b2864SDave Chinner DEFINE_EVENT(writeback_work_class, name, \ 212455b2864SDave Chinner TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \ 213455b2864SDave Chinner TP_ARGS(bdi, work)) 214455b2864SDave Chinner DEFINE_WRITEBACK_WORK_EVENT(writeback_queue); 215455b2864SDave Chinner DEFINE_WRITEBACK_WORK_EVENT(writeback_exec); 216d46db3d5SWu Fengguang DEFINE_WRITEBACK_WORK_EVENT(writeback_start); 217d46db3d5SWu Fengguang DEFINE_WRITEBACK_WORK_EVENT(writeback_written); 218d46db3d5SWu Fengguang DEFINE_WRITEBACK_WORK_EVENT(writeback_wait); 219455b2864SDave Chinner 220455b2864SDave Chinner TRACE_EVENT(writeback_pages_written, 221455b2864SDave Chinner TP_PROTO(long pages_written), 222455b2864SDave Chinner TP_ARGS(pages_written), 223455b2864SDave Chinner TP_STRUCT__entry( 224455b2864SDave Chinner __field(long, pages) 225455b2864SDave Chinner ), 226455b2864SDave Chinner TP_fast_assign( 227455b2864SDave Chinner __entry->pages = pages_written; 228455b2864SDave Chinner ), 229455b2864SDave Chinner TP_printk("%ld", __entry->pages) 230455b2864SDave Chinner ); 231455b2864SDave Chinner 232455b2864SDave Chinner DECLARE_EVENT_CLASS(writeback_class, 233455b2864SDave Chinner TP_PROTO(struct backing_dev_info *bdi), 234455b2864SDave Chinner TP_ARGS(bdi), 235455b2864SDave Chinner TP_STRUCT__entry( 236455b2864SDave Chinner __array(char, name, 32) 237455b2864SDave Chinner ), 238455b2864SDave Chinner TP_fast_assign( 239455b2864SDave Chinner strncpy(__entry->name, dev_name(bdi->dev), 32); 240455b2864SDave Chinner ), 241455b2864SDave Chinner TP_printk("bdi %s", 242455b2864SDave Chinner __entry->name 243455b2864SDave Chinner ) 244455b2864SDave Chinner ); 245455b2864SDave Chinner #define DEFINE_WRITEBACK_EVENT(name) \ 246455b2864SDave Chinner DEFINE_EVENT(writeback_class, name, \ 247455b2864SDave Chinner TP_PROTO(struct backing_dev_info *bdi), \ 248455b2864SDave Chinner TP_ARGS(bdi)) 249455b2864SDave Chinner 250455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_nowork); 25171927e84SWu Fengguang DEFINE_WRITEBACK_EVENT(writeback_wake_background); 252455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_bdi_register); 253455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister); 254455b2864SDave Chinner 255028c2dd1SDave Chinner DECLARE_EVENT_CLASS(wbc_class, 256028c2dd1SDave Chinner TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), 257028c2dd1SDave Chinner TP_ARGS(wbc, bdi), 258028c2dd1SDave Chinner TP_STRUCT__entry( 259028c2dd1SDave Chinner __array(char, name, 32) 260028c2dd1SDave Chinner __field(long, nr_to_write) 261028c2dd1SDave Chinner __field(long, pages_skipped) 262028c2dd1SDave Chinner __field(int, sync_mode) 263028c2dd1SDave Chinner __field(int, for_kupdate) 264028c2dd1SDave Chinner __field(int, for_background) 265028c2dd1SDave Chinner __field(int, for_reclaim) 266028c2dd1SDave Chinner __field(int, range_cyclic) 267028c2dd1SDave Chinner __field(long, range_start) 268028c2dd1SDave Chinner __field(long, range_end) 269028c2dd1SDave Chinner ), 270028c2dd1SDave Chinner 271028c2dd1SDave Chinner TP_fast_assign( 272028c2dd1SDave Chinner strncpy(__entry->name, dev_name(bdi->dev), 32); 273028c2dd1SDave Chinner __entry->nr_to_write = wbc->nr_to_write; 274028c2dd1SDave Chinner __entry->pages_skipped = wbc->pages_skipped; 275028c2dd1SDave Chinner __entry->sync_mode = wbc->sync_mode; 276028c2dd1SDave Chinner __entry->for_kupdate = wbc->for_kupdate; 277028c2dd1SDave Chinner __entry->for_background = wbc->for_background; 278028c2dd1SDave Chinner __entry->for_reclaim = wbc->for_reclaim; 279028c2dd1SDave Chinner __entry->range_cyclic = wbc->range_cyclic; 280028c2dd1SDave Chinner __entry->range_start = (long)wbc->range_start; 281028c2dd1SDave Chinner __entry->range_end = (long)wbc->range_end; 282028c2dd1SDave Chinner ), 283028c2dd1SDave Chinner 284028c2dd1SDave Chinner TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d " 285d46db3d5SWu Fengguang "bgrd=%d reclm=%d cyclic=%d " 286028c2dd1SDave Chinner "start=0x%lx end=0x%lx", 287028c2dd1SDave Chinner __entry->name, 288028c2dd1SDave Chinner __entry->nr_to_write, 289028c2dd1SDave Chinner __entry->pages_skipped, 290028c2dd1SDave Chinner __entry->sync_mode, 291028c2dd1SDave Chinner __entry->for_kupdate, 292028c2dd1SDave Chinner __entry->for_background, 293028c2dd1SDave Chinner __entry->for_reclaim, 294028c2dd1SDave Chinner __entry->range_cyclic, 295028c2dd1SDave Chinner __entry->range_start, 296028c2dd1SDave Chinner __entry->range_end) 297028c2dd1SDave Chinner ) 298028c2dd1SDave Chinner 299028c2dd1SDave Chinner #define DEFINE_WBC_EVENT(name) \ 300028c2dd1SDave Chinner DEFINE_EVENT(wbc_class, name, \ 301028c2dd1SDave Chinner TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \ 302028c2dd1SDave Chinner TP_ARGS(wbc, bdi)) 3039e094383SDave Chinner DEFINE_WBC_EVENT(wbc_writepage); 304028c2dd1SDave Chinner 305e84d0a4fSWu Fengguang TRACE_EVENT(writeback_queue_io, 306e84d0a4fSWu Fengguang TP_PROTO(struct bdi_writeback *wb, 307ad4e38ddSCurt Wohlgemuth struct wb_writeback_work *work, 308e84d0a4fSWu Fengguang int moved), 309ad4e38ddSCurt Wohlgemuth TP_ARGS(wb, work, moved), 310e84d0a4fSWu Fengguang TP_STRUCT__entry( 311e84d0a4fSWu Fengguang __array(char, name, 32) 312e84d0a4fSWu Fengguang __field(unsigned long, older) 313e84d0a4fSWu Fengguang __field(long, age) 314e84d0a4fSWu Fengguang __field(int, moved) 3150e175a18SCurt Wohlgemuth __field(int, reason) 316e84d0a4fSWu Fengguang ), 317e84d0a4fSWu Fengguang TP_fast_assign( 3180dc83bd3SJan Kara unsigned long *older_than_this = work->older_than_this; 319e84d0a4fSWu Fengguang strncpy(__entry->name, dev_name(wb->bdi->dev), 32); 3200dc83bd3SJan Kara __entry->older = older_than_this ? *older_than_this : 0; 321e84d0a4fSWu Fengguang __entry->age = older_than_this ? 3220dc83bd3SJan Kara (jiffies - *older_than_this) * 1000 / HZ : -1; 323e84d0a4fSWu Fengguang __entry->moved = moved; 3240e175a18SCurt Wohlgemuth __entry->reason = work->reason; 325e84d0a4fSWu Fengguang ), 3260e175a18SCurt Wohlgemuth TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s", 327e84d0a4fSWu Fengguang __entry->name, 328e84d0a4fSWu Fengguang __entry->older, /* older_than_this in jiffies */ 329e84d0a4fSWu Fengguang __entry->age, /* older_than_this in relative milliseconds */ 3300e175a18SCurt Wohlgemuth __entry->moved, 331b3bba872SWu Fengguang __print_symbolic(__entry->reason, WB_WORK_REASON) 332b3bba872SWu Fengguang ) 333e84d0a4fSWu Fengguang ); 334e84d0a4fSWu Fengguang 335e1cbe236SWu Fengguang TRACE_EVENT(global_dirty_state, 336e1cbe236SWu Fengguang 337e1cbe236SWu Fengguang TP_PROTO(unsigned long background_thresh, 338e1cbe236SWu Fengguang unsigned long dirty_thresh 339e1cbe236SWu Fengguang ), 340e1cbe236SWu Fengguang 341e1cbe236SWu Fengguang TP_ARGS(background_thresh, 342e1cbe236SWu Fengguang dirty_thresh 343e1cbe236SWu Fengguang ), 344e1cbe236SWu Fengguang 345e1cbe236SWu Fengguang TP_STRUCT__entry( 346e1cbe236SWu Fengguang __field(unsigned long, nr_dirty) 347e1cbe236SWu Fengguang __field(unsigned long, nr_writeback) 348e1cbe236SWu Fengguang __field(unsigned long, nr_unstable) 349e1cbe236SWu Fengguang __field(unsigned long, background_thresh) 350e1cbe236SWu Fengguang __field(unsigned long, dirty_thresh) 351e1cbe236SWu Fengguang __field(unsigned long, dirty_limit) 352e1cbe236SWu Fengguang __field(unsigned long, nr_dirtied) 353e1cbe236SWu Fengguang __field(unsigned long, nr_written) 354e1cbe236SWu Fengguang ), 355e1cbe236SWu Fengguang 356e1cbe236SWu Fengguang TP_fast_assign( 357e1cbe236SWu Fengguang __entry->nr_dirty = global_page_state(NR_FILE_DIRTY); 358e1cbe236SWu Fengguang __entry->nr_writeback = global_page_state(NR_WRITEBACK); 359e1cbe236SWu Fengguang __entry->nr_unstable = global_page_state(NR_UNSTABLE_NFS); 360e1cbe236SWu Fengguang __entry->nr_dirtied = global_page_state(NR_DIRTIED); 361e1cbe236SWu Fengguang __entry->nr_written = global_page_state(NR_WRITTEN); 362e1cbe236SWu Fengguang __entry->background_thresh = background_thresh; 363e1cbe236SWu Fengguang __entry->dirty_thresh = dirty_thresh; 364e1cbe236SWu Fengguang __entry->dirty_limit = global_dirty_limit; 365e1cbe236SWu Fengguang ), 366e1cbe236SWu Fengguang 367e1cbe236SWu Fengguang TP_printk("dirty=%lu writeback=%lu unstable=%lu " 368e1cbe236SWu Fengguang "bg_thresh=%lu thresh=%lu limit=%lu " 369e1cbe236SWu Fengguang "dirtied=%lu written=%lu", 370e1cbe236SWu Fengguang __entry->nr_dirty, 371e1cbe236SWu Fengguang __entry->nr_writeback, 372e1cbe236SWu Fengguang __entry->nr_unstable, 373e1cbe236SWu Fengguang __entry->background_thresh, 374e1cbe236SWu Fengguang __entry->dirty_thresh, 375e1cbe236SWu Fengguang __entry->dirty_limit, 376e1cbe236SWu Fengguang __entry->nr_dirtied, 377e1cbe236SWu Fengguang __entry->nr_written 378e1cbe236SWu Fengguang ) 379e1cbe236SWu Fengguang ); 380e1cbe236SWu Fengguang 381b48c104dSWu Fengguang #define KBps(x) ((x) << (PAGE_SHIFT - 10)) 382b48c104dSWu Fengguang 383b48c104dSWu Fengguang TRACE_EVENT(bdi_dirty_ratelimit, 384b48c104dSWu Fengguang 385b48c104dSWu Fengguang TP_PROTO(struct backing_dev_info *bdi, 386b48c104dSWu Fengguang unsigned long dirty_rate, 387b48c104dSWu Fengguang unsigned long task_ratelimit), 388b48c104dSWu Fengguang 389b48c104dSWu Fengguang TP_ARGS(bdi, dirty_rate, task_ratelimit), 390b48c104dSWu Fengguang 391b48c104dSWu Fengguang TP_STRUCT__entry( 392b48c104dSWu Fengguang __array(char, bdi, 32) 393b48c104dSWu Fengguang __field(unsigned long, write_bw) 394b48c104dSWu Fengguang __field(unsigned long, avg_write_bw) 395b48c104dSWu Fengguang __field(unsigned long, dirty_rate) 396b48c104dSWu Fengguang __field(unsigned long, dirty_ratelimit) 397b48c104dSWu Fengguang __field(unsigned long, task_ratelimit) 398b48c104dSWu Fengguang __field(unsigned long, balanced_dirty_ratelimit) 399b48c104dSWu Fengguang ), 400b48c104dSWu Fengguang 401b48c104dSWu Fengguang TP_fast_assign( 402b48c104dSWu Fengguang strlcpy(__entry->bdi, dev_name(bdi->dev), 32); 403b48c104dSWu Fengguang __entry->write_bw = KBps(bdi->write_bandwidth); 404b48c104dSWu Fengguang __entry->avg_write_bw = KBps(bdi->avg_write_bandwidth); 405b48c104dSWu Fengguang __entry->dirty_rate = KBps(dirty_rate); 406b48c104dSWu Fengguang __entry->dirty_ratelimit = KBps(bdi->dirty_ratelimit); 407b48c104dSWu Fengguang __entry->task_ratelimit = KBps(task_ratelimit); 408b48c104dSWu Fengguang __entry->balanced_dirty_ratelimit = 409b48c104dSWu Fengguang KBps(bdi->balanced_dirty_ratelimit); 410b48c104dSWu Fengguang ), 411b48c104dSWu Fengguang 412b48c104dSWu Fengguang TP_printk("bdi %s: " 413b48c104dSWu Fengguang "write_bw=%lu awrite_bw=%lu dirty_rate=%lu " 414b48c104dSWu Fengguang "dirty_ratelimit=%lu task_ratelimit=%lu " 415b48c104dSWu Fengguang "balanced_dirty_ratelimit=%lu", 416b48c104dSWu Fengguang __entry->bdi, 417b48c104dSWu Fengguang __entry->write_bw, /* write bandwidth */ 418b48c104dSWu Fengguang __entry->avg_write_bw, /* avg write bandwidth */ 419b48c104dSWu Fengguang __entry->dirty_rate, /* bdi dirty rate */ 420b48c104dSWu Fengguang __entry->dirty_ratelimit, /* base ratelimit */ 421b48c104dSWu Fengguang __entry->task_ratelimit, /* ratelimit with position control */ 422b48c104dSWu Fengguang __entry->balanced_dirty_ratelimit /* the balanced ratelimit */ 423b48c104dSWu Fengguang ) 424b48c104dSWu Fengguang ); 425b48c104dSWu Fengguang 426ece13ac3SWu Fengguang TRACE_EVENT(balance_dirty_pages, 427ece13ac3SWu Fengguang 428ece13ac3SWu Fengguang TP_PROTO(struct backing_dev_info *bdi, 429ece13ac3SWu Fengguang unsigned long thresh, 430ece13ac3SWu Fengguang unsigned long bg_thresh, 431ece13ac3SWu Fengguang unsigned long dirty, 432ece13ac3SWu Fengguang unsigned long bdi_thresh, 433ece13ac3SWu Fengguang unsigned long bdi_dirty, 434ece13ac3SWu Fengguang unsigned long dirty_ratelimit, 435ece13ac3SWu Fengguang unsigned long task_ratelimit, 436ece13ac3SWu Fengguang unsigned long dirtied, 43783712358SWu Fengguang unsigned long period, 438ece13ac3SWu Fengguang long pause, 439ece13ac3SWu Fengguang unsigned long start_time), 440ece13ac3SWu Fengguang 441ece13ac3SWu Fengguang TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty, 442ece13ac3SWu Fengguang dirty_ratelimit, task_ratelimit, 44383712358SWu Fengguang dirtied, period, pause, start_time), 444ece13ac3SWu Fengguang 445ece13ac3SWu Fengguang TP_STRUCT__entry( 446ece13ac3SWu Fengguang __array( char, bdi, 32) 447ece13ac3SWu Fengguang __field(unsigned long, limit) 448ece13ac3SWu Fengguang __field(unsigned long, setpoint) 449ece13ac3SWu Fengguang __field(unsigned long, dirty) 450ece13ac3SWu Fengguang __field(unsigned long, bdi_setpoint) 451ece13ac3SWu Fengguang __field(unsigned long, bdi_dirty) 452ece13ac3SWu Fengguang __field(unsigned long, dirty_ratelimit) 453ece13ac3SWu Fengguang __field(unsigned long, task_ratelimit) 454ece13ac3SWu Fengguang __field(unsigned int, dirtied) 455ece13ac3SWu Fengguang __field(unsigned int, dirtied_pause) 456ece13ac3SWu Fengguang __field(unsigned long, paused) 457ece13ac3SWu Fengguang __field( long, pause) 45883712358SWu Fengguang __field(unsigned long, period) 45983712358SWu Fengguang __field( long, think) 460ece13ac3SWu Fengguang ), 461ece13ac3SWu Fengguang 462ece13ac3SWu Fengguang TP_fast_assign( 463ece13ac3SWu Fengguang unsigned long freerun = (thresh + bg_thresh) / 2; 464ece13ac3SWu Fengguang strlcpy(__entry->bdi, dev_name(bdi->dev), 32); 465ece13ac3SWu Fengguang 466ece13ac3SWu Fengguang __entry->limit = global_dirty_limit; 467ece13ac3SWu Fengguang __entry->setpoint = (global_dirty_limit + freerun) / 2; 468ece13ac3SWu Fengguang __entry->dirty = dirty; 469ece13ac3SWu Fengguang __entry->bdi_setpoint = __entry->setpoint * 470ece13ac3SWu Fengguang bdi_thresh / (thresh + 1); 471ece13ac3SWu Fengguang __entry->bdi_dirty = bdi_dirty; 472ece13ac3SWu Fengguang __entry->dirty_ratelimit = KBps(dirty_ratelimit); 473ece13ac3SWu Fengguang __entry->task_ratelimit = KBps(task_ratelimit); 474ece13ac3SWu Fengguang __entry->dirtied = dirtied; 475ece13ac3SWu Fengguang __entry->dirtied_pause = current->nr_dirtied_pause; 47683712358SWu Fengguang __entry->think = current->dirty_paused_when == 0 ? 0 : 47783712358SWu Fengguang (long)(jiffies - current->dirty_paused_when) * 1000/HZ; 47883712358SWu Fengguang __entry->period = period * 1000 / HZ; 479ece13ac3SWu Fengguang __entry->pause = pause * 1000 / HZ; 480ece13ac3SWu Fengguang __entry->paused = (jiffies - start_time) * 1000 / HZ; 481ece13ac3SWu Fengguang ), 482ece13ac3SWu Fengguang 483ece13ac3SWu Fengguang 484ece13ac3SWu Fengguang TP_printk("bdi %s: " 485ece13ac3SWu Fengguang "limit=%lu setpoint=%lu dirty=%lu " 486ece13ac3SWu Fengguang "bdi_setpoint=%lu bdi_dirty=%lu " 487ece13ac3SWu Fengguang "dirty_ratelimit=%lu task_ratelimit=%lu " 488ece13ac3SWu Fengguang "dirtied=%u dirtied_pause=%u " 48983712358SWu Fengguang "paused=%lu pause=%ld period=%lu think=%ld", 490ece13ac3SWu Fengguang __entry->bdi, 491ece13ac3SWu Fengguang __entry->limit, 492ece13ac3SWu Fengguang __entry->setpoint, 493ece13ac3SWu Fengguang __entry->dirty, 494ece13ac3SWu Fengguang __entry->bdi_setpoint, 495ece13ac3SWu Fengguang __entry->bdi_dirty, 496ece13ac3SWu Fengguang __entry->dirty_ratelimit, 497ece13ac3SWu Fengguang __entry->task_ratelimit, 498ece13ac3SWu Fengguang __entry->dirtied, 499ece13ac3SWu Fengguang __entry->dirtied_pause, 500ece13ac3SWu Fengguang __entry->paused, /* ms */ 50183712358SWu Fengguang __entry->pause, /* ms */ 50283712358SWu Fengguang __entry->period, /* ms */ 50383712358SWu Fengguang __entry->think /* ms */ 504ece13ac3SWu Fengguang ) 505ece13ac3SWu Fengguang ); 506ece13ac3SWu Fengguang 507cc1676d9SJan Kara TRACE_EVENT(writeback_sb_inodes_requeue, 508cc1676d9SJan Kara 509cc1676d9SJan Kara TP_PROTO(struct inode *inode), 510cc1676d9SJan Kara TP_ARGS(inode), 511cc1676d9SJan Kara 512cc1676d9SJan Kara TP_STRUCT__entry( 513cc1676d9SJan Kara __array(char, name, 32) 514cc1676d9SJan Kara __field(unsigned long, ino) 515cc1676d9SJan Kara __field(unsigned long, state) 516cc1676d9SJan Kara __field(unsigned long, dirtied_when) 517cc1676d9SJan Kara ), 518cc1676d9SJan Kara 519cc1676d9SJan Kara TP_fast_assign( 520cc1676d9SJan Kara strncpy(__entry->name, 521cc1676d9SJan Kara dev_name(inode_to_bdi(inode)->dev), 32); 522cc1676d9SJan Kara __entry->ino = inode->i_ino; 523cc1676d9SJan Kara __entry->state = inode->i_state; 524cc1676d9SJan Kara __entry->dirtied_when = inode->dirtied_when; 525cc1676d9SJan Kara ), 526cc1676d9SJan Kara 527cc1676d9SJan Kara TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu", 528cc1676d9SJan Kara __entry->name, 529cc1676d9SJan Kara __entry->ino, 530cc1676d9SJan Kara show_inode_state(__entry->state), 531cc1676d9SJan Kara __entry->dirtied_when, 532cc1676d9SJan Kara (jiffies - __entry->dirtied_when) / HZ 533cc1676d9SJan Kara ) 534cc1676d9SJan Kara ); 535cc1676d9SJan Kara 53652bb9198SMel Gorman DECLARE_EVENT_CLASS(writeback_congest_waited_template, 53752bb9198SMel Gorman 53852bb9198SMel Gorman TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed), 53952bb9198SMel Gorman 54052bb9198SMel Gorman TP_ARGS(usec_timeout, usec_delayed), 54152bb9198SMel Gorman 54252bb9198SMel Gorman TP_STRUCT__entry( 54352bb9198SMel Gorman __field( unsigned int, usec_timeout ) 54452bb9198SMel Gorman __field( unsigned int, usec_delayed ) 54552bb9198SMel Gorman ), 54652bb9198SMel Gorman 54752bb9198SMel Gorman TP_fast_assign( 54852bb9198SMel Gorman __entry->usec_timeout = usec_timeout; 54952bb9198SMel Gorman __entry->usec_delayed = usec_delayed; 55052bb9198SMel Gorman ), 55152bb9198SMel Gorman 55252bb9198SMel Gorman TP_printk("usec_timeout=%u usec_delayed=%u", 55352bb9198SMel Gorman __entry->usec_timeout, 55452bb9198SMel Gorman __entry->usec_delayed) 55552bb9198SMel Gorman ); 55652bb9198SMel Gorman 55752bb9198SMel Gorman DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait, 55852bb9198SMel Gorman 55952bb9198SMel Gorman TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed), 56052bb9198SMel Gorman 56152bb9198SMel Gorman TP_ARGS(usec_timeout, usec_delayed) 56252bb9198SMel Gorman ); 56352bb9198SMel Gorman 5640e093d99SMel Gorman DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested, 5650e093d99SMel Gorman 5660e093d99SMel Gorman TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed), 5670e093d99SMel Gorman 5680e093d99SMel Gorman TP_ARGS(usec_timeout, usec_delayed) 5690e093d99SMel Gorman ); 5700e093d99SMel Gorman 571251d6a47SWu Fengguang DECLARE_EVENT_CLASS(writeback_single_inode_template, 572251d6a47SWu Fengguang 573251d6a47SWu Fengguang TP_PROTO(struct inode *inode, 574251d6a47SWu Fengguang struct writeback_control *wbc, 575251d6a47SWu Fengguang unsigned long nr_to_write 576251d6a47SWu Fengguang ), 577251d6a47SWu Fengguang 578251d6a47SWu Fengguang TP_ARGS(inode, wbc, nr_to_write), 579251d6a47SWu Fengguang 580251d6a47SWu Fengguang TP_STRUCT__entry( 581251d6a47SWu Fengguang __array(char, name, 32) 582251d6a47SWu Fengguang __field(unsigned long, ino) 583251d6a47SWu Fengguang __field(unsigned long, state) 584c8ad6206SWu Fengguang __field(unsigned long, dirtied_when) 585251d6a47SWu Fengguang __field(unsigned long, writeback_index) 586251d6a47SWu Fengguang __field(long, nr_to_write) 587251d6a47SWu Fengguang __field(unsigned long, wrote) 588251d6a47SWu Fengguang ), 589251d6a47SWu Fengguang 590251d6a47SWu Fengguang TP_fast_assign( 591251d6a47SWu Fengguang strncpy(__entry->name, 59215eb77a0SWu Fengguang dev_name(inode_to_bdi(inode)->dev), 32); 593251d6a47SWu Fengguang __entry->ino = inode->i_ino; 594251d6a47SWu Fengguang __entry->state = inode->i_state; 595c8ad6206SWu Fengguang __entry->dirtied_when = inode->dirtied_when; 596251d6a47SWu Fengguang __entry->writeback_index = inode->i_mapping->writeback_index; 597251d6a47SWu Fengguang __entry->nr_to_write = nr_to_write; 598251d6a47SWu Fengguang __entry->wrote = nr_to_write - wbc->nr_to_write; 599251d6a47SWu Fengguang ), 600251d6a47SWu Fengguang 601c8ad6206SWu Fengguang TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu " 602251d6a47SWu Fengguang "index=%lu to_write=%ld wrote=%lu", 603251d6a47SWu Fengguang __entry->name, 604251d6a47SWu Fengguang __entry->ino, 605251d6a47SWu Fengguang show_inode_state(__entry->state), 606c8ad6206SWu Fengguang __entry->dirtied_when, 607c8ad6206SWu Fengguang (jiffies - __entry->dirtied_when) / HZ, 608251d6a47SWu Fengguang __entry->writeback_index, 609251d6a47SWu Fengguang __entry->nr_to_write, 610251d6a47SWu Fengguang __entry->wrote 611251d6a47SWu Fengguang ) 612251d6a47SWu Fengguang ); 613251d6a47SWu Fengguang 6149fb0a7daSTejun Heo DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode_start, 6159fb0a7daSTejun Heo TP_PROTO(struct inode *inode, 6169fb0a7daSTejun Heo struct writeback_control *wbc, 6179fb0a7daSTejun Heo unsigned long nr_to_write), 6189fb0a7daSTejun Heo TP_ARGS(inode, wbc, nr_to_write) 6199fb0a7daSTejun Heo ); 6209fb0a7daSTejun Heo 621251d6a47SWu Fengguang DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode, 622251d6a47SWu Fengguang TP_PROTO(struct inode *inode, 623251d6a47SWu Fengguang struct writeback_control *wbc, 624251d6a47SWu Fengguang unsigned long nr_to_write), 625251d6a47SWu Fengguang TP_ARGS(inode, wbc, nr_to_write) 626251d6a47SWu Fengguang ); 627251d6a47SWu Fengguang 6280ae45f63STheodore Ts'o DECLARE_EVENT_CLASS(writeback_lazytime_template, 6290ae45f63STheodore Ts'o TP_PROTO(struct inode *inode), 6300ae45f63STheodore Ts'o 6310ae45f63STheodore Ts'o TP_ARGS(inode), 6320ae45f63STheodore Ts'o 6330ae45f63STheodore Ts'o TP_STRUCT__entry( 6340ae45f63STheodore Ts'o __field( dev_t, dev ) 6350ae45f63STheodore Ts'o __field(unsigned long, ino ) 6360ae45f63STheodore Ts'o __field(unsigned long, state ) 6370ae45f63STheodore Ts'o __field( __u16, mode ) 6380ae45f63STheodore Ts'o __field(unsigned long, dirtied_when ) 6390ae45f63STheodore Ts'o ), 6400ae45f63STheodore Ts'o 6410ae45f63STheodore Ts'o TP_fast_assign( 6420ae45f63STheodore Ts'o __entry->dev = inode->i_sb->s_dev; 6430ae45f63STheodore Ts'o __entry->ino = inode->i_ino; 6440ae45f63STheodore Ts'o __entry->state = inode->i_state; 6450ae45f63STheodore Ts'o __entry->mode = inode->i_mode; 6460ae45f63STheodore Ts'o __entry->dirtied_when = inode->dirtied_when; 6470ae45f63STheodore Ts'o ), 6480ae45f63STheodore Ts'o 6490ae45f63STheodore Ts'o TP_printk("dev %d,%d ino %lu dirtied %lu state %s mode 0%o", 6500ae45f63STheodore Ts'o MAJOR(__entry->dev), MINOR(__entry->dev), 6510ae45f63STheodore Ts'o __entry->ino, __entry->dirtied_when, 6520ae45f63STheodore Ts'o show_inode_state(__entry->state), __entry->mode) 6530ae45f63STheodore Ts'o ); 6540ae45f63STheodore Ts'o 6550ae45f63STheodore Ts'o DEFINE_EVENT(writeback_lazytime_template, writeback_lazytime, 6560ae45f63STheodore Ts'o TP_PROTO(struct inode *inode), 6570ae45f63STheodore Ts'o 6580ae45f63STheodore Ts'o TP_ARGS(inode) 6590ae45f63STheodore Ts'o ); 6600ae45f63STheodore Ts'o 6610ae45f63STheodore Ts'o DEFINE_EVENT(writeback_lazytime_template, writeback_lazytime_iput, 6620ae45f63STheodore Ts'o TP_PROTO(struct inode *inode), 6630ae45f63STheodore Ts'o 6640ae45f63STheodore Ts'o TP_ARGS(inode) 6650ae45f63STheodore Ts'o ); 6660ae45f63STheodore Ts'o 6670ae45f63STheodore Ts'o DEFINE_EVENT(writeback_lazytime_template, writeback_dirty_inode_enqueue, 6680ae45f63STheodore Ts'o 6690ae45f63STheodore Ts'o TP_PROTO(struct inode *inode), 6700ae45f63STheodore Ts'o 6710ae45f63STheodore Ts'o TP_ARGS(inode) 6720ae45f63STheodore Ts'o ); 6730ae45f63STheodore Ts'o 674455b2864SDave Chinner #endif /* _TRACE_WRITEBACK_H */ 675455b2864SDave Chinner 676455b2864SDave Chinner /* This part must be outside protection */ 677455b2864SDave Chinner #include <trace/define_trace.h> 678