Dave Chinner | 455b286 | 2010-07-07 13:24:06 +1000 | [diff] [blame] | 1 | #undef TRACE_SYSTEM |
| 2 | #define TRACE_SYSTEM writeback |
| 3 | |
| 4 | #if !defined(_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ) |
| 5 | #define _TRACE_WRITEBACK_H |
| 6 | |
| 7 | #include <linux/backing-dev.h> |
Randy Dunlap | 96dccab | 2010-07-19 16:49:17 -0700 | [diff] [blame] | 8 | #include <linux/device.h> |
Dave Chinner | 455b286 | 2010-07-07 13:24:06 +1000 | [diff] [blame] | 9 | #include <linux/writeback.h> |
| 10 | |
Wu Fengguang | 251d6a4 | 2010-12-01 17:33:37 -0600 | [diff] [blame] | 11 | #define show_inode_state(state) \ |
| 12 | __print_flags(state, "|", \ |
| 13 | {I_DIRTY_SYNC, "I_DIRTY_SYNC"}, \ |
| 14 | {I_DIRTY_DATASYNC, "I_DIRTY_DATASYNC"}, \ |
| 15 | {I_DIRTY_PAGES, "I_DIRTY_PAGES"}, \ |
| 16 | {I_NEW, "I_NEW"}, \ |
| 17 | {I_WILL_FREE, "I_WILL_FREE"}, \ |
| 18 | {I_FREEING, "I_FREEING"}, \ |
| 19 | {I_CLEAR, "I_CLEAR"}, \ |
| 20 | {I_SYNC, "I_SYNC"}, \ |
| 21 | {I_REFERENCED, "I_REFERENCED"} \ |
| 22 | ) |
| 23 | |
Dave Chinner | 455b286 | 2010-07-07 13:24:06 +1000 | [diff] [blame] | 24 | struct wb_writeback_work; |
| 25 | |
| 26 | DECLARE_EVENT_CLASS(writeback_work_class, |
| 27 | TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), |
| 28 | TP_ARGS(bdi, work), |
| 29 | TP_STRUCT__entry( |
| 30 | __array(char, name, 32) |
| 31 | __field(long, nr_pages) |
| 32 | __field(dev_t, sb_dev) |
| 33 | __field(int, sync_mode) |
| 34 | __field(int, for_kupdate) |
| 35 | __field(int, range_cyclic) |
| 36 | __field(int, for_background) |
| 37 | ), |
| 38 | TP_fast_assign( |
| 39 | strncpy(__entry->name, dev_name(bdi->dev), 32); |
| 40 | __entry->nr_pages = work->nr_pages; |
| 41 | __entry->sb_dev = work->sb ? work->sb->s_dev : 0; |
| 42 | __entry->sync_mode = work->sync_mode; |
| 43 | __entry->for_kupdate = work->for_kupdate; |
| 44 | __entry->range_cyclic = work->range_cyclic; |
| 45 | __entry->for_background = work->for_background; |
| 46 | ), |
| 47 | TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d " |
| 48 | "kupdate=%d range_cyclic=%d background=%d", |
| 49 | __entry->name, |
| 50 | MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev), |
| 51 | __entry->nr_pages, |
| 52 | __entry->sync_mode, |
| 53 | __entry->for_kupdate, |
| 54 | __entry->range_cyclic, |
| 55 | __entry->for_background |
| 56 | ) |
| 57 | ); |
| 58 | #define DEFINE_WRITEBACK_WORK_EVENT(name) \ |
| 59 | DEFINE_EVENT(writeback_work_class, name, \ |
| 60 | TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \ |
| 61 | TP_ARGS(bdi, work)) |
| 62 | DEFINE_WRITEBACK_WORK_EVENT(writeback_nothread); |
| 63 | DEFINE_WRITEBACK_WORK_EVENT(writeback_queue); |
| 64 | DEFINE_WRITEBACK_WORK_EVENT(writeback_exec); |
Wu Fengguang | d46db3d | 2011-05-04 19:54:37 -0600 | [diff] [blame] | 65 | DEFINE_WRITEBACK_WORK_EVENT(writeback_start); |
| 66 | DEFINE_WRITEBACK_WORK_EVENT(writeback_written); |
| 67 | DEFINE_WRITEBACK_WORK_EVENT(writeback_wait); |
Dave Chinner | 455b286 | 2010-07-07 13:24:06 +1000 | [diff] [blame] | 68 | |
| 69 | TRACE_EVENT(writeback_pages_written, |
| 70 | TP_PROTO(long pages_written), |
| 71 | TP_ARGS(pages_written), |
| 72 | TP_STRUCT__entry( |
| 73 | __field(long, pages) |
| 74 | ), |
| 75 | TP_fast_assign( |
| 76 | __entry->pages = pages_written; |
| 77 | ), |
| 78 | TP_printk("%ld", __entry->pages) |
| 79 | ); |
| 80 | |
| 81 | DECLARE_EVENT_CLASS(writeback_class, |
| 82 | TP_PROTO(struct backing_dev_info *bdi), |
| 83 | TP_ARGS(bdi), |
| 84 | TP_STRUCT__entry( |
| 85 | __array(char, name, 32) |
| 86 | ), |
| 87 | TP_fast_assign( |
| 88 | strncpy(__entry->name, dev_name(bdi->dev), 32); |
| 89 | ), |
| 90 | TP_printk("bdi %s", |
| 91 | __entry->name |
| 92 | ) |
| 93 | ); |
| 94 | #define DEFINE_WRITEBACK_EVENT(name) \ |
| 95 | DEFINE_EVENT(writeback_class, name, \ |
| 96 | TP_PROTO(struct backing_dev_info *bdi), \ |
| 97 | TP_ARGS(bdi)) |
| 98 | |
| 99 | DEFINE_WRITEBACK_EVENT(writeback_nowork); |
Wu Fengguang | 71927e8 | 2011-01-13 15:45:46 -0800 | [diff] [blame] | 100 | DEFINE_WRITEBACK_EVENT(writeback_wake_background); |
Artem Bityutskiy | 6033202 | 2010-07-25 14:29:24 +0300 | [diff] [blame] | 101 | DEFINE_WRITEBACK_EVENT(writeback_wake_thread); |
| 102 | DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread); |
Dave Chinner | 455b286 | 2010-07-07 13:24:06 +1000 | [diff] [blame] | 103 | DEFINE_WRITEBACK_EVENT(writeback_bdi_register); |
| 104 | DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister); |
| 105 | DEFINE_WRITEBACK_EVENT(writeback_thread_start); |
| 106 | DEFINE_WRITEBACK_EVENT(writeback_thread_stop); |
Wu Fengguang | d46db3d | 2011-05-04 19:54:37 -0600 | [diff] [blame] | 107 | DEFINE_WRITEBACK_EVENT(balance_dirty_start); |
| 108 | DEFINE_WRITEBACK_EVENT(balance_dirty_wait); |
| 109 | |
| 110 | TRACE_EVENT(balance_dirty_written, |
| 111 | |
| 112 | TP_PROTO(struct backing_dev_info *bdi, int written), |
| 113 | |
| 114 | TP_ARGS(bdi, written), |
| 115 | |
| 116 | TP_STRUCT__entry( |
| 117 | __array(char, name, 32) |
| 118 | __field(int, written) |
| 119 | ), |
| 120 | |
| 121 | TP_fast_assign( |
| 122 | strncpy(__entry->name, dev_name(bdi->dev), 32); |
| 123 | __entry->written = written; |
| 124 | ), |
| 125 | |
| 126 | TP_printk("bdi %s written %d", |
| 127 | __entry->name, |
| 128 | __entry->written |
| 129 | ) |
| 130 | ); |
Dave Chinner | 455b286 | 2010-07-07 13:24:06 +1000 | [diff] [blame] | 131 | |
Dave Chinner | 028c2dd | 2010-07-07 13:24:07 +1000 | [diff] [blame] | 132 | DECLARE_EVENT_CLASS(wbc_class, |
| 133 | TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), |
| 134 | TP_ARGS(wbc, bdi), |
| 135 | TP_STRUCT__entry( |
| 136 | __array(char, name, 32) |
| 137 | __field(long, nr_to_write) |
| 138 | __field(long, pages_skipped) |
| 139 | __field(int, sync_mode) |
Dave Chinner | 028c2dd | 2010-07-07 13:24:07 +1000 | [diff] [blame] | 140 | __field(int, for_kupdate) |
| 141 | __field(int, for_background) |
| 142 | __field(int, for_reclaim) |
| 143 | __field(int, range_cyclic) |
Dave Chinner | 028c2dd | 2010-07-07 13:24:07 +1000 | [diff] [blame] | 144 | __field(long, range_start) |
| 145 | __field(long, range_end) |
| 146 | ), |
| 147 | |
| 148 | TP_fast_assign( |
| 149 | strncpy(__entry->name, dev_name(bdi->dev), 32); |
| 150 | __entry->nr_to_write = wbc->nr_to_write; |
| 151 | __entry->pages_skipped = wbc->pages_skipped; |
| 152 | __entry->sync_mode = wbc->sync_mode; |
| 153 | __entry->for_kupdate = wbc->for_kupdate; |
| 154 | __entry->for_background = wbc->for_background; |
| 155 | __entry->for_reclaim = wbc->for_reclaim; |
| 156 | __entry->range_cyclic = wbc->range_cyclic; |
Dave Chinner | 028c2dd | 2010-07-07 13:24:07 +1000 | [diff] [blame] | 157 | __entry->range_start = (long)wbc->range_start; |
| 158 | __entry->range_end = (long)wbc->range_end; |
| 159 | ), |
| 160 | |
| 161 | TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d " |
Wu Fengguang | d46db3d | 2011-05-04 19:54:37 -0600 | [diff] [blame] | 162 | "bgrd=%d reclm=%d cyclic=%d " |
Dave Chinner | 028c2dd | 2010-07-07 13:24:07 +1000 | [diff] [blame] | 163 | "start=0x%lx end=0x%lx", |
| 164 | __entry->name, |
| 165 | __entry->nr_to_write, |
| 166 | __entry->pages_skipped, |
| 167 | __entry->sync_mode, |
| 168 | __entry->for_kupdate, |
| 169 | __entry->for_background, |
| 170 | __entry->for_reclaim, |
| 171 | __entry->range_cyclic, |
Dave Chinner | 028c2dd | 2010-07-07 13:24:07 +1000 | [diff] [blame] | 172 | __entry->range_start, |
| 173 | __entry->range_end) |
| 174 | ) |
| 175 | |
| 176 | #define DEFINE_WBC_EVENT(name) \ |
| 177 | DEFINE_EVENT(wbc_class, name, \ |
| 178 | TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \ |
| 179 | TP_ARGS(wbc, bdi)) |
Dave Chinner | 9e09438 | 2010-07-07 13:24:08 +1000 | [diff] [blame] | 180 | DEFINE_WBC_EVENT(wbc_writepage); |
Dave Chinner | 028c2dd | 2010-07-07 13:24:07 +1000 | [diff] [blame] | 181 | |
Wu Fengguang | e84d0a4 | 2011-04-23 12:27:27 -0600 | [diff] [blame] | 182 | TRACE_EVENT(writeback_queue_io, |
| 183 | TP_PROTO(struct bdi_writeback *wb, |
| 184 | unsigned long *older_than_this, |
| 185 | int moved), |
| 186 | TP_ARGS(wb, older_than_this, moved), |
| 187 | TP_STRUCT__entry( |
| 188 | __array(char, name, 32) |
| 189 | __field(unsigned long, older) |
| 190 | __field(long, age) |
| 191 | __field(int, moved) |
| 192 | ), |
| 193 | TP_fast_assign( |
| 194 | strncpy(__entry->name, dev_name(wb->bdi->dev), 32); |
| 195 | __entry->older = older_than_this ? *older_than_this : 0; |
| 196 | __entry->age = older_than_this ? |
| 197 | (jiffies - *older_than_this) * 1000 / HZ : -1; |
| 198 | __entry->moved = moved; |
| 199 | ), |
| 200 | TP_printk("bdi %s: older=%lu age=%ld enqueue=%d", |
| 201 | __entry->name, |
| 202 | __entry->older, /* older_than_this in jiffies */ |
| 203 | __entry->age, /* older_than_this in relative milliseconds */ |
| 204 | __entry->moved) |
| 205 | ); |
| 206 | |
Wu Fengguang | e1cbe23 | 2010-12-06 22:34:29 -0600 | [diff] [blame] | 207 | TRACE_EVENT(global_dirty_state, |
| 208 | |
| 209 | TP_PROTO(unsigned long background_thresh, |
| 210 | unsigned long dirty_thresh |
| 211 | ), |
| 212 | |
| 213 | TP_ARGS(background_thresh, |
| 214 | dirty_thresh |
| 215 | ), |
| 216 | |
| 217 | TP_STRUCT__entry( |
| 218 | __field(unsigned long, nr_dirty) |
| 219 | __field(unsigned long, nr_writeback) |
| 220 | __field(unsigned long, nr_unstable) |
| 221 | __field(unsigned long, background_thresh) |
| 222 | __field(unsigned long, dirty_thresh) |
| 223 | __field(unsigned long, dirty_limit) |
| 224 | __field(unsigned long, nr_dirtied) |
| 225 | __field(unsigned long, nr_written) |
| 226 | ), |
| 227 | |
| 228 | TP_fast_assign( |
| 229 | __entry->nr_dirty = global_page_state(NR_FILE_DIRTY); |
| 230 | __entry->nr_writeback = global_page_state(NR_WRITEBACK); |
| 231 | __entry->nr_unstable = global_page_state(NR_UNSTABLE_NFS); |
| 232 | __entry->nr_dirtied = global_page_state(NR_DIRTIED); |
| 233 | __entry->nr_written = global_page_state(NR_WRITTEN); |
| 234 | __entry->background_thresh = background_thresh; |
| 235 | __entry->dirty_thresh = dirty_thresh; |
| 236 | __entry->dirty_limit = global_dirty_limit; |
| 237 | ), |
| 238 | |
| 239 | TP_printk("dirty=%lu writeback=%lu unstable=%lu " |
| 240 | "bg_thresh=%lu thresh=%lu limit=%lu " |
| 241 | "dirtied=%lu written=%lu", |
| 242 | __entry->nr_dirty, |
| 243 | __entry->nr_writeback, |
| 244 | __entry->nr_unstable, |
| 245 | __entry->background_thresh, |
| 246 | __entry->dirty_thresh, |
| 247 | __entry->dirty_limit, |
| 248 | __entry->nr_dirtied, |
| 249 | __entry->nr_written |
| 250 | ) |
| 251 | ); |
| 252 | |
Mel Gorman | 52bb919 | 2010-10-26 14:21:41 -0700 | [diff] [blame] | 253 | DECLARE_EVENT_CLASS(writeback_congest_waited_template, |
| 254 | |
| 255 | TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed), |
| 256 | |
| 257 | TP_ARGS(usec_timeout, usec_delayed), |
| 258 | |
| 259 | TP_STRUCT__entry( |
| 260 | __field( unsigned int, usec_timeout ) |
| 261 | __field( unsigned int, usec_delayed ) |
| 262 | ), |
| 263 | |
| 264 | TP_fast_assign( |
| 265 | __entry->usec_timeout = usec_timeout; |
| 266 | __entry->usec_delayed = usec_delayed; |
| 267 | ), |
| 268 | |
| 269 | TP_printk("usec_timeout=%u usec_delayed=%u", |
| 270 | __entry->usec_timeout, |
| 271 | __entry->usec_delayed) |
| 272 | ); |
| 273 | |
| 274 | DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait, |
| 275 | |
| 276 | TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed), |
| 277 | |
| 278 | TP_ARGS(usec_timeout, usec_delayed) |
| 279 | ); |
| 280 | |
Mel Gorman | 0e093d99 | 2010-10-26 14:21:45 -0700 | [diff] [blame] | 281 | DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested, |
| 282 | |
| 283 | TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed), |
| 284 | |
| 285 | TP_ARGS(usec_timeout, usec_delayed) |
| 286 | ); |
| 287 | |
Wu Fengguang | 251d6a4 | 2010-12-01 17:33:37 -0600 | [diff] [blame] | 288 | DECLARE_EVENT_CLASS(writeback_single_inode_template, |
| 289 | |
| 290 | TP_PROTO(struct inode *inode, |
| 291 | struct writeback_control *wbc, |
| 292 | unsigned long nr_to_write |
| 293 | ), |
| 294 | |
| 295 | TP_ARGS(inode, wbc, nr_to_write), |
| 296 | |
| 297 | TP_STRUCT__entry( |
| 298 | __array(char, name, 32) |
| 299 | __field(unsigned long, ino) |
| 300 | __field(unsigned long, state) |
Wu Fengguang | c8ad620 | 2011-08-29 09:52:23 -0600 | [diff] [blame] | 301 | __field(unsigned long, dirtied_when) |
Wu Fengguang | 251d6a4 | 2010-12-01 17:33:37 -0600 | [diff] [blame] | 302 | __field(unsigned long, writeback_index) |
| 303 | __field(long, nr_to_write) |
| 304 | __field(unsigned long, wrote) |
| 305 | ), |
| 306 | |
| 307 | TP_fast_assign( |
| 308 | strncpy(__entry->name, |
| 309 | dev_name(inode->i_mapping->backing_dev_info->dev), 32); |
| 310 | __entry->ino = inode->i_ino; |
| 311 | __entry->state = inode->i_state; |
Wu Fengguang | c8ad620 | 2011-08-29 09:52:23 -0600 | [diff] [blame] | 312 | __entry->dirtied_when = inode->dirtied_when; |
Wu Fengguang | 251d6a4 | 2010-12-01 17:33:37 -0600 | [diff] [blame] | 313 | __entry->writeback_index = inode->i_mapping->writeback_index; |
| 314 | __entry->nr_to_write = nr_to_write; |
| 315 | __entry->wrote = nr_to_write - wbc->nr_to_write; |
| 316 | ), |
| 317 | |
Wu Fengguang | c8ad620 | 2011-08-29 09:52:23 -0600 | [diff] [blame] | 318 | TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu " |
Wu Fengguang | 251d6a4 | 2010-12-01 17:33:37 -0600 | [diff] [blame] | 319 | "index=%lu to_write=%ld wrote=%lu", |
| 320 | __entry->name, |
| 321 | __entry->ino, |
| 322 | show_inode_state(__entry->state), |
Wu Fengguang | c8ad620 | 2011-08-29 09:52:23 -0600 | [diff] [blame] | 323 | __entry->dirtied_when, |
| 324 | (jiffies - __entry->dirtied_when) / HZ, |
Wu Fengguang | 251d6a4 | 2010-12-01 17:33:37 -0600 | [diff] [blame] | 325 | __entry->writeback_index, |
| 326 | __entry->nr_to_write, |
| 327 | __entry->wrote |
| 328 | ) |
| 329 | ); |
| 330 | |
| 331 | DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode_requeue, |
| 332 | TP_PROTO(struct inode *inode, |
| 333 | struct writeback_control *wbc, |
| 334 | unsigned long nr_to_write), |
| 335 | TP_ARGS(inode, wbc, nr_to_write) |
| 336 | ); |
| 337 | |
| 338 | DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode, |
| 339 | TP_PROTO(struct inode *inode, |
| 340 | struct writeback_control *wbc, |
| 341 | unsigned long nr_to_write), |
| 342 | TP_ARGS(inode, wbc, nr_to_write) |
| 343 | ); |
| 344 | |
Dave Chinner | 455b286 | 2010-07-07 13:24:06 +1000 | [diff] [blame] | 345 | #endif /* _TRACE_WRITEBACK_H */ |
| 346 | |
| 347 | /* This part must be outside protection */ |
| 348 | #include <trace/define_trace.h> |