Linux 4.8.3
[linux/fpc-iii.git] / include / trace / events / block.h
blob8f3a163b8166dadb0f7e1c5f7080acd757013a3f
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM block
4 #if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_BLOCK_H
7 #include <linux/blktrace_api.h>
8 #include <linux/blkdev.h>
9 #include <linux/buffer_head.h>
10 #include <linux/tracepoint.h>
12 #define RWBS_LEN 8
14 DECLARE_EVENT_CLASS(block_buffer,
16 TP_PROTO(struct buffer_head *bh),
18 TP_ARGS(bh),
20 TP_STRUCT__entry (
21 __field( dev_t, dev )
22 __field( sector_t, sector )
23 __field( size_t, size )
26 TP_fast_assign(
27 __entry->dev = bh->b_bdev->bd_dev;
28 __entry->sector = bh->b_blocknr;
29 __entry->size = bh->b_size;
32 TP_printk("%d,%d sector=%llu size=%zu",
33 MAJOR(__entry->dev), MINOR(__entry->dev),
34 (unsigned long long)__entry->sector, __entry->size
38 /**
39 * block_touch_buffer - mark a buffer accessed
40 * @bh: buffer_head being touched
42 * Called from touch_buffer().
44 DEFINE_EVENT(block_buffer, block_touch_buffer,
46 TP_PROTO(struct buffer_head *bh),
48 TP_ARGS(bh)
51 /**
52 * block_dirty_buffer - mark a buffer dirty
53 * @bh: buffer_head being dirtied
55 * Called from mark_buffer_dirty().
57 DEFINE_EVENT(block_buffer, block_dirty_buffer,
59 TP_PROTO(struct buffer_head *bh),
61 TP_ARGS(bh)
64 DECLARE_EVENT_CLASS(block_rq_with_error,
66 TP_PROTO(struct request_queue *q, struct request *rq),
68 TP_ARGS(q, rq),
70 TP_STRUCT__entry(
71 __field( dev_t, dev )
72 __field( sector_t, sector )
73 __field( unsigned int, nr_sector )
74 __field( int, errors )
75 __array( char, rwbs, RWBS_LEN )
76 __dynamic_array( char, cmd, blk_cmd_buf_len(rq) )
79 TP_fast_assign(
80 __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
81 __entry->sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
82 0 : blk_rq_pos(rq);
83 __entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
84 0 : blk_rq_sectors(rq);
85 __entry->errors = rq->errors;
87 blk_fill_rwbs(__entry->rwbs, req_op(rq), rq->cmd_flags,
88 blk_rq_bytes(rq));
89 blk_dump_cmd(__get_str(cmd), rq);
92 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
93 MAJOR(__entry->dev), MINOR(__entry->dev),
94 __entry->rwbs, __get_str(cmd),
95 (unsigned long long)__entry->sector,
96 __entry->nr_sector, __entry->errors)
99 /**
100 * block_rq_abort - abort block operation request
101 * @q: queue containing the block operation request
102 * @rq: block IO operation request
104 * Called immediately after pending block IO operation request @rq in
105 * queue @q is aborted. The fields in the operation request @rq
106 * can be examined to determine which device and sectors the pending
107 * operation would access.
109 DEFINE_EVENT(block_rq_with_error, block_rq_abort,
111 TP_PROTO(struct request_queue *q, struct request *rq),
113 TP_ARGS(q, rq)
117 * block_rq_requeue - place block IO request back on a queue
118 * @q: queue holding operation
119 * @rq: block IO operation request
121 * The block operation request @rq is being placed back into queue
122 * @q. For some reason the request was not completed and needs to be
123 * put back in the queue.
125 DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
127 TP_PROTO(struct request_queue *q, struct request *rq),
129 TP_ARGS(q, rq)
133 * block_rq_complete - block IO operation completed by device driver
134 * @q: queue containing the block operation request
135 * @rq: block operations request
136 * @nr_bytes: number of completed bytes
138 * The block_rq_complete tracepoint event indicates that some portion
139 * of operation request has been completed by the device driver. If
140 * the @rq->bio is %NULL, then there is absolutely no additional work to
141 * do for the request. If @rq->bio is non-NULL then there is
142 * additional work required to complete the request.
144 TRACE_EVENT(block_rq_complete,
146 TP_PROTO(struct request_queue *q, struct request *rq,
147 unsigned int nr_bytes),
149 TP_ARGS(q, rq, nr_bytes),
151 TP_STRUCT__entry(
152 __field( dev_t, dev )
153 __field( sector_t, sector )
154 __field( unsigned int, nr_sector )
155 __field( int, errors )
156 __array( char, rwbs, RWBS_LEN )
157 __dynamic_array( char, cmd, blk_cmd_buf_len(rq) )
160 TP_fast_assign(
161 __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
162 __entry->sector = blk_rq_pos(rq);
163 __entry->nr_sector = nr_bytes >> 9;
164 __entry->errors = rq->errors;
166 blk_fill_rwbs(__entry->rwbs, req_op(rq), rq->cmd_flags, nr_bytes);
167 blk_dump_cmd(__get_str(cmd), rq);
170 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
171 MAJOR(__entry->dev), MINOR(__entry->dev),
172 __entry->rwbs, __get_str(cmd),
173 (unsigned long long)__entry->sector,
174 __entry->nr_sector, __entry->errors)
177 DECLARE_EVENT_CLASS(block_rq,
179 TP_PROTO(struct request_queue *q, struct request *rq),
181 TP_ARGS(q, rq),
183 TP_STRUCT__entry(
184 __field( dev_t, dev )
185 __field( sector_t, sector )
186 __field( unsigned int, nr_sector )
187 __field( unsigned int, bytes )
188 __array( char, rwbs, RWBS_LEN )
189 __array( char, comm, TASK_COMM_LEN )
190 __dynamic_array( char, cmd, blk_cmd_buf_len(rq) )
193 TP_fast_assign(
194 __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
195 __entry->sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
196 0 : blk_rq_pos(rq);
197 __entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
198 0 : blk_rq_sectors(rq);
199 __entry->bytes = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
200 blk_rq_bytes(rq) : 0;
202 blk_fill_rwbs(__entry->rwbs, req_op(rq), rq->cmd_flags,
203 blk_rq_bytes(rq));
204 blk_dump_cmd(__get_str(cmd), rq);
205 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
208 TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
209 MAJOR(__entry->dev), MINOR(__entry->dev),
210 __entry->rwbs, __entry->bytes, __get_str(cmd),
211 (unsigned long long)__entry->sector,
212 __entry->nr_sector, __entry->comm)
216 * block_rq_insert - insert block operation request into queue
217 * @q: target queue
218 * @rq: block IO operation request
220 * Called immediately before block operation request @rq is inserted
221 * into queue @q. The fields in the operation request @rq struct can
222 * be examined to determine which device and sectors the pending
223 * operation would access.
225 DEFINE_EVENT(block_rq, block_rq_insert,
227 TP_PROTO(struct request_queue *q, struct request *rq),
229 TP_ARGS(q, rq)
233 * block_rq_issue - issue pending block IO request operation to device driver
234 * @q: queue holding operation
235 * @rq: block IO operation operation request
237 * Called when block operation request @rq from queue @q is sent to a
238 * device driver for processing.
240 DEFINE_EVENT(block_rq, block_rq_issue,
242 TP_PROTO(struct request_queue *q, struct request *rq),
244 TP_ARGS(q, rq)
248 * block_bio_bounce - used bounce buffer when processing block operation
249 * @q: queue holding the block operation
250 * @bio: block operation
252 * A bounce buffer was used to handle the block operation @bio in @q.
253 * This occurs when hardware limitations prevent a direct transfer of
254 * data between the @bio data memory area and the IO device. Use of a
255 * bounce buffer requires extra copying of data and decreases
256 * performance.
258 TRACE_EVENT(block_bio_bounce,
260 TP_PROTO(struct request_queue *q, struct bio *bio),
262 TP_ARGS(q, bio),
264 TP_STRUCT__entry(
265 __field( dev_t, dev )
266 __field( sector_t, sector )
267 __field( unsigned int, nr_sector )
268 __array( char, rwbs, RWBS_LEN )
269 __array( char, comm, TASK_COMM_LEN )
272 TP_fast_assign(
273 __entry->dev = bio->bi_bdev ?
274 bio->bi_bdev->bd_dev : 0;
275 __entry->sector = bio->bi_iter.bi_sector;
276 __entry->nr_sector = bio_sectors(bio);
277 blk_fill_rwbs(__entry->rwbs, bio_op(bio), bio->bi_opf,
278 bio->bi_iter.bi_size);
279 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
282 TP_printk("%d,%d %s %llu + %u [%s]",
283 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
284 (unsigned long long)__entry->sector,
285 __entry->nr_sector, __entry->comm)
289 * block_bio_complete - completed all work on the block operation
290 * @q: queue holding the block operation
291 * @bio: block operation completed
292 * @error: io error value
294 * This tracepoint indicates there is no further work to do on this
295 * block IO operation @bio.
297 TRACE_EVENT(block_bio_complete,
299 TP_PROTO(struct request_queue *q, struct bio *bio, int error),
301 TP_ARGS(q, bio, error),
303 TP_STRUCT__entry(
304 __field( dev_t, dev )
305 __field( sector_t, sector )
306 __field( unsigned, nr_sector )
307 __field( int, error )
308 __array( char, rwbs, RWBS_LEN)
311 TP_fast_assign(
312 __entry->dev = bio->bi_bdev->bd_dev;
313 __entry->sector = bio->bi_iter.bi_sector;
314 __entry->nr_sector = bio_sectors(bio);
315 __entry->error = error;
316 blk_fill_rwbs(__entry->rwbs, bio_op(bio), bio->bi_opf,
317 bio->bi_iter.bi_size);
320 TP_printk("%d,%d %s %llu + %u [%d]",
321 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
322 (unsigned long long)__entry->sector,
323 __entry->nr_sector, __entry->error)
326 DECLARE_EVENT_CLASS(block_bio_merge,
328 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
330 TP_ARGS(q, rq, bio),
332 TP_STRUCT__entry(
333 __field( dev_t, dev )
334 __field( sector_t, sector )
335 __field( unsigned int, nr_sector )
336 __array( char, rwbs, RWBS_LEN )
337 __array( char, comm, TASK_COMM_LEN )
340 TP_fast_assign(
341 __entry->dev = bio->bi_bdev->bd_dev;
342 __entry->sector = bio->bi_iter.bi_sector;
343 __entry->nr_sector = bio_sectors(bio);
344 blk_fill_rwbs(__entry->rwbs, bio_op(bio), bio->bi_opf,
345 bio->bi_iter.bi_size);
346 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
349 TP_printk("%d,%d %s %llu + %u [%s]",
350 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
351 (unsigned long long)__entry->sector,
352 __entry->nr_sector, __entry->comm)
356 * block_bio_backmerge - merging block operation to the end of an existing operation
357 * @q: queue holding operation
358 * @rq: request bio is being merged into
359 * @bio: new block operation to merge
361 * Merging block request @bio to the end of an existing block request
362 * in queue @q.
364 DEFINE_EVENT(block_bio_merge, block_bio_backmerge,
366 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
368 TP_ARGS(q, rq, bio)
372 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
373 * @q: queue holding operation
374 * @rq: request bio is being merged into
375 * @bio: new block operation to merge
377 * Merging block IO operation @bio to the beginning of an existing block
378 * operation in queue @q.
380 DEFINE_EVENT(block_bio_merge, block_bio_frontmerge,
382 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
384 TP_ARGS(q, rq, bio)
388 * block_bio_queue - putting new block IO operation in queue
389 * @q: queue holding operation
390 * @bio: new block operation
392 * About to place the block IO operation @bio into queue @q.
394 TRACE_EVENT(block_bio_queue,
396 TP_PROTO(struct request_queue *q, struct bio *bio),
398 TP_ARGS(q, bio),
400 TP_STRUCT__entry(
401 __field( dev_t, dev )
402 __field( sector_t, sector )
403 __field( unsigned int, nr_sector )
404 __array( char, rwbs, RWBS_LEN )
405 __array( char, comm, TASK_COMM_LEN )
408 TP_fast_assign(
409 __entry->dev = bio->bi_bdev->bd_dev;
410 __entry->sector = bio->bi_iter.bi_sector;
411 __entry->nr_sector = bio_sectors(bio);
412 blk_fill_rwbs(__entry->rwbs, bio_op(bio), bio->bi_opf,
413 bio->bi_iter.bi_size);
414 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
417 TP_printk("%d,%d %s %llu + %u [%s]",
418 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
419 (unsigned long long)__entry->sector,
420 __entry->nr_sector, __entry->comm)
423 DECLARE_EVENT_CLASS(block_get_rq,
425 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
427 TP_ARGS(q, bio, rw),
429 TP_STRUCT__entry(
430 __field( dev_t, dev )
431 __field( sector_t, sector )
432 __field( unsigned int, nr_sector )
433 __array( char, rwbs, RWBS_LEN )
434 __array( char, comm, TASK_COMM_LEN )
437 TP_fast_assign(
438 __entry->dev = bio ? bio->bi_bdev->bd_dev : 0;
439 __entry->sector = bio ? bio->bi_iter.bi_sector : 0;
440 __entry->nr_sector = bio ? bio_sectors(bio) : 0;
441 blk_fill_rwbs(__entry->rwbs, bio ? bio_op(bio) : 0,
442 bio ? bio->bi_opf : 0, __entry->nr_sector);
443 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
446 TP_printk("%d,%d %s %llu + %u [%s]",
447 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
448 (unsigned long long)__entry->sector,
449 __entry->nr_sector, __entry->comm)
453 * block_getrq - get a free request entry in queue for block IO operations
454 * @q: queue for operations
455 * @bio: pending block IO operation
456 * @rw: low bit indicates a read (%0) or a write (%1)
458 * A request struct for queue @q has been allocated to handle the
459 * block IO operation @bio.
461 DEFINE_EVENT(block_get_rq, block_getrq,
463 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
465 TP_ARGS(q, bio, rw)
469 * block_sleeprq - waiting to get a free request entry in queue for block IO operation
470 * @q: queue for operation
471 * @bio: pending block IO operation
472 * @rw: low bit indicates a read (%0) or a write (%1)
474 * In the case where a request struct cannot be provided for queue @q
475 * the process needs to wait for an request struct to become
476 * available. This tracepoint event is generated each time the
477 * process goes to sleep waiting for request struct become available.
479 DEFINE_EVENT(block_get_rq, block_sleeprq,
481 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
483 TP_ARGS(q, bio, rw)
487 * block_plug - keep operations requests in request queue
488 * @q: request queue to plug
490 * Plug the request queue @q. Do not allow block operation requests
491 * to be sent to the device driver. Instead, accumulate requests in
492 * the queue to improve throughput performance of the block device.
494 TRACE_EVENT(block_plug,
496 TP_PROTO(struct request_queue *q),
498 TP_ARGS(q),
500 TP_STRUCT__entry(
501 __array( char, comm, TASK_COMM_LEN )
504 TP_fast_assign(
505 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
508 TP_printk("[%s]", __entry->comm)
511 DECLARE_EVENT_CLASS(block_unplug,
513 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
515 TP_ARGS(q, depth, explicit),
517 TP_STRUCT__entry(
518 __field( int, nr_rq )
519 __array( char, comm, TASK_COMM_LEN )
522 TP_fast_assign(
523 __entry->nr_rq = depth;
524 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
527 TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
531 * block_unplug - release of operations requests in request queue
532 * @q: request queue to unplug
533 * @depth: number of requests just added to the queue
534 * @explicit: whether this was an explicit unplug, or one from schedule()
536 * Unplug request queue @q because device driver is scheduled to work
537 * on elements in the request queue.
539 DEFINE_EVENT(block_unplug, block_unplug,
541 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
543 TP_ARGS(q, depth, explicit)
547 * block_split - split a single bio struct into two bio structs
548 * @q: queue containing the bio
549 * @bio: block operation being split
550 * @new_sector: The starting sector for the new bio
552 * The bio request @bio in request queue @q needs to be split into two
553 * bio requests. The newly created @bio request starts at
554 * @new_sector. This split may be required due to hardware limitation
555 * such as operation crossing device boundaries in a RAID system.
557 TRACE_EVENT(block_split,
559 TP_PROTO(struct request_queue *q, struct bio *bio,
560 unsigned int new_sector),
562 TP_ARGS(q, bio, new_sector),
564 TP_STRUCT__entry(
565 __field( dev_t, dev )
566 __field( sector_t, sector )
567 __field( sector_t, new_sector )
568 __array( char, rwbs, RWBS_LEN )
569 __array( char, comm, TASK_COMM_LEN )
572 TP_fast_assign(
573 __entry->dev = bio->bi_bdev->bd_dev;
574 __entry->sector = bio->bi_iter.bi_sector;
575 __entry->new_sector = new_sector;
576 blk_fill_rwbs(__entry->rwbs, bio_op(bio), bio->bi_opf,
577 bio->bi_iter.bi_size);
578 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
581 TP_printk("%d,%d %s %llu / %llu [%s]",
582 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
583 (unsigned long long)__entry->sector,
584 (unsigned long long)__entry->new_sector,
585 __entry->comm)
589 * block_bio_remap - map request for a logical device to the raw device
590 * @q: queue holding the operation
591 * @bio: revised operation
592 * @dev: device for the operation
593 * @from: original sector for the operation
595 * An operation for a logical device has been mapped to the
596 * raw block device.
598 TRACE_EVENT(block_bio_remap,
600 TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
601 sector_t from),
603 TP_ARGS(q, bio, dev, from),
605 TP_STRUCT__entry(
606 __field( dev_t, dev )
607 __field( sector_t, sector )
608 __field( unsigned int, nr_sector )
609 __field( dev_t, old_dev )
610 __field( sector_t, old_sector )
611 __array( char, rwbs, RWBS_LEN)
614 TP_fast_assign(
615 __entry->dev = bio->bi_bdev->bd_dev;
616 __entry->sector = bio->bi_iter.bi_sector;
617 __entry->nr_sector = bio_sectors(bio);
618 __entry->old_dev = dev;
619 __entry->old_sector = from;
620 blk_fill_rwbs(__entry->rwbs, bio_op(bio), bio->bi_opf,
621 bio->bi_iter.bi_size);
624 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
625 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
626 (unsigned long long)__entry->sector,
627 __entry->nr_sector,
628 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
629 (unsigned long long)__entry->old_sector)
633 * block_rq_remap - map request for a block operation request
634 * @q: queue holding the operation
635 * @rq: block IO operation request
636 * @dev: device for the operation
637 * @from: original sector for the operation
639 * The block operation request @rq in @q has been remapped. The block
640 * operation request @rq holds the current information and @from hold
641 * the original sector.
643 TRACE_EVENT(block_rq_remap,
645 TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
646 sector_t from),
648 TP_ARGS(q, rq, dev, from),
650 TP_STRUCT__entry(
651 __field( dev_t, dev )
652 __field( sector_t, sector )
653 __field( unsigned int, nr_sector )
654 __field( dev_t, old_dev )
655 __field( sector_t, old_sector )
656 __field( unsigned int, nr_bios )
657 __array( char, rwbs, RWBS_LEN)
660 TP_fast_assign(
661 __entry->dev = disk_devt(rq->rq_disk);
662 __entry->sector = blk_rq_pos(rq);
663 __entry->nr_sector = blk_rq_sectors(rq);
664 __entry->old_dev = dev;
665 __entry->old_sector = from;
666 __entry->nr_bios = blk_rq_count_bios(rq);
667 blk_fill_rwbs(__entry->rwbs, req_op(rq), rq->cmd_flags,
668 blk_rq_bytes(rq));
671 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u",
672 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
673 (unsigned long long)__entry->sector,
674 __entry->nr_sector,
675 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
676 (unsigned long long)__entry->old_sector, __entry->nr_bios)
679 #endif /* _TRACE_BLOCK_H */
681 /* This part must be outside protection */
682 #include <trace/define_trace.h>