xref: /openbmc/linux/include/trace/events/block.h (revision d5869fdc189f0f12a954a48d58a48104a2f5d044)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2d0b6e04aSLi Zefan #undef TRACE_SYSTEM
3d0b6e04aSLi Zefan #define TRACE_SYSTEM block
4d0b6e04aSLi Zefan 
555782138SLi Zefan #if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
655782138SLi Zefan #define _TRACE_BLOCK_H
755782138SLi Zefan 
855782138SLi Zefan #include <linux/blktrace_api.h>
955782138SLi Zefan #include <linux/blkdev.h>
105305cb83STejun Heo #include <linux/buffer_head.h>
1155782138SLi Zefan #include <linux/tracepoint.h>
1255782138SLi Zefan 
13c09c47caSNamhyung Kim #define RWBS_LEN	8
14c09c47caSNamhyung Kim 
155305cb83STejun Heo DECLARE_EVENT_CLASS(block_buffer,
165305cb83STejun Heo 
175305cb83STejun Heo 	TP_PROTO(struct buffer_head *bh),
185305cb83STejun Heo 
195305cb83STejun Heo 	TP_ARGS(bh),
205305cb83STejun Heo 
215305cb83STejun Heo 	TP_STRUCT__entry (
225305cb83STejun Heo 		__field(  dev_t,	dev			)
235305cb83STejun Heo 		__field(  sector_t,	sector			)
245305cb83STejun Heo 		__field(  size_t,	size			)
255305cb83STejun Heo 	),
265305cb83STejun Heo 
275305cb83STejun Heo 	TP_fast_assign(
285305cb83STejun Heo 		__entry->dev		= bh->b_bdev->bd_dev;
295305cb83STejun Heo 		__entry->sector		= bh->b_blocknr;
305305cb83STejun Heo 		__entry->size		= bh->b_size;
315305cb83STejun Heo 	),
325305cb83STejun Heo 
335305cb83STejun Heo 	TP_printk("%d,%d sector=%llu size=%zu",
345305cb83STejun Heo 		MAJOR(__entry->dev), MINOR(__entry->dev),
355305cb83STejun Heo 		(unsigned long long)__entry->sector, __entry->size
365305cb83STejun Heo 	)
375305cb83STejun Heo );
385305cb83STejun Heo 
395305cb83STejun Heo /**
405305cb83STejun Heo  * block_touch_buffer - mark a buffer accessed
415305cb83STejun Heo  * @bh: buffer_head being touched
425305cb83STejun Heo  *
435305cb83STejun Heo  * Called from touch_buffer().
445305cb83STejun Heo  */
455305cb83STejun Heo DEFINE_EVENT(block_buffer, block_touch_buffer,
465305cb83STejun Heo 
475305cb83STejun Heo 	TP_PROTO(struct buffer_head *bh),
485305cb83STejun Heo 
495305cb83STejun Heo 	TP_ARGS(bh)
505305cb83STejun Heo );
515305cb83STejun Heo 
525305cb83STejun Heo /**
535305cb83STejun Heo  * block_dirty_buffer - mark a buffer dirty
545305cb83STejun Heo  * @bh: buffer_head being dirtied
555305cb83STejun Heo  *
565305cb83STejun Heo  * Called from mark_buffer_dirty().
575305cb83STejun Heo  */
585305cb83STejun Heo DEFINE_EVENT(block_buffer, block_dirty_buffer,
595305cb83STejun Heo 
605305cb83STejun Heo 	TP_PROTO(struct buffer_head *bh),
615305cb83STejun Heo 
625305cb83STejun Heo 	TP_ARGS(bh)
635305cb83STejun Heo );
645305cb83STejun Heo 
65cee4b7ceSChristoph Hellwig /**
66cee4b7ceSChristoph Hellwig  * block_rq_requeue - place block IO request back on a queue
67cee4b7ceSChristoph Hellwig  * @rq: block IO operation request
68cee4b7ceSChristoph Hellwig  *
69cee4b7ceSChristoph Hellwig  * The block operation request @rq is being placed back into queue
70cee4b7ceSChristoph Hellwig  * @q.  For some reason the request was not completed and needs to be
71cee4b7ceSChristoph Hellwig  * put back in the queue.
72cee4b7ceSChristoph Hellwig  */
73cee4b7ceSChristoph Hellwig TRACE_EVENT(block_rq_requeue,
7455782138SLi Zefan 
75a54895faSChristoph Hellwig 	TP_PROTO(struct request *rq),
7655782138SLi Zefan 
77a54895faSChristoph Hellwig 	TP_ARGS(rq),
7855782138SLi Zefan 
7955782138SLi Zefan 	TP_STRUCT__entry(
8055782138SLi Zefan 		__field(  dev_t,	dev			)
8155782138SLi Zefan 		__field(  sector_t,	sector			)
8255782138SLi Zefan 		__field(  unsigned int,	nr_sector		)
83c09c47caSNamhyung Kim 		__array(  char,		rwbs,	RWBS_LEN	)
8448b77ad6SChristoph Hellwig 		__dynamic_array( char,	cmd,	1		)
8555782138SLi Zefan 	),
8655782138SLi Zefan 
8755782138SLi Zefan 	TP_fast_assign(
88f3fa33acSChristoph Hellwig 		__entry->dev	   = rq->q->disk ? disk_devt(rq->q->disk) : 0;
8948b77ad6SChristoph Hellwig 		__entry->sector    = blk_rq_trace_sector(rq);
9048b77ad6SChristoph Hellwig 		__entry->nr_sector = blk_rq_trace_nr_sectors(rq);
9155782138SLi Zefan 
92179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
9348b77ad6SChristoph Hellwig 		__get_str(cmd)[0] = '\0';
9455782138SLi Zefan 	),
9555782138SLi Zefan 
9655782138SLi Zefan 	TP_printk("%d,%d %s (%s) %llu + %u [%d]",
9755782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev),
9855782138SLi Zefan 		  __entry->rwbs, __get_str(cmd),
996556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
100caf7df12SChristoph Hellwig 		  __entry->nr_sector, 0)
10155782138SLi Zefan );
10255782138SLi Zefan 
103*d5869fdcSYang Shi DECLARE_EVENT_CLASS(block_rq_completion,
10477ca1e02SLi Zefan 
1058a7d267bSChristoph Hellwig 	TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes),
10677ca1e02SLi Zefan 
107caf7df12SChristoph Hellwig 	TP_ARGS(rq, error, nr_bytes),
108af5040daSRoman Pen 
109af5040daSRoman Pen 	TP_STRUCT__entry(
110af5040daSRoman Pen 		__field(  dev_t,	dev			)
111af5040daSRoman Pen 		__field(  sector_t,	sector			)
112af5040daSRoman Pen 		__field(  unsigned int,	nr_sector		)
113caf7df12SChristoph Hellwig 		__field(  int	,	error			)
114af5040daSRoman Pen 		__array(  char,		rwbs,	RWBS_LEN	)
11548b77ad6SChristoph Hellwig 		__dynamic_array( char,	cmd,	1		)
116af5040daSRoman Pen 	),
117af5040daSRoman Pen 
118af5040daSRoman Pen 	TP_fast_assign(
119f3fa33acSChristoph Hellwig 		__entry->dev	   = rq->q->disk ? disk_devt(rq->q->disk) : 0;
120af5040daSRoman Pen 		__entry->sector    = blk_rq_pos(rq);
121af5040daSRoman Pen 		__entry->nr_sector = nr_bytes >> 9;
1228a7d267bSChristoph Hellwig 		__entry->error     = blk_status_to_errno(error);
123af5040daSRoman Pen 
124179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
12548b77ad6SChristoph Hellwig 		__get_str(cmd)[0] = '\0';
126af5040daSRoman Pen 	),
127af5040daSRoman Pen 
128af5040daSRoman Pen 	TP_printk("%d,%d %s (%s) %llu + %u [%d]",
129af5040daSRoman Pen 		  MAJOR(__entry->dev), MINOR(__entry->dev),
130af5040daSRoman Pen 		  __entry->rwbs, __get_str(cmd),
131af5040daSRoman Pen 		  (unsigned long long)__entry->sector,
132caf7df12SChristoph Hellwig 		  __entry->nr_sector, __entry->error)
13377ca1e02SLi Zefan );
13477ca1e02SLi Zefan 
135*d5869fdcSYang Shi /**
136*d5869fdcSYang Shi  * block_rq_complete - block IO operation completed by device driver
137*d5869fdcSYang Shi  * @rq: block operations request
138*d5869fdcSYang Shi  * @error: status code
139*d5869fdcSYang Shi  * @nr_bytes: number of completed bytes
140*d5869fdcSYang Shi  *
141*d5869fdcSYang Shi  * The block_rq_complete tracepoint event indicates that some portion
142*d5869fdcSYang Shi  * of operation request has been completed by the device driver.  If
143*d5869fdcSYang Shi  * the @rq->bio is %NULL, then there is absolutely no additional work to
144*d5869fdcSYang Shi  * do for the request. If @rq->bio is non-NULL then there is
145*d5869fdcSYang Shi  * additional work required to complete the request.
146*d5869fdcSYang Shi  */
147*d5869fdcSYang Shi DEFINE_EVENT(block_rq_completion, block_rq_complete,
148*d5869fdcSYang Shi 
149*d5869fdcSYang Shi 	TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes),
150*d5869fdcSYang Shi 
151*d5869fdcSYang Shi 	TP_ARGS(rq, error, nr_bytes)
152*d5869fdcSYang Shi );
153*d5869fdcSYang Shi 
154*d5869fdcSYang Shi /**
155*d5869fdcSYang Shi  * block_rq_error - block IO operation error reported by device driver
156*d5869fdcSYang Shi  * @rq: block operations request
157*d5869fdcSYang Shi  * @error: status code
158*d5869fdcSYang Shi  * @nr_bytes: number of completed bytes
159*d5869fdcSYang Shi  *
160*d5869fdcSYang Shi  * The block_rq_error tracepoint event indicates that some portion
161*d5869fdcSYang Shi  * of operation request has failed as reported by the device driver.
162*d5869fdcSYang Shi  */
163*d5869fdcSYang Shi DEFINE_EVENT(block_rq_completion, block_rq_error,
164*d5869fdcSYang Shi 
165*d5869fdcSYang Shi 	TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes),
166*d5869fdcSYang Shi 
167*d5869fdcSYang Shi 	TP_ARGS(rq, error, nr_bytes)
168*d5869fdcSYang Shi );
169*d5869fdcSYang Shi 
17077ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_rq,
17155782138SLi Zefan 
172a54895faSChristoph Hellwig 	TP_PROTO(struct request *rq),
17355782138SLi Zefan 
174a54895faSChristoph Hellwig 	TP_ARGS(rq),
17555782138SLi Zefan 
17655782138SLi Zefan 	TP_STRUCT__entry(
17755782138SLi Zefan 		__field(  dev_t,	dev			)
17855782138SLi Zefan 		__field(  sector_t,	sector			)
17955782138SLi Zefan 		__field(  unsigned int,	nr_sector		)
18055782138SLi Zefan 		__field(  unsigned int,	bytes			)
181c09c47caSNamhyung Kim 		__array(  char,		rwbs,	RWBS_LEN	)
18255782138SLi Zefan 		__array(  char,         comm,   TASK_COMM_LEN   )
18348b77ad6SChristoph Hellwig 		__dynamic_array( char,	cmd,	1		)
18455782138SLi Zefan 	),
18555782138SLi Zefan 
18655782138SLi Zefan 	TP_fast_assign(
187f3fa33acSChristoph Hellwig 		__entry->dev	   = rq->q->disk ? disk_devt(rq->q->disk) : 0;
18848b77ad6SChristoph Hellwig 		__entry->sector    = blk_rq_trace_sector(rq);
18948b77ad6SChristoph Hellwig 		__entry->nr_sector = blk_rq_trace_nr_sectors(rq);
19048b77ad6SChristoph Hellwig 		__entry->bytes     = blk_rq_bytes(rq);
19155782138SLi Zefan 
192179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
19348b77ad6SChristoph Hellwig 		__get_str(cmd)[0] = '\0';
19455782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
19555782138SLi Zefan 	),
19655782138SLi Zefan 
19755782138SLi Zefan 	TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
19855782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev),
19955782138SLi Zefan 		  __entry->rwbs, __entry->bytes, __get_str(cmd),
2006556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
2016556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->comm)
20255782138SLi Zefan );
20355782138SLi Zefan 
204881245dcSWilliam Cohen /**
205881245dcSWilliam Cohen  * block_rq_insert - insert block operation request into queue
206881245dcSWilliam Cohen  * @rq: block IO operation request
207881245dcSWilliam Cohen  *
208881245dcSWilliam Cohen  * Called immediately before block operation request @rq is inserted
209881245dcSWilliam Cohen  * into queue @q.  The fields in the operation request @rq struct can
210881245dcSWilliam Cohen  * be examined to determine which device and sectors the pending
211881245dcSWilliam Cohen  * operation would access.
212881245dcSWilliam Cohen  */
21377ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_insert,
21455782138SLi Zefan 
215a54895faSChristoph Hellwig 	TP_PROTO(struct request *rq),
21655782138SLi Zefan 
217a54895faSChristoph Hellwig 	TP_ARGS(rq)
21855782138SLi Zefan );
21955782138SLi Zefan 
220881245dcSWilliam Cohen /**
221881245dcSWilliam Cohen  * block_rq_issue - issue pending block IO request operation to device driver
222c7ff6519SChaitanya Kulkarni  * @rq: block IO operation request
223881245dcSWilliam Cohen  *
224881245dcSWilliam Cohen  * Called when block operation request @rq from queue @q is sent to a
225881245dcSWilliam Cohen  * device driver for processing.
226881245dcSWilliam Cohen  */
22777ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_issue,
22855782138SLi Zefan 
229a54895faSChristoph Hellwig 	TP_PROTO(struct request *rq),
23055782138SLi Zefan 
231a54895faSChristoph Hellwig 	TP_ARGS(rq)
23255782138SLi Zefan );
233fe63b94aSCarsten Emde 
234881245dcSWilliam Cohen /**
235f3bdc62fSJan Kara  * block_rq_merge - merge request with another one in the elevator
236b0719245SChaitanya Kulkarni  * @rq: block IO operation request
237f3bdc62fSJan Kara  *
238f3bdc62fSJan Kara  * Called when block operation request @rq from queue @q is merged to another
239f3bdc62fSJan Kara  * request queued in the elevator.
240f3bdc62fSJan Kara  */
241f3bdc62fSJan Kara DEFINE_EVENT(block_rq, block_rq_merge,
242f3bdc62fSJan Kara 
243a54895faSChristoph Hellwig 	TP_PROTO(struct request *rq),
244f3bdc62fSJan Kara 
245a54895faSChristoph Hellwig 	TP_ARGS(rq)
246f3bdc62fSJan Kara );
247f3bdc62fSJan Kara 
248f3bdc62fSJan Kara /**
249881245dcSWilliam Cohen  * block_bio_complete - completed all work on the block operation
2500a82a8d1SLinus Torvalds  * @q: queue holding the block operation
251881245dcSWilliam Cohen  * @bio: block operation completed
252881245dcSWilliam Cohen  *
253881245dcSWilliam Cohen  * This tracepoint indicates there is no further work to do on this
254881245dcSWilliam Cohen  * block IO operation @bio.
255881245dcSWilliam Cohen  */
25655782138SLi Zefan TRACE_EVENT(block_bio_complete,
25755782138SLi Zefan 
258d24de76aSChristoph Hellwig 	TP_PROTO(struct request_queue *q, struct bio *bio),
25955782138SLi Zefan 
260d24de76aSChristoph Hellwig 	TP_ARGS(q, bio),
26155782138SLi Zefan 
26255782138SLi Zefan 	TP_STRUCT__entry(
26355782138SLi Zefan 		__field( dev_t,		dev		)
26455782138SLi Zefan 		__field( sector_t,	sector		)
26555782138SLi Zefan 		__field( unsigned,	nr_sector	)
26655782138SLi Zefan 		__field( int,		error		)
267c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN)
26855782138SLi Zefan 	),
26955782138SLi Zefan 
27055782138SLi Zefan 	TP_fast_assign(
27174d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
2724f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
273aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
274d24de76aSChristoph Hellwig 		__entry->error		= blk_status_to_errno(bio->bi_status);
275179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
27655782138SLi Zefan 	),
27755782138SLi Zefan 
27855782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u [%d]",
27955782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
2806556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
2816556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->error)
28255782138SLi Zefan );
28355782138SLi Zefan 
284e8a676d6SChristoph Hellwig DECLARE_EVENT_CLASS(block_bio,
28555782138SLi Zefan 
286e8a676d6SChristoph Hellwig 	TP_PROTO(struct bio *bio),
28755782138SLi Zefan 
288e8a676d6SChristoph Hellwig 	TP_ARGS(bio),
28955782138SLi Zefan 
29055782138SLi Zefan 	TP_STRUCT__entry(
29155782138SLi Zefan 		__field( dev_t,		dev			)
29255782138SLi Zefan 		__field( sector_t,	sector			)
29355782138SLi Zefan 		__field( unsigned int,	nr_sector		)
294c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN	)
29555782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
29655782138SLi Zefan 	),
29755782138SLi Zefan 
29855782138SLi Zefan 	TP_fast_assign(
29974d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
3004f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
301aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
302179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
30355782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
30455782138SLi Zefan 	),
30555782138SLi Zefan 
30655782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u [%s]",
30755782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
3086556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
3096556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->comm)
31055782138SLi Zefan );
31155782138SLi Zefan 
312881245dcSWilliam Cohen /**
313e8a676d6SChristoph Hellwig  * block_bio_bounce - used bounce buffer when processing block operation
314e8a676d6SChristoph Hellwig  * @bio: block operation
315e8a676d6SChristoph Hellwig  *
316e8a676d6SChristoph Hellwig  * A bounce buffer was used to handle the block operation @bio in @q.
317e8a676d6SChristoph Hellwig  * This occurs when hardware limitations prevent a direct transfer of
318e8a676d6SChristoph Hellwig  * data between the @bio data memory area and the IO device.  Use of a
319e8a676d6SChristoph Hellwig  * bounce buffer requires extra copying of data and decreases
320e8a676d6SChristoph Hellwig  * performance.
321e8a676d6SChristoph Hellwig  */
322e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_bounce,
323e8a676d6SChristoph Hellwig 	TP_PROTO(struct bio *bio),
324e8a676d6SChristoph Hellwig 	TP_ARGS(bio)
325e8a676d6SChristoph Hellwig );
326e8a676d6SChristoph Hellwig 
327e8a676d6SChristoph Hellwig /**
328881245dcSWilliam Cohen  * block_bio_backmerge - merging block operation to the end of an existing operation
329881245dcSWilliam Cohen  * @bio: new block operation to merge
330881245dcSWilliam Cohen  *
331e8a676d6SChristoph Hellwig  * Merging block request @bio to the end of an existing block request.
332881245dcSWilliam Cohen  */
333e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_backmerge,
334e8a676d6SChristoph Hellwig 	TP_PROTO(struct bio *bio),
335e8a676d6SChristoph Hellwig 	TP_ARGS(bio)
33655782138SLi Zefan );
33755782138SLi Zefan 
338881245dcSWilliam Cohen /**
339881245dcSWilliam Cohen  * block_bio_frontmerge - merging block operation to the beginning of an existing operation
340881245dcSWilliam Cohen  * @bio: new block operation to merge
341881245dcSWilliam Cohen  *
342e8a676d6SChristoph Hellwig  * Merging block IO operation @bio to the beginning of an existing block request.
343881245dcSWilliam Cohen  */
344e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_frontmerge,
345e8a676d6SChristoph Hellwig 	TP_PROTO(struct bio *bio),
346e8a676d6SChristoph Hellwig 	TP_ARGS(bio)
34755782138SLi Zefan );
34855782138SLi Zefan 
349881245dcSWilliam Cohen /**
350881245dcSWilliam Cohen  * block_bio_queue - putting new block IO operation in queue
351881245dcSWilliam Cohen  * @bio: new block operation
352881245dcSWilliam Cohen  *
353881245dcSWilliam Cohen  * About to place the block IO operation @bio into queue @q.
354881245dcSWilliam Cohen  */
355e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_queue,
356e8a676d6SChristoph Hellwig 	TP_PROTO(struct bio *bio),
357e8a676d6SChristoph Hellwig 	TP_ARGS(bio)
35855782138SLi Zefan );
35955782138SLi Zefan 
360881245dcSWilliam Cohen /**
361881245dcSWilliam Cohen  * block_getrq - get a free request entry in queue for block IO operations
362f8e9ec16SGreg Thelen  * @bio: pending block IO operation (can be %NULL)
363881245dcSWilliam Cohen  *
364e8a676d6SChristoph Hellwig  * A request struct has been allocated to handle the block IO operation @bio.
365881245dcSWilliam Cohen  */
366e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_getrq,
367e8a676d6SChristoph Hellwig 	TP_PROTO(struct bio *bio),
368e8a676d6SChristoph Hellwig 	TP_ARGS(bio)
36977ca1e02SLi Zefan );
37055782138SLi Zefan 
371881245dcSWilliam Cohen /**
372881245dcSWilliam Cohen  * block_plug - keep operations requests in request queue
373881245dcSWilliam Cohen  * @q: request queue to plug
374881245dcSWilliam Cohen  *
375881245dcSWilliam Cohen  * Plug the request queue @q.  Do not allow block operation requests
376881245dcSWilliam Cohen  * to be sent to the device driver. Instead, accumulate requests in
377881245dcSWilliam Cohen  * the queue to improve throughput performance of the block device.
378881245dcSWilliam Cohen  */
37955782138SLi Zefan TRACE_EVENT(block_plug,
38055782138SLi Zefan 
38155782138SLi Zefan 	TP_PROTO(struct request_queue *q),
38255782138SLi Zefan 
38355782138SLi Zefan 	TP_ARGS(q),
38455782138SLi Zefan 
38555782138SLi Zefan 	TP_STRUCT__entry(
38655782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
38755782138SLi Zefan 	),
38855782138SLi Zefan 
38955782138SLi Zefan 	TP_fast_assign(
39055782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
39155782138SLi Zefan 	),
39255782138SLi Zefan 
39355782138SLi Zefan 	TP_printk("[%s]", __entry->comm)
39455782138SLi Zefan );
39555782138SLi Zefan 
39677ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_unplug,
39755782138SLi Zefan 
39849cac01eSJens Axboe 	TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
39955782138SLi Zefan 
40049cac01eSJens Axboe 	TP_ARGS(q, depth, explicit),
40155782138SLi Zefan 
40255782138SLi Zefan 	TP_STRUCT__entry(
40355782138SLi Zefan 		__field( int,		nr_rq			)
40455782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
40555782138SLi Zefan 	),
40655782138SLi Zefan 
40755782138SLi Zefan 	TP_fast_assign(
40894b5eb28SJens Axboe 		__entry->nr_rq = depth;
40955782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
41055782138SLi Zefan 	),
41155782138SLi Zefan 
41255782138SLi Zefan 	TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
41355782138SLi Zefan );
41455782138SLi Zefan 
415881245dcSWilliam Cohen /**
41649cac01eSJens Axboe  * block_unplug - release of operations requests in request queue
417881245dcSWilliam Cohen  * @q: request queue to unplug
41894b5eb28SJens Axboe  * @depth: number of requests just added to the queue
41949cac01eSJens Axboe  * @explicit: whether this was an explicit unplug, or one from schedule()
420881245dcSWilliam Cohen  *
421881245dcSWilliam Cohen  * Unplug request queue @q because device driver is scheduled to work
422881245dcSWilliam Cohen  * on elements in the request queue.
423881245dcSWilliam Cohen  */
42449cac01eSJens Axboe DEFINE_EVENT(block_unplug, block_unplug,
42555782138SLi Zefan 
42649cac01eSJens Axboe 	TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
42755782138SLi Zefan 
42849cac01eSJens Axboe 	TP_ARGS(q, depth, explicit)
42955782138SLi Zefan );
43055782138SLi Zefan 
431881245dcSWilliam Cohen /**
432881245dcSWilliam Cohen  * block_split - split a single bio struct into two bio structs
433881245dcSWilliam Cohen  * @bio: block operation being split
434881245dcSWilliam Cohen  * @new_sector: The starting sector for the new bio
435881245dcSWilliam Cohen  *
436eb6f7f7cSChristoph Hellwig  * The bio request @bio needs to be split into two bio requests.  The newly
437eb6f7f7cSChristoph Hellwig  * created @bio request starts at @new_sector. This split may be required due to
438eb6f7f7cSChristoph Hellwig  * hardware limitations such as operation crossing device boundaries in a RAID
439eb6f7f7cSChristoph Hellwig  * system.
440881245dcSWilliam Cohen  */
44155782138SLi Zefan TRACE_EVENT(block_split,
44255782138SLi Zefan 
443eb6f7f7cSChristoph Hellwig 	TP_PROTO(struct bio *bio, unsigned int new_sector),
44455782138SLi Zefan 
445eb6f7f7cSChristoph Hellwig 	TP_ARGS(bio, new_sector),
44655782138SLi Zefan 
44755782138SLi Zefan 	TP_STRUCT__entry(
44855782138SLi Zefan 		__field( dev_t,		dev				)
44955782138SLi Zefan 		__field( sector_t,	sector				)
45055782138SLi Zefan 		__field( sector_t,	new_sector			)
451c09c47caSNamhyung Kim 		__array( char,		rwbs,		RWBS_LEN	)
45255782138SLi Zefan 		__array( char,		comm,		TASK_COMM_LEN	)
45355782138SLi Zefan 	),
45455782138SLi Zefan 
45555782138SLi Zefan 	TP_fast_assign(
45674d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
4574f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
45855782138SLi Zefan 		__entry->new_sector	= new_sector;
459179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
46055782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
46155782138SLi Zefan 	),
46255782138SLi Zefan 
46355782138SLi Zefan 	TP_printk("%d,%d %s %llu / %llu [%s]",
46455782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
4656556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
4666556d1dfSSteven Rostedt 		  (unsigned long long)__entry->new_sector,
4676556d1dfSSteven Rostedt 		  __entry->comm)
46855782138SLi Zefan );
46955782138SLi Zefan 
470881245dcSWilliam Cohen /**
471d07335e5SMike Snitzer  * block_bio_remap - map request for a logical device to the raw device
472881245dcSWilliam Cohen  * @bio: revised operation
4731c02fca6SChristoph Hellwig  * @dev: original device for the operation
474881245dcSWilliam Cohen  * @from: original sector for the operation
475881245dcSWilliam Cohen  *
476d07335e5SMike Snitzer  * An operation for a logical device has been mapped to the
477881245dcSWilliam Cohen  * raw block device.
478881245dcSWilliam Cohen  */
479d07335e5SMike Snitzer TRACE_EVENT(block_bio_remap,
48055782138SLi Zefan 
4811c02fca6SChristoph Hellwig 	TP_PROTO(struct bio *bio, dev_t dev, sector_t from),
48255782138SLi Zefan 
4831c02fca6SChristoph Hellwig 	TP_ARGS(bio, dev, from),
48455782138SLi Zefan 
48555782138SLi Zefan 	TP_STRUCT__entry(
48655782138SLi Zefan 		__field( dev_t,		dev		)
48755782138SLi Zefan 		__field( sector_t,	sector		)
48855782138SLi Zefan 		__field( unsigned int,	nr_sector	)
48955782138SLi Zefan 		__field( dev_t,		old_dev		)
49055782138SLi Zefan 		__field( sector_t,	old_sector	)
491c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN)
49255782138SLi Zefan 	),
49355782138SLi Zefan 
49455782138SLi Zefan 	TP_fast_assign(
49574d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
4964f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
497aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
49855782138SLi Zefan 		__entry->old_dev	= dev;
49955782138SLi Zefan 		__entry->old_sector	= from;
500179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
50155782138SLi Zefan 	),
50255782138SLi Zefan 
50355782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
50455782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
5056556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
5066556d1dfSSteven Rostedt 		  __entry->nr_sector,
50755782138SLi Zefan 		  MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
5086556d1dfSSteven Rostedt 		  (unsigned long long)__entry->old_sector)
50955782138SLi Zefan );
51055782138SLi Zefan 
511881245dcSWilliam Cohen /**
512881245dcSWilliam Cohen  * block_rq_remap - map request for a block operation request
513881245dcSWilliam Cohen  * @rq: block IO operation request
514881245dcSWilliam Cohen  * @dev: device for the operation
515881245dcSWilliam Cohen  * @from: original sector for the operation
516881245dcSWilliam Cohen  *
517881245dcSWilliam Cohen  * The block operation request @rq in @q has been remapped.  The block
518881245dcSWilliam Cohen  * operation request @rq holds the current information and @from hold
519881245dcSWilliam Cohen  * the original sector.
520881245dcSWilliam Cohen  */
521b0da3f0dSJun'ichi Nomura TRACE_EVENT(block_rq_remap,
522b0da3f0dSJun'ichi Nomura 
523a54895faSChristoph Hellwig 	TP_PROTO(struct request *rq, dev_t dev, sector_t from),
524b0da3f0dSJun'ichi Nomura 
525a54895faSChristoph Hellwig 	TP_ARGS(rq, dev, from),
526b0da3f0dSJun'ichi Nomura 
527b0da3f0dSJun'ichi Nomura 	TP_STRUCT__entry(
528b0da3f0dSJun'ichi Nomura 		__field( dev_t,		dev		)
529b0da3f0dSJun'ichi Nomura 		__field( sector_t,	sector		)
530b0da3f0dSJun'ichi Nomura 		__field( unsigned int,	nr_sector	)
531b0da3f0dSJun'ichi Nomura 		__field( dev_t,		old_dev		)
532b0da3f0dSJun'ichi Nomura 		__field( sector_t,	old_sector	)
53375afb352SJun'ichi Nomura 		__field( unsigned int,	nr_bios		)
534c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN)
535b0da3f0dSJun'ichi Nomura 	),
536b0da3f0dSJun'ichi Nomura 
537b0da3f0dSJun'ichi Nomura 	TP_fast_assign(
538f3fa33acSChristoph Hellwig 		__entry->dev		= disk_devt(rq->q->disk);
539b0da3f0dSJun'ichi Nomura 		__entry->sector		= blk_rq_pos(rq);
540b0da3f0dSJun'ichi Nomura 		__entry->nr_sector	= blk_rq_sectors(rq);
541b0da3f0dSJun'ichi Nomura 		__entry->old_dev	= dev;
542b0da3f0dSJun'ichi Nomura 		__entry->old_sector	= from;
54375afb352SJun'ichi Nomura 		__entry->nr_bios	= blk_rq_count_bios(rq);
544179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
545b0da3f0dSJun'ichi Nomura 	),
546b0da3f0dSJun'ichi Nomura 
54775afb352SJun'ichi Nomura 	TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u",
548b0da3f0dSJun'ichi Nomura 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
549b0da3f0dSJun'ichi Nomura 		  (unsigned long long)__entry->sector,
550b0da3f0dSJun'ichi Nomura 		  __entry->nr_sector,
551b0da3f0dSJun'ichi Nomura 		  MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
55275afb352SJun'ichi Nomura 		  (unsigned long long)__entry->old_sector, __entry->nr_bios)
553b0da3f0dSJun'ichi Nomura );
554b0da3f0dSJun'ichi Nomura 
55555782138SLi Zefan #endif /* _TRACE_BLOCK_H */
55655782138SLi Zefan 
55755782138SLi Zefan /* This part must be outside protection */
55855782138SLi Zefan #include <trace/define_trace.h>
55955782138SLi Zefan 
560