xref: /openbmc/linux/include/trace/events/block.h (revision 75afb352991ff1cd3cf5955bfe611de6d83a0c87)
1d0b6e04aSLi Zefan #undef TRACE_SYSTEM
2d0b6e04aSLi Zefan #define TRACE_SYSTEM block
3d0b6e04aSLi Zefan 
455782138SLi Zefan #if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
555782138SLi Zefan #define _TRACE_BLOCK_H
655782138SLi Zefan 
755782138SLi Zefan #include <linux/blktrace_api.h>
855782138SLi Zefan #include <linux/blkdev.h>
95305cb83STejun Heo #include <linux/buffer_head.h>
1055782138SLi Zefan #include <linux/tracepoint.h>
1155782138SLi Zefan 
12c09c47caSNamhyung Kim #define RWBS_LEN	8
13c09c47caSNamhyung Kim 
145305cb83STejun Heo DECLARE_EVENT_CLASS(block_buffer,
155305cb83STejun Heo 
165305cb83STejun Heo 	TP_PROTO(struct buffer_head *bh),
175305cb83STejun Heo 
185305cb83STejun Heo 	TP_ARGS(bh),
195305cb83STejun Heo 
205305cb83STejun Heo 	TP_STRUCT__entry (
215305cb83STejun Heo 		__field(  dev_t,	dev			)
225305cb83STejun Heo 		__field(  sector_t,	sector			)
235305cb83STejun Heo 		__field(  size_t,	size			)
245305cb83STejun Heo 	),
255305cb83STejun Heo 
265305cb83STejun Heo 	TP_fast_assign(
275305cb83STejun Heo 		__entry->dev		= bh->b_bdev->bd_dev;
285305cb83STejun Heo 		__entry->sector		= bh->b_blocknr;
295305cb83STejun Heo 		__entry->size		= bh->b_size;
305305cb83STejun Heo 	),
315305cb83STejun Heo 
325305cb83STejun Heo 	TP_printk("%d,%d sector=%llu size=%zu",
335305cb83STejun Heo 		MAJOR(__entry->dev), MINOR(__entry->dev),
345305cb83STejun Heo 		(unsigned long long)__entry->sector, __entry->size
355305cb83STejun Heo 	)
365305cb83STejun Heo );
375305cb83STejun Heo 
385305cb83STejun Heo /**
395305cb83STejun Heo  * block_touch_buffer - mark a buffer accessed
405305cb83STejun Heo  * @bh: buffer_head being touched
415305cb83STejun Heo  *
425305cb83STejun Heo  * Called from touch_buffer().
435305cb83STejun Heo  */
445305cb83STejun Heo DEFINE_EVENT(block_buffer, block_touch_buffer,
455305cb83STejun Heo 
465305cb83STejun Heo 	TP_PROTO(struct buffer_head *bh),
475305cb83STejun Heo 
485305cb83STejun Heo 	TP_ARGS(bh)
495305cb83STejun Heo );
505305cb83STejun Heo 
515305cb83STejun Heo /**
525305cb83STejun Heo  * block_dirty_buffer - mark a buffer dirty
535305cb83STejun Heo  * @bh: buffer_head being dirtied
545305cb83STejun Heo  *
555305cb83STejun Heo  * Called from mark_buffer_dirty().
565305cb83STejun Heo  */
575305cb83STejun Heo DEFINE_EVENT(block_buffer, block_dirty_buffer,
585305cb83STejun Heo 
595305cb83STejun Heo 	TP_PROTO(struct buffer_head *bh),
605305cb83STejun Heo 
615305cb83STejun Heo 	TP_ARGS(bh)
625305cb83STejun Heo );
635305cb83STejun Heo 
6477ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_rq_with_error,
6555782138SLi Zefan 
6655782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct request *rq),
6755782138SLi Zefan 
6855782138SLi Zefan 	TP_ARGS(q, rq),
6955782138SLi Zefan 
7055782138SLi Zefan 	TP_STRUCT__entry(
7155782138SLi Zefan 		__field(  dev_t,	dev			)
7255782138SLi Zefan 		__field(  sector_t,	sector			)
7355782138SLi Zefan 		__field(  unsigned int,	nr_sector		)
7455782138SLi Zefan 		__field(  int,		errors			)
75c09c47caSNamhyung Kim 		__array(  char,		rwbs,	RWBS_LEN	)
7655782138SLi Zefan 		__dynamic_array( char,	cmd,	blk_cmd_buf_len(rq)	)
7755782138SLi Zefan 	),
7855782138SLi Zefan 
7955782138SLi Zefan 	TP_fast_assign(
8055782138SLi Zefan 		__entry->dev	   = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
8133659ebbSChristoph Hellwig 		__entry->sector    = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
8233659ebbSChristoph Hellwig 					0 : blk_rq_pos(rq);
8333659ebbSChristoph Hellwig 		__entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
8433659ebbSChristoph Hellwig 					0 : blk_rq_sectors(rq);
8555782138SLi Zefan 		__entry->errors    = rq->errors;
8655782138SLi Zefan 
872d3a8497STao Ma 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
8855782138SLi Zefan 		blk_dump_cmd(__get_str(cmd), rq);
8955782138SLi Zefan 	),
9055782138SLi Zefan 
9155782138SLi Zefan 	TP_printk("%d,%d %s (%s) %llu + %u [%d]",
9255782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev),
9355782138SLi Zefan 		  __entry->rwbs, __get_str(cmd),
946556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
956556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->errors)
9655782138SLi Zefan );
9755782138SLi Zefan 
98881245dcSWilliam Cohen /**
99881245dcSWilliam Cohen  * block_rq_abort - abort block operation request
100881245dcSWilliam Cohen  * @q: queue containing the block operation request
101881245dcSWilliam Cohen  * @rq: block IO operation request
102881245dcSWilliam Cohen  *
103881245dcSWilliam Cohen  * Called immediately after pending block IO operation request @rq in
104881245dcSWilliam Cohen  * queue @q is aborted. The fields in the operation request @rq
105881245dcSWilliam Cohen  * can be examined to determine which device and sectors the pending
106881245dcSWilliam Cohen  * operation would access.
107881245dcSWilliam Cohen  */
10877ca1e02SLi Zefan DEFINE_EVENT(block_rq_with_error, block_rq_abort,
10977ca1e02SLi Zefan 
11077ca1e02SLi Zefan 	TP_PROTO(struct request_queue *q, struct request *rq),
11177ca1e02SLi Zefan 
11277ca1e02SLi Zefan 	TP_ARGS(q, rq)
11377ca1e02SLi Zefan );
11477ca1e02SLi Zefan 
115881245dcSWilliam Cohen /**
116881245dcSWilliam Cohen  * block_rq_requeue - place block IO request back on a queue
117881245dcSWilliam Cohen  * @q: queue holding operation
118881245dcSWilliam Cohen  * @rq: block IO operation request
119881245dcSWilliam Cohen  *
120881245dcSWilliam Cohen  * The block operation request @rq is being placed back into queue
121881245dcSWilliam Cohen  * @q.  For some reason the request was not completed and needs to be
122881245dcSWilliam Cohen  * put back in the queue.
123881245dcSWilliam Cohen  */
12477ca1e02SLi Zefan DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
12577ca1e02SLi Zefan 
12677ca1e02SLi Zefan 	TP_PROTO(struct request_queue *q, struct request *rq),
12777ca1e02SLi Zefan 
12877ca1e02SLi Zefan 	TP_ARGS(q, rq)
12977ca1e02SLi Zefan );
13077ca1e02SLi Zefan 
131881245dcSWilliam Cohen /**
132881245dcSWilliam Cohen  * block_rq_complete - block IO operation completed by device driver
133881245dcSWilliam Cohen  * @q: queue containing the block operation request
134881245dcSWilliam Cohen  * @rq: block operations request
135881245dcSWilliam Cohen  *
136881245dcSWilliam Cohen  * The block_rq_complete tracepoint event indicates that some portion
137881245dcSWilliam Cohen  * of operation request has been completed by the device driver.  If
138881245dcSWilliam Cohen  * the @rq->bio is %NULL, then there is absolutely no additional work to
139881245dcSWilliam Cohen  * do for the request. If @rq->bio is non-NULL then there is
140881245dcSWilliam Cohen  * additional work required to complete the request.
141881245dcSWilliam Cohen  */
14277ca1e02SLi Zefan DEFINE_EVENT(block_rq_with_error, block_rq_complete,
14377ca1e02SLi Zefan 
14477ca1e02SLi Zefan 	TP_PROTO(struct request_queue *q, struct request *rq),
14577ca1e02SLi Zefan 
14677ca1e02SLi Zefan 	TP_ARGS(q, rq)
14777ca1e02SLi Zefan );
14877ca1e02SLi Zefan 
14977ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_rq,
15055782138SLi Zefan 
15155782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct request *rq),
15255782138SLi Zefan 
15355782138SLi Zefan 	TP_ARGS(q, rq),
15455782138SLi Zefan 
15555782138SLi Zefan 	TP_STRUCT__entry(
15655782138SLi Zefan 		__field(  dev_t,	dev			)
15755782138SLi Zefan 		__field(  sector_t,	sector			)
15855782138SLi Zefan 		__field(  unsigned int,	nr_sector		)
15955782138SLi Zefan 		__field(  unsigned int,	bytes			)
160c09c47caSNamhyung Kim 		__array(  char,		rwbs,	RWBS_LEN	)
16155782138SLi Zefan 		__array(  char,         comm,   TASK_COMM_LEN   )
16255782138SLi Zefan 		__dynamic_array( char,	cmd,	blk_cmd_buf_len(rq)	)
16355782138SLi Zefan 	),
16455782138SLi Zefan 
16555782138SLi Zefan 	TP_fast_assign(
16655782138SLi Zefan 		__entry->dev	   = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
16733659ebbSChristoph Hellwig 		__entry->sector    = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
16833659ebbSChristoph Hellwig 					0 : blk_rq_pos(rq);
16933659ebbSChristoph Hellwig 		__entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
17033659ebbSChristoph Hellwig 					0 : blk_rq_sectors(rq);
17133659ebbSChristoph Hellwig 		__entry->bytes     = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
17233659ebbSChristoph Hellwig 					blk_rq_bytes(rq) : 0;
17355782138SLi Zefan 
1742d3a8497STao Ma 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
17555782138SLi Zefan 		blk_dump_cmd(__get_str(cmd), rq);
17655782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
17755782138SLi Zefan 	),
17855782138SLi Zefan 
17955782138SLi Zefan 	TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
18055782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev),
18155782138SLi Zefan 		  __entry->rwbs, __entry->bytes, __get_str(cmd),
1826556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
1836556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->comm)
18455782138SLi Zefan );
18555782138SLi Zefan 
186881245dcSWilliam Cohen /**
187881245dcSWilliam Cohen  * block_rq_insert - insert block operation request into queue
188881245dcSWilliam Cohen  * @q: target queue
189881245dcSWilliam Cohen  * @rq: block IO operation request
190881245dcSWilliam Cohen  *
191881245dcSWilliam Cohen  * Called immediately before block operation request @rq is inserted
192881245dcSWilliam Cohen  * into queue @q.  The fields in the operation request @rq struct can
193881245dcSWilliam Cohen  * be examined to determine which device and sectors the pending
194881245dcSWilliam Cohen  * operation would access.
195881245dcSWilliam Cohen  */
19677ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_insert,
19755782138SLi Zefan 
19855782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct request *rq),
19955782138SLi Zefan 
20077ca1e02SLi Zefan 	TP_ARGS(q, rq)
20155782138SLi Zefan );
20255782138SLi Zefan 
203881245dcSWilliam Cohen /**
204881245dcSWilliam Cohen  * block_rq_issue - issue pending block IO request operation to device driver
205881245dcSWilliam Cohen  * @q: queue holding operation
206881245dcSWilliam Cohen  * @rq: block IO operation operation request
207881245dcSWilliam Cohen  *
208881245dcSWilliam Cohen  * Called when block operation request @rq from queue @q is sent to a
209881245dcSWilliam Cohen  * device driver for processing.
210881245dcSWilliam Cohen  */
21177ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_issue,
21255782138SLi Zefan 
21355782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct request *rq),
21455782138SLi Zefan 
21577ca1e02SLi Zefan 	TP_ARGS(q, rq)
21655782138SLi Zefan );
217fe63b94aSCarsten Emde 
218881245dcSWilliam Cohen /**
219881245dcSWilliam Cohen  * block_bio_bounce - used bounce buffer when processing block operation
220881245dcSWilliam Cohen  * @q: queue holding the block operation
221881245dcSWilliam Cohen  * @bio: block operation
222881245dcSWilliam Cohen  *
223881245dcSWilliam Cohen  * A bounce buffer was used to handle the block operation @bio in @q.
224881245dcSWilliam Cohen  * This occurs when hardware limitations prevent a direct transfer of
225881245dcSWilliam Cohen  * data between the @bio data memory area and the IO device.  Use of a
226881245dcSWilliam Cohen  * bounce buffer requires extra copying of data and decreases
227881245dcSWilliam Cohen  * performance.
228881245dcSWilliam Cohen  */
22955782138SLi Zefan TRACE_EVENT(block_bio_bounce,
23055782138SLi Zefan 
23155782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio),
23255782138SLi Zefan 
23355782138SLi Zefan 	TP_ARGS(q, bio),
23455782138SLi Zefan 
23555782138SLi Zefan 	TP_STRUCT__entry(
23655782138SLi Zefan 		__field( dev_t,		dev			)
23755782138SLi Zefan 		__field( sector_t,	sector			)
23855782138SLi Zefan 		__field( unsigned int,	nr_sector		)
239c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN	)
24055782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
24155782138SLi Zefan 	),
24255782138SLi Zefan 
24355782138SLi Zefan 	TP_fast_assign(
244fe63b94aSCarsten Emde 		__entry->dev		= bio->bi_bdev ?
245fe63b94aSCarsten Emde 					  bio->bi_bdev->bd_dev : 0;
24655782138SLi Zefan 		__entry->sector		= bio->bi_sector;
247aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
24855782138SLi Zefan 		blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
24955782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
25055782138SLi Zefan 	),
25155782138SLi Zefan 
25255782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u [%s]",
25355782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
2546556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
2556556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->comm)
25655782138SLi Zefan );
25755782138SLi Zefan 
258881245dcSWilliam Cohen /**
259881245dcSWilliam Cohen  * block_bio_complete - completed all work on the block operation
2600a82a8d1SLinus Torvalds  * @q: queue holding the block operation
261881245dcSWilliam Cohen  * @bio: block operation completed
262b7908c10SJeff Moyer  * @error: io error value
263881245dcSWilliam Cohen  *
264881245dcSWilliam Cohen  * This tracepoint indicates there is no further work to do on this
265881245dcSWilliam Cohen  * block IO operation @bio.
266881245dcSWilliam Cohen  */
26755782138SLi Zefan TRACE_EVENT(block_bio_complete,
26855782138SLi Zefan 
2690a82a8d1SLinus Torvalds 	TP_PROTO(struct request_queue *q, struct bio *bio, int error),
27055782138SLi Zefan 
2710a82a8d1SLinus Torvalds 	TP_ARGS(q, bio, error),
27255782138SLi Zefan 
27355782138SLi Zefan 	TP_STRUCT__entry(
27455782138SLi Zefan 		__field( dev_t,		dev		)
27555782138SLi Zefan 		__field( sector_t,	sector		)
27655782138SLi Zefan 		__field( unsigned,	nr_sector	)
27755782138SLi Zefan 		__field( int,		error		)
278c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN)
27955782138SLi Zefan 	),
28055782138SLi Zefan 
28155782138SLi Zefan 	TP_fast_assign(
2820a82a8d1SLinus Torvalds 		__entry->dev		= bio->bi_bdev->bd_dev;
28355782138SLi Zefan 		__entry->sector		= bio->bi_sector;
284aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
285b7908c10SJeff Moyer 		__entry->error		= error;
28655782138SLi Zefan 		blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
28755782138SLi Zefan 	),
28855782138SLi Zefan 
28955782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u [%d]",
29055782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
2916556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
2926556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->error)
29355782138SLi Zefan );
29455782138SLi Zefan 
2958c1cf6bbSTejun Heo DECLARE_EVENT_CLASS(block_bio_merge,
29655782138SLi Zefan 
2978c1cf6bbSTejun Heo 	TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
29855782138SLi Zefan 
2998c1cf6bbSTejun Heo 	TP_ARGS(q, rq, bio),
30055782138SLi Zefan 
30155782138SLi Zefan 	TP_STRUCT__entry(
30255782138SLi Zefan 		__field( dev_t,		dev			)
30355782138SLi Zefan 		__field( sector_t,	sector			)
30455782138SLi Zefan 		__field( unsigned int,	nr_sector		)
305c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN	)
30655782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
30755782138SLi Zefan 	),
30855782138SLi Zefan 
30955782138SLi Zefan 	TP_fast_assign(
31055782138SLi Zefan 		__entry->dev		= bio->bi_bdev->bd_dev;
31155782138SLi Zefan 		__entry->sector		= bio->bi_sector;
312aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
31355782138SLi Zefan 		blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
31455782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
31555782138SLi Zefan 	),
31655782138SLi Zefan 
31755782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u [%s]",
31855782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
3196556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
3206556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->comm)
32155782138SLi Zefan );
32255782138SLi Zefan 
323881245dcSWilliam Cohen /**
324881245dcSWilliam Cohen  * block_bio_backmerge - merging block operation to the end of an existing operation
325881245dcSWilliam Cohen  * @q: queue holding operation
3268c1cf6bbSTejun Heo  * @rq: request bio is being merged into
327881245dcSWilliam Cohen  * @bio: new block operation to merge
328881245dcSWilliam Cohen  *
329881245dcSWilliam Cohen  * Merging block request @bio to the end of an existing block request
330881245dcSWilliam Cohen  * in queue @q.
331881245dcSWilliam Cohen  */
3328c1cf6bbSTejun Heo DEFINE_EVENT(block_bio_merge, block_bio_backmerge,
33355782138SLi Zefan 
3348c1cf6bbSTejun Heo 	TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
33555782138SLi Zefan 
3368c1cf6bbSTejun Heo 	TP_ARGS(q, rq, bio)
33755782138SLi Zefan );
33855782138SLi Zefan 
339881245dcSWilliam Cohen /**
340881245dcSWilliam Cohen  * block_bio_frontmerge - merging block operation to the beginning of an existing operation
341881245dcSWilliam Cohen  * @q: queue holding operation
3428c1cf6bbSTejun Heo  * @rq: request bio is being merged into
343881245dcSWilliam Cohen  * @bio: new block operation to merge
344881245dcSWilliam Cohen  *
345881245dcSWilliam Cohen  * Merging block IO operation @bio to the beginning of an existing block
346881245dcSWilliam Cohen  * operation in queue @q.
347881245dcSWilliam Cohen  */
3488c1cf6bbSTejun Heo DEFINE_EVENT(block_bio_merge, block_bio_frontmerge,
34955782138SLi Zefan 
3508c1cf6bbSTejun Heo 	TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
35155782138SLi Zefan 
3528c1cf6bbSTejun Heo 	TP_ARGS(q, rq, bio)
35355782138SLi Zefan );
35455782138SLi Zefan 
355881245dcSWilliam Cohen /**
356881245dcSWilliam Cohen  * block_bio_queue - putting new block IO operation in queue
357881245dcSWilliam Cohen  * @q: queue holding operation
358881245dcSWilliam Cohen  * @bio: new block operation
359881245dcSWilliam Cohen  *
360881245dcSWilliam Cohen  * About to place the block IO operation @bio into queue @q.
361881245dcSWilliam Cohen  */
3628c1cf6bbSTejun Heo TRACE_EVENT(block_bio_queue,
36377ca1e02SLi Zefan 
36477ca1e02SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio),
36577ca1e02SLi Zefan 
3668c1cf6bbSTejun Heo 	TP_ARGS(q, bio),
3678c1cf6bbSTejun Heo 
3688c1cf6bbSTejun Heo 	TP_STRUCT__entry(
3698c1cf6bbSTejun Heo 		__field( dev_t,		dev			)
3708c1cf6bbSTejun Heo 		__field( sector_t,	sector			)
3718c1cf6bbSTejun Heo 		__field( unsigned int,	nr_sector		)
3728c1cf6bbSTejun Heo 		__array( char,		rwbs,	RWBS_LEN	)
3738c1cf6bbSTejun Heo 		__array( char,		comm,	TASK_COMM_LEN	)
3748c1cf6bbSTejun Heo 	),
3758c1cf6bbSTejun Heo 
3768c1cf6bbSTejun Heo 	TP_fast_assign(
3778c1cf6bbSTejun Heo 		__entry->dev		= bio->bi_bdev->bd_dev;
3788c1cf6bbSTejun Heo 		__entry->sector		= bio->bi_sector;
379aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
3808c1cf6bbSTejun Heo 		blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
3818c1cf6bbSTejun Heo 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
3828c1cf6bbSTejun Heo 	),
3838c1cf6bbSTejun Heo 
3848c1cf6bbSTejun Heo 	TP_printk("%d,%d %s %llu + %u [%s]",
3858c1cf6bbSTejun Heo 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
3868c1cf6bbSTejun Heo 		  (unsigned long long)__entry->sector,
3878c1cf6bbSTejun Heo 		  __entry->nr_sector, __entry->comm)
38877ca1e02SLi Zefan );
38977ca1e02SLi Zefan 
39077ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_get_rq,
39155782138SLi Zefan 
39255782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
39355782138SLi Zefan 
39455782138SLi Zefan 	TP_ARGS(q, bio, rw),
39555782138SLi Zefan 
39655782138SLi Zefan 	TP_STRUCT__entry(
39755782138SLi Zefan 		__field( dev_t,		dev			)
39855782138SLi Zefan 		__field( sector_t,	sector			)
39955782138SLi Zefan 		__field( unsigned int,	nr_sector		)
400c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN	)
40155782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
40255782138SLi Zefan         ),
40355782138SLi Zefan 
40455782138SLi Zefan 	TP_fast_assign(
40555782138SLi Zefan 		__entry->dev		= bio ? bio->bi_bdev->bd_dev : 0;
40655782138SLi Zefan 		__entry->sector		= bio ? bio->bi_sector : 0;
407aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio ? bio_sectors(bio) : 0;
40855782138SLi Zefan 		blk_fill_rwbs(__entry->rwbs,
40955782138SLi Zefan 			      bio ? bio->bi_rw : 0, __entry->nr_sector);
41055782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
41155782138SLi Zefan         ),
41255782138SLi Zefan 
41355782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u [%s]",
41455782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
4156556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
4166556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->comm)
41755782138SLi Zefan );
41855782138SLi Zefan 
419881245dcSWilliam Cohen /**
420881245dcSWilliam Cohen  * block_getrq - get a free request entry in queue for block IO operations
421881245dcSWilliam Cohen  * @q: queue for operations
422881245dcSWilliam Cohen  * @bio: pending block IO operation
423881245dcSWilliam Cohen  * @rw: low bit indicates a read (%0) or a write (%1)
424881245dcSWilliam Cohen  *
425881245dcSWilliam Cohen  * A request struct for queue @q has been allocated to handle the
426881245dcSWilliam Cohen  * block IO operation @bio.
427881245dcSWilliam Cohen  */
42877ca1e02SLi Zefan DEFINE_EVENT(block_get_rq, block_getrq,
42955782138SLi Zefan 
43055782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
43155782138SLi Zefan 
43277ca1e02SLi Zefan 	TP_ARGS(q, bio, rw)
43377ca1e02SLi Zefan );
43455782138SLi Zefan 
435881245dcSWilliam Cohen /**
436881245dcSWilliam Cohen  * block_sleeprq - waiting to get a free request entry in queue for block IO operation
437881245dcSWilliam Cohen  * @q: queue for operation
438881245dcSWilliam Cohen  * @bio: pending block IO operation
439881245dcSWilliam Cohen  * @rw: low bit indicates a read (%0) or a write (%1)
440881245dcSWilliam Cohen  *
441881245dcSWilliam Cohen  * In the case where a request struct cannot be provided for queue @q
442881245dcSWilliam Cohen  * the process needs to wait for an request struct to become
443881245dcSWilliam Cohen  * available.  This tracepoint event is generated each time the
444881245dcSWilliam Cohen  * process goes to sleep waiting for request struct become available.
445881245dcSWilliam Cohen  */
44677ca1e02SLi Zefan DEFINE_EVENT(block_get_rq, block_sleeprq,
44755782138SLi Zefan 
44877ca1e02SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
44955782138SLi Zefan 
45077ca1e02SLi Zefan 	TP_ARGS(q, bio, rw)
45155782138SLi Zefan );
45255782138SLi Zefan 
453881245dcSWilliam Cohen /**
454881245dcSWilliam Cohen  * block_plug - keep operations requests in request queue
455881245dcSWilliam Cohen  * @q: request queue to plug
456881245dcSWilliam Cohen  *
457881245dcSWilliam Cohen  * Plug the request queue @q.  Do not allow block operation requests
458881245dcSWilliam Cohen  * to be sent to the device driver. Instead, accumulate requests in
459881245dcSWilliam Cohen  * the queue to improve throughput performance of the block device.
460881245dcSWilliam Cohen  */
46155782138SLi Zefan TRACE_EVENT(block_plug,
46255782138SLi Zefan 
46355782138SLi Zefan 	TP_PROTO(struct request_queue *q),
46455782138SLi Zefan 
46555782138SLi Zefan 	TP_ARGS(q),
46655782138SLi Zefan 
46755782138SLi Zefan 	TP_STRUCT__entry(
46855782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
46955782138SLi Zefan 	),
47055782138SLi Zefan 
47155782138SLi Zefan 	TP_fast_assign(
47255782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
47355782138SLi Zefan 	),
47455782138SLi Zefan 
47555782138SLi Zefan 	TP_printk("[%s]", __entry->comm)
47655782138SLi Zefan );
47755782138SLi Zefan 
47877ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_unplug,
47955782138SLi Zefan 
48049cac01eSJens Axboe 	TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
48155782138SLi Zefan 
48249cac01eSJens Axboe 	TP_ARGS(q, depth, explicit),
48355782138SLi Zefan 
48455782138SLi Zefan 	TP_STRUCT__entry(
48555782138SLi Zefan 		__field( int,		nr_rq			)
48655782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
48755782138SLi Zefan 	),
48855782138SLi Zefan 
48955782138SLi Zefan 	TP_fast_assign(
49094b5eb28SJens Axboe 		__entry->nr_rq = depth;
49155782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
49255782138SLi Zefan 	),
49355782138SLi Zefan 
49455782138SLi Zefan 	TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
49555782138SLi Zefan );
49655782138SLi Zefan 
497881245dcSWilliam Cohen /**
49849cac01eSJens Axboe  * block_unplug - release of operations requests in request queue
499881245dcSWilliam Cohen  * @q: request queue to unplug
50094b5eb28SJens Axboe  * @depth: number of requests just added to the queue
50149cac01eSJens Axboe  * @explicit: whether this was an explicit unplug, or one from schedule()
502881245dcSWilliam Cohen  *
503881245dcSWilliam Cohen  * Unplug request queue @q because device driver is scheduled to work
504881245dcSWilliam Cohen  * on elements in the request queue.
505881245dcSWilliam Cohen  */
50649cac01eSJens Axboe DEFINE_EVENT(block_unplug, block_unplug,
50755782138SLi Zefan 
50849cac01eSJens Axboe 	TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
50955782138SLi Zefan 
51049cac01eSJens Axboe 	TP_ARGS(q, depth, explicit)
51155782138SLi Zefan );
51255782138SLi Zefan 
513881245dcSWilliam Cohen /**
514881245dcSWilliam Cohen  * block_split - split a single bio struct into two bio structs
515881245dcSWilliam Cohen  * @q: queue containing the bio
516881245dcSWilliam Cohen  * @bio: block operation being split
517881245dcSWilliam Cohen  * @new_sector: The starting sector for the new bio
518881245dcSWilliam Cohen  *
519881245dcSWilliam Cohen  * The bio request @bio in request queue @q needs to be split into two
520881245dcSWilliam Cohen  * bio requests. The newly created @bio request starts at
521881245dcSWilliam Cohen  * @new_sector. This split may be required due to hardware limitation
522881245dcSWilliam Cohen  * such as operation crossing device boundaries in a RAID system.
523881245dcSWilliam Cohen  */
52455782138SLi Zefan TRACE_EVENT(block_split,
52555782138SLi Zefan 
52655782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio,
52755782138SLi Zefan 		 unsigned int new_sector),
52855782138SLi Zefan 
52955782138SLi Zefan 	TP_ARGS(q, bio, new_sector),
53055782138SLi Zefan 
53155782138SLi Zefan 	TP_STRUCT__entry(
53255782138SLi Zefan 		__field( dev_t,		dev				)
53355782138SLi Zefan 		__field( sector_t,	sector				)
53455782138SLi Zefan 		__field( sector_t,	new_sector			)
535c09c47caSNamhyung Kim 		__array( char,		rwbs,		RWBS_LEN	)
53655782138SLi Zefan 		__array( char,		comm,		TASK_COMM_LEN	)
53755782138SLi Zefan 	),
53855782138SLi Zefan 
53955782138SLi Zefan 	TP_fast_assign(
54055782138SLi Zefan 		__entry->dev		= bio->bi_bdev->bd_dev;
54155782138SLi Zefan 		__entry->sector		= bio->bi_sector;
54255782138SLi Zefan 		__entry->new_sector	= new_sector;
54355782138SLi Zefan 		blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
54455782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
54555782138SLi Zefan 	),
54655782138SLi Zefan 
54755782138SLi Zefan 	TP_printk("%d,%d %s %llu / %llu [%s]",
54855782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
5496556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
5506556d1dfSSteven Rostedt 		  (unsigned long long)__entry->new_sector,
5516556d1dfSSteven Rostedt 		  __entry->comm)
55255782138SLi Zefan );
55355782138SLi Zefan 
554881245dcSWilliam Cohen /**
555d07335e5SMike Snitzer  * block_bio_remap - map request for a logical device to the raw device
556881245dcSWilliam Cohen  * @q: queue holding the operation
557881245dcSWilliam Cohen  * @bio: revised operation
558881245dcSWilliam Cohen  * @dev: device for the operation
559881245dcSWilliam Cohen  * @from: original sector for the operation
560881245dcSWilliam Cohen  *
561d07335e5SMike Snitzer  * An operation for a logical device has been mapped to the
562881245dcSWilliam Cohen  * raw block device.
563881245dcSWilliam Cohen  */
564d07335e5SMike Snitzer TRACE_EVENT(block_bio_remap,
56555782138SLi Zefan 
56655782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
56755782138SLi Zefan 		 sector_t from),
56855782138SLi Zefan 
56955782138SLi Zefan 	TP_ARGS(q, bio, dev, from),
57055782138SLi Zefan 
57155782138SLi Zefan 	TP_STRUCT__entry(
57255782138SLi Zefan 		__field( dev_t,		dev		)
57355782138SLi Zefan 		__field( sector_t,	sector		)
57455782138SLi Zefan 		__field( unsigned int,	nr_sector	)
57555782138SLi Zefan 		__field( dev_t,		old_dev		)
57655782138SLi Zefan 		__field( sector_t,	old_sector	)
577c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN)
57855782138SLi Zefan 	),
57955782138SLi Zefan 
58055782138SLi Zefan 	TP_fast_assign(
58155782138SLi Zefan 		__entry->dev		= bio->bi_bdev->bd_dev;
58255782138SLi Zefan 		__entry->sector		= bio->bi_sector;
583aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
58455782138SLi Zefan 		__entry->old_dev	= dev;
58555782138SLi Zefan 		__entry->old_sector	= from;
58655782138SLi Zefan 		blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
58755782138SLi Zefan 	),
58855782138SLi Zefan 
58955782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
59055782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
5916556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
5926556d1dfSSteven Rostedt 		  __entry->nr_sector,
59355782138SLi Zefan 		  MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
5946556d1dfSSteven Rostedt 		  (unsigned long long)__entry->old_sector)
59555782138SLi Zefan );
59655782138SLi Zefan 
597881245dcSWilliam Cohen /**
598881245dcSWilliam Cohen  * block_rq_remap - map request for a block operation request
599881245dcSWilliam Cohen  * @q: queue holding the operation
600881245dcSWilliam Cohen  * @rq: block IO operation request
601881245dcSWilliam Cohen  * @dev: device for the operation
602881245dcSWilliam Cohen  * @from: original sector for the operation
603881245dcSWilliam Cohen  *
604881245dcSWilliam Cohen  * The block operation request @rq in @q has been remapped.  The block
605881245dcSWilliam Cohen  * operation request @rq holds the current information and @from hold
606881245dcSWilliam Cohen  * the original sector.
607881245dcSWilliam Cohen  */
608b0da3f0dSJun'ichi Nomura TRACE_EVENT(block_rq_remap,
609b0da3f0dSJun'ichi Nomura 
610b0da3f0dSJun'ichi Nomura 	TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
611b0da3f0dSJun'ichi Nomura 		 sector_t from),
612b0da3f0dSJun'ichi Nomura 
613b0da3f0dSJun'ichi Nomura 	TP_ARGS(q, rq, dev, from),
614b0da3f0dSJun'ichi Nomura 
615b0da3f0dSJun'ichi Nomura 	TP_STRUCT__entry(
616b0da3f0dSJun'ichi Nomura 		__field( dev_t,		dev		)
617b0da3f0dSJun'ichi Nomura 		__field( sector_t,	sector		)
618b0da3f0dSJun'ichi Nomura 		__field( unsigned int,	nr_sector	)
619b0da3f0dSJun'ichi Nomura 		__field( dev_t,		old_dev		)
620b0da3f0dSJun'ichi Nomura 		__field( sector_t,	old_sector	)
621*75afb352SJun'ichi Nomura 		__field( unsigned int,	nr_bios		)
622c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN)
623b0da3f0dSJun'ichi Nomura 	),
624b0da3f0dSJun'ichi Nomura 
625b0da3f0dSJun'ichi Nomura 	TP_fast_assign(
626b0da3f0dSJun'ichi Nomura 		__entry->dev		= disk_devt(rq->rq_disk);
627b0da3f0dSJun'ichi Nomura 		__entry->sector		= blk_rq_pos(rq);
628b0da3f0dSJun'ichi Nomura 		__entry->nr_sector	= blk_rq_sectors(rq);
629b0da3f0dSJun'ichi Nomura 		__entry->old_dev	= dev;
630b0da3f0dSJun'ichi Nomura 		__entry->old_sector	= from;
631*75afb352SJun'ichi Nomura 		__entry->nr_bios	= blk_rq_count_bios(rq);
6322d3a8497STao Ma 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
633b0da3f0dSJun'ichi Nomura 	),
634b0da3f0dSJun'ichi Nomura 
635*75afb352SJun'ichi Nomura 	TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u",
636b0da3f0dSJun'ichi Nomura 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
637b0da3f0dSJun'ichi Nomura 		  (unsigned long long)__entry->sector,
638b0da3f0dSJun'ichi Nomura 		  __entry->nr_sector,
639b0da3f0dSJun'ichi Nomura 		  MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
640*75afb352SJun'ichi Nomura 		  (unsigned long long)__entry->old_sector, __entry->nr_bios)
641b0da3f0dSJun'ichi Nomura );
642b0da3f0dSJun'ichi Nomura 
64355782138SLi Zefan #endif /* _TRACE_BLOCK_H */
64455782138SLi Zefan 
64555782138SLi Zefan /* This part must be outside protection */
64655782138SLi Zefan #include <trace/define_trace.h>
64755782138SLi Zefan 
648