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 * @q: queue holding operation 68cee4b7ceSChristoph Hellwig * @rq: block IO operation request 69cee4b7ceSChristoph Hellwig * 70cee4b7ceSChristoph Hellwig * The block operation request @rq is being placed back into queue 71cee4b7ceSChristoph Hellwig * @q. For some reason the request was not completed and needs to be 72cee4b7ceSChristoph Hellwig * put back in the queue. 73cee4b7ceSChristoph Hellwig */ 74cee4b7ceSChristoph Hellwig TRACE_EVENT(block_rq_requeue, 7555782138SLi Zefan 7655782138SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 7755782138SLi Zefan 7855782138SLi Zefan TP_ARGS(q, rq), 7955782138SLi Zefan 8055782138SLi Zefan TP_STRUCT__entry( 8155782138SLi Zefan __field( dev_t, dev ) 8255782138SLi Zefan __field( sector_t, sector ) 8355782138SLi Zefan __field( unsigned int, nr_sector ) 84c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 8548b77ad6SChristoph Hellwig __dynamic_array( char, cmd, 1 ) 8655782138SLi Zefan ), 8755782138SLi Zefan 8855782138SLi Zefan TP_fast_assign( 8955782138SLi Zefan __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0; 9048b77ad6SChristoph Hellwig __entry->sector = blk_rq_trace_sector(rq); 9148b77ad6SChristoph Hellwig __entry->nr_sector = blk_rq_trace_nr_sectors(rq); 9255782138SLi Zefan 93ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq)); 9448b77ad6SChristoph Hellwig __get_str(cmd)[0] = '\0'; 9555782138SLi Zefan ), 9655782138SLi Zefan 9755782138SLi Zefan TP_printk("%d,%d %s (%s) %llu + %u [%d]", 9855782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), 9955782138SLi Zefan __entry->rwbs, __get_str(cmd), 1006556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 101caf7df12SChristoph Hellwig __entry->nr_sector, 0) 10255782138SLi Zefan ); 10355782138SLi Zefan 104881245dcSWilliam Cohen /** 105881245dcSWilliam Cohen * block_rq_complete - block IO operation completed by device driver 106881245dcSWilliam Cohen * @rq: block operations request 107caf7df12SChristoph Hellwig * @error: status code 108af5040daSRoman Pen * @nr_bytes: number of completed bytes 109881245dcSWilliam Cohen * 110881245dcSWilliam Cohen * The block_rq_complete tracepoint event indicates that some portion 111881245dcSWilliam Cohen * of operation request has been completed by the device driver. If 112881245dcSWilliam Cohen * the @rq->bio is %NULL, then there is absolutely no additional work to 113881245dcSWilliam Cohen * do for the request. If @rq->bio is non-NULL then there is 114881245dcSWilliam Cohen * additional work required to complete the request. 115881245dcSWilliam Cohen */ 116af5040daSRoman Pen TRACE_EVENT(block_rq_complete, 11777ca1e02SLi Zefan 118caf7df12SChristoph Hellwig TP_PROTO(struct request *rq, int error, unsigned int nr_bytes), 11977ca1e02SLi Zefan 120caf7df12SChristoph Hellwig TP_ARGS(rq, error, nr_bytes), 121af5040daSRoman Pen 122af5040daSRoman Pen TP_STRUCT__entry( 123af5040daSRoman Pen __field( dev_t, dev ) 124af5040daSRoman Pen __field( sector_t, sector ) 125af5040daSRoman Pen __field( unsigned int, nr_sector ) 126caf7df12SChristoph Hellwig __field( int, error ) 127af5040daSRoman Pen __array( char, rwbs, RWBS_LEN ) 12848b77ad6SChristoph Hellwig __dynamic_array( char, cmd, 1 ) 129af5040daSRoman Pen ), 130af5040daSRoman Pen 131af5040daSRoman Pen TP_fast_assign( 132af5040daSRoman Pen __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0; 133af5040daSRoman Pen __entry->sector = blk_rq_pos(rq); 134af5040daSRoman Pen __entry->nr_sector = nr_bytes >> 9; 135caf7df12SChristoph Hellwig __entry->error = error; 136af5040daSRoman Pen 137ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, nr_bytes); 13848b77ad6SChristoph Hellwig __get_str(cmd)[0] = '\0'; 139af5040daSRoman Pen ), 140af5040daSRoman Pen 141af5040daSRoman Pen TP_printk("%d,%d %s (%s) %llu + %u [%d]", 142af5040daSRoman Pen MAJOR(__entry->dev), MINOR(__entry->dev), 143af5040daSRoman Pen __entry->rwbs, __get_str(cmd), 144af5040daSRoman Pen (unsigned long long)__entry->sector, 145caf7df12SChristoph Hellwig __entry->nr_sector, __entry->error) 14677ca1e02SLi Zefan ); 14777ca1e02SLi Zefan 14877ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_rq, 14955782138SLi Zefan 15055782138SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 15155782138SLi Zefan 15255782138SLi Zefan TP_ARGS(q, rq), 15355782138SLi Zefan 15455782138SLi Zefan TP_STRUCT__entry( 15555782138SLi Zefan __field( dev_t, dev ) 15655782138SLi Zefan __field( sector_t, sector ) 15755782138SLi Zefan __field( unsigned int, nr_sector ) 15855782138SLi Zefan __field( unsigned int, bytes ) 159c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 16055782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 16148b77ad6SChristoph Hellwig __dynamic_array( char, cmd, 1 ) 16255782138SLi Zefan ), 16355782138SLi Zefan 16455782138SLi Zefan TP_fast_assign( 16555782138SLi Zefan __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0; 16648b77ad6SChristoph Hellwig __entry->sector = blk_rq_trace_sector(rq); 16748b77ad6SChristoph Hellwig __entry->nr_sector = blk_rq_trace_nr_sectors(rq); 16848b77ad6SChristoph Hellwig __entry->bytes = blk_rq_bytes(rq); 16955782138SLi Zefan 170ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq)); 17148b77ad6SChristoph Hellwig __get_str(cmd)[0] = '\0'; 17255782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 17355782138SLi Zefan ), 17455782138SLi Zefan 17555782138SLi Zefan TP_printk("%d,%d %s %u (%s) %llu + %u [%s]", 17655782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), 17755782138SLi Zefan __entry->rwbs, __entry->bytes, __get_str(cmd), 1786556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 1796556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 18055782138SLi Zefan ); 18155782138SLi Zefan 182881245dcSWilliam Cohen /** 183881245dcSWilliam Cohen * block_rq_insert - insert block operation request into queue 184881245dcSWilliam Cohen * @q: target queue 185881245dcSWilliam Cohen * @rq: block IO operation request 186881245dcSWilliam Cohen * 187881245dcSWilliam Cohen * Called immediately before block operation request @rq is inserted 188881245dcSWilliam Cohen * into queue @q. The fields in the operation request @rq struct can 189881245dcSWilliam Cohen * be examined to determine which device and sectors the pending 190881245dcSWilliam Cohen * operation would access. 191881245dcSWilliam Cohen */ 19277ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_insert, 19355782138SLi Zefan 19455782138SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 19555782138SLi Zefan 19677ca1e02SLi Zefan TP_ARGS(q, rq) 19755782138SLi Zefan ); 19855782138SLi Zefan 199881245dcSWilliam Cohen /** 200881245dcSWilliam Cohen * block_rq_issue - issue pending block IO request operation to device driver 201881245dcSWilliam Cohen * @q: queue holding operation 202881245dcSWilliam Cohen * @rq: block IO operation operation request 203881245dcSWilliam Cohen * 204881245dcSWilliam Cohen * Called when block operation request @rq from queue @q is sent to a 205881245dcSWilliam Cohen * device driver for processing. 206881245dcSWilliam Cohen */ 20777ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_issue, 20855782138SLi Zefan 20955782138SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 21055782138SLi Zefan 21177ca1e02SLi Zefan TP_ARGS(q, rq) 21255782138SLi Zefan ); 213fe63b94aSCarsten Emde 214881245dcSWilliam Cohen /** 215*f3bdc62fSJan Kara * block_rq_merge - merge request with another one in the elevator 216*f3bdc62fSJan Kara * @q: queue holding operation 217*f3bdc62fSJan Kara * @rq: block IO operation operation request 218*f3bdc62fSJan Kara * 219*f3bdc62fSJan Kara * Called when block operation request @rq from queue @q is merged to another 220*f3bdc62fSJan Kara * request queued in the elevator. 221*f3bdc62fSJan Kara */ 222*f3bdc62fSJan Kara DEFINE_EVENT(block_rq, block_rq_merge, 223*f3bdc62fSJan Kara 224*f3bdc62fSJan Kara TP_PROTO(struct request_queue *q, struct request *rq), 225*f3bdc62fSJan Kara 226*f3bdc62fSJan Kara TP_ARGS(q, rq) 227*f3bdc62fSJan Kara ); 228*f3bdc62fSJan Kara 229*f3bdc62fSJan Kara /** 230881245dcSWilliam Cohen * block_bio_bounce - used bounce buffer when processing block operation 231881245dcSWilliam Cohen * @q: queue holding the block operation 232881245dcSWilliam Cohen * @bio: block operation 233881245dcSWilliam Cohen * 234881245dcSWilliam Cohen * A bounce buffer was used to handle the block operation @bio in @q. 235881245dcSWilliam Cohen * This occurs when hardware limitations prevent a direct transfer of 236881245dcSWilliam Cohen * data between the @bio data memory area and the IO device. Use of a 237881245dcSWilliam Cohen * bounce buffer requires extra copying of data and decreases 238881245dcSWilliam Cohen * performance. 239881245dcSWilliam Cohen */ 24055782138SLi Zefan TRACE_EVENT(block_bio_bounce, 24155782138SLi Zefan 24255782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio), 24355782138SLi Zefan 24455782138SLi Zefan TP_ARGS(q, bio), 24555782138SLi Zefan 24655782138SLi Zefan TP_STRUCT__entry( 24755782138SLi Zefan __field( dev_t, dev ) 24855782138SLi Zefan __field( sector_t, sector ) 24955782138SLi Zefan __field( unsigned int, nr_sector ) 250c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 25155782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 25255782138SLi Zefan ), 25355782138SLi Zefan 25455782138SLi Zefan TP_fast_assign( 25574d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 2564f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 257aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 258ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 25955782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 26055782138SLi Zefan ), 26155782138SLi Zefan 26255782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%s]", 26355782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 2646556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 2656556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 26655782138SLi Zefan ); 26755782138SLi Zefan 268881245dcSWilliam Cohen /** 269881245dcSWilliam Cohen * block_bio_complete - completed all work on the block operation 2700a82a8d1SLinus Torvalds * @q: queue holding the block operation 271881245dcSWilliam Cohen * @bio: block operation completed 272881245dcSWilliam Cohen * 273881245dcSWilliam Cohen * This tracepoint indicates there is no further work to do on this 274881245dcSWilliam Cohen * block IO operation @bio. 275881245dcSWilliam Cohen */ 27655782138SLi Zefan TRACE_EVENT(block_bio_complete, 27755782138SLi Zefan 278d24de76aSChristoph Hellwig TP_PROTO(struct request_queue *q, struct bio *bio), 27955782138SLi Zefan 280d24de76aSChristoph Hellwig TP_ARGS(q, bio), 28155782138SLi Zefan 28255782138SLi Zefan TP_STRUCT__entry( 28355782138SLi Zefan __field( dev_t, dev ) 28455782138SLi Zefan __field( sector_t, sector ) 28555782138SLi Zefan __field( unsigned, nr_sector ) 28655782138SLi Zefan __field( int, error ) 287c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN) 28855782138SLi Zefan ), 28955782138SLi Zefan 29055782138SLi Zefan TP_fast_assign( 29174d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 2924f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 293aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 294d24de76aSChristoph Hellwig __entry->error = blk_status_to_errno(bio->bi_status); 295ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 29655782138SLi Zefan ), 29755782138SLi Zefan 29855782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%d]", 29955782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 3006556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 3016556d1dfSSteven Rostedt __entry->nr_sector, __entry->error) 30255782138SLi Zefan ); 30355782138SLi Zefan 3048c1cf6bbSTejun Heo DECLARE_EVENT_CLASS(block_bio_merge, 30555782138SLi Zefan 3068c1cf6bbSTejun Heo TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio), 30755782138SLi Zefan 3088c1cf6bbSTejun Heo TP_ARGS(q, rq, bio), 30955782138SLi Zefan 31055782138SLi Zefan TP_STRUCT__entry( 31155782138SLi Zefan __field( dev_t, dev ) 31255782138SLi Zefan __field( sector_t, sector ) 31355782138SLi Zefan __field( unsigned int, nr_sector ) 314c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 31555782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 31655782138SLi Zefan ), 31755782138SLi Zefan 31855782138SLi Zefan TP_fast_assign( 31974d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 3204f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 321aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 322ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 32355782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 32455782138SLi Zefan ), 32555782138SLi Zefan 32655782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%s]", 32755782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 3286556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 3296556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 33055782138SLi Zefan ); 33155782138SLi Zefan 332881245dcSWilliam Cohen /** 333881245dcSWilliam Cohen * block_bio_backmerge - merging block operation to the end of an existing operation 334881245dcSWilliam Cohen * @q: queue holding operation 3358c1cf6bbSTejun Heo * @rq: request bio is being merged into 336881245dcSWilliam Cohen * @bio: new block operation to merge 337881245dcSWilliam Cohen * 338881245dcSWilliam Cohen * Merging block request @bio to the end of an existing block request 339881245dcSWilliam Cohen * in queue @q. 340881245dcSWilliam Cohen */ 3418c1cf6bbSTejun Heo DEFINE_EVENT(block_bio_merge, block_bio_backmerge, 34255782138SLi Zefan 3438c1cf6bbSTejun Heo TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio), 34455782138SLi Zefan 3458c1cf6bbSTejun Heo TP_ARGS(q, rq, bio) 34655782138SLi Zefan ); 34755782138SLi Zefan 348881245dcSWilliam Cohen /** 349881245dcSWilliam Cohen * block_bio_frontmerge - merging block operation to the beginning of an existing operation 350881245dcSWilliam Cohen * @q: queue holding operation 3518c1cf6bbSTejun Heo * @rq: request bio is being merged into 352881245dcSWilliam Cohen * @bio: new block operation to merge 353881245dcSWilliam Cohen * 354881245dcSWilliam Cohen * Merging block IO operation @bio to the beginning of an existing block 355881245dcSWilliam Cohen * operation in queue @q. 356881245dcSWilliam Cohen */ 3578c1cf6bbSTejun Heo DEFINE_EVENT(block_bio_merge, block_bio_frontmerge, 35855782138SLi Zefan 3598c1cf6bbSTejun Heo TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio), 36055782138SLi Zefan 3618c1cf6bbSTejun Heo TP_ARGS(q, rq, bio) 36255782138SLi Zefan ); 36355782138SLi Zefan 364881245dcSWilliam Cohen /** 365881245dcSWilliam Cohen * block_bio_queue - putting new block IO operation in queue 366881245dcSWilliam Cohen * @q: queue holding operation 367881245dcSWilliam Cohen * @bio: new block operation 368881245dcSWilliam Cohen * 369881245dcSWilliam Cohen * About to place the block IO operation @bio into queue @q. 370881245dcSWilliam Cohen */ 3718c1cf6bbSTejun Heo TRACE_EVENT(block_bio_queue, 37277ca1e02SLi Zefan 37377ca1e02SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio), 37477ca1e02SLi Zefan 3758c1cf6bbSTejun Heo TP_ARGS(q, bio), 3768c1cf6bbSTejun Heo 3778c1cf6bbSTejun Heo TP_STRUCT__entry( 3788c1cf6bbSTejun Heo __field( dev_t, dev ) 3798c1cf6bbSTejun Heo __field( sector_t, sector ) 3808c1cf6bbSTejun Heo __field( unsigned int, nr_sector ) 3818c1cf6bbSTejun Heo __array( char, rwbs, RWBS_LEN ) 3828c1cf6bbSTejun Heo __array( char, comm, TASK_COMM_LEN ) 3838c1cf6bbSTejun Heo ), 3848c1cf6bbSTejun Heo 3858c1cf6bbSTejun Heo TP_fast_assign( 38674d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 3874f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 388aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 389ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 3908c1cf6bbSTejun Heo memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 3918c1cf6bbSTejun Heo ), 3928c1cf6bbSTejun Heo 3938c1cf6bbSTejun Heo TP_printk("%d,%d %s %llu + %u [%s]", 3948c1cf6bbSTejun Heo MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 3958c1cf6bbSTejun Heo (unsigned long long)__entry->sector, 3968c1cf6bbSTejun Heo __entry->nr_sector, __entry->comm) 39777ca1e02SLi Zefan ); 39877ca1e02SLi Zefan 39977ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_get_rq, 40055782138SLi Zefan 40155782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio, int rw), 40255782138SLi Zefan 40355782138SLi Zefan TP_ARGS(q, bio, rw), 40455782138SLi Zefan 40555782138SLi Zefan TP_STRUCT__entry( 40655782138SLi Zefan __field( dev_t, dev ) 40755782138SLi Zefan __field( sector_t, sector ) 40855782138SLi Zefan __field( unsigned int, nr_sector ) 409c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 41055782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 41155782138SLi Zefan ), 41255782138SLi Zefan 41355782138SLi Zefan TP_fast_assign( 41474d46992SChristoph Hellwig __entry->dev = bio ? bio_dev(bio) : 0; 4154f024f37SKent Overstreet __entry->sector = bio ? bio->bi_iter.bi_sector : 0; 416aa8b57aaSKent Overstreet __entry->nr_sector = bio ? bio_sectors(bio) : 0; 417ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, 4181eff9d32SJens Axboe bio ? bio->bi_opf : 0, __entry->nr_sector); 41955782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 42055782138SLi Zefan ), 42155782138SLi Zefan 42255782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%s]", 42355782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 4246556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 4256556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 42655782138SLi Zefan ); 42755782138SLi Zefan 428881245dcSWilliam Cohen /** 429881245dcSWilliam Cohen * block_getrq - get a free request entry in queue for block IO operations 430881245dcSWilliam Cohen * @q: queue for operations 431f8e9ec16SGreg Thelen * @bio: pending block IO operation (can be %NULL) 432881245dcSWilliam Cohen * @rw: low bit indicates a read (%0) or a write (%1) 433881245dcSWilliam Cohen * 434881245dcSWilliam Cohen * A request struct for queue @q has been allocated to handle the 435881245dcSWilliam Cohen * block IO operation @bio. 436881245dcSWilliam Cohen */ 43777ca1e02SLi Zefan DEFINE_EVENT(block_get_rq, block_getrq, 43855782138SLi Zefan 43955782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio, int rw), 44055782138SLi Zefan 44177ca1e02SLi Zefan TP_ARGS(q, bio, rw) 44277ca1e02SLi Zefan ); 44355782138SLi Zefan 444881245dcSWilliam Cohen /** 445881245dcSWilliam Cohen * block_sleeprq - waiting to get a free request entry in queue for block IO operation 446881245dcSWilliam Cohen * @q: queue for operation 447f8e9ec16SGreg Thelen * @bio: pending block IO operation (can be %NULL) 448881245dcSWilliam Cohen * @rw: low bit indicates a read (%0) or a write (%1) 449881245dcSWilliam Cohen * 450881245dcSWilliam Cohen * In the case where a request struct cannot be provided for queue @q 451881245dcSWilliam Cohen * the process needs to wait for an request struct to become 452881245dcSWilliam Cohen * available. This tracepoint event is generated each time the 453881245dcSWilliam Cohen * process goes to sleep waiting for request struct become available. 454881245dcSWilliam Cohen */ 45577ca1e02SLi Zefan DEFINE_EVENT(block_get_rq, block_sleeprq, 45655782138SLi Zefan 45777ca1e02SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio, int rw), 45855782138SLi Zefan 45977ca1e02SLi Zefan TP_ARGS(q, bio, rw) 46055782138SLi Zefan ); 46155782138SLi Zefan 462881245dcSWilliam Cohen /** 463881245dcSWilliam Cohen * block_plug - keep operations requests in request queue 464881245dcSWilliam Cohen * @q: request queue to plug 465881245dcSWilliam Cohen * 466881245dcSWilliam Cohen * Plug the request queue @q. Do not allow block operation requests 467881245dcSWilliam Cohen * to be sent to the device driver. Instead, accumulate requests in 468881245dcSWilliam Cohen * the queue to improve throughput performance of the block device. 469881245dcSWilliam Cohen */ 47055782138SLi Zefan TRACE_EVENT(block_plug, 47155782138SLi Zefan 47255782138SLi Zefan TP_PROTO(struct request_queue *q), 47355782138SLi Zefan 47455782138SLi Zefan TP_ARGS(q), 47555782138SLi Zefan 47655782138SLi Zefan TP_STRUCT__entry( 47755782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 47855782138SLi Zefan ), 47955782138SLi Zefan 48055782138SLi Zefan TP_fast_assign( 48155782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 48255782138SLi Zefan ), 48355782138SLi Zefan 48455782138SLi Zefan TP_printk("[%s]", __entry->comm) 48555782138SLi Zefan ); 48655782138SLi Zefan 48777ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_unplug, 48855782138SLi Zefan 48949cac01eSJens Axboe TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit), 49055782138SLi Zefan 49149cac01eSJens Axboe TP_ARGS(q, depth, explicit), 49255782138SLi Zefan 49355782138SLi Zefan TP_STRUCT__entry( 49455782138SLi Zefan __field( int, nr_rq ) 49555782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 49655782138SLi Zefan ), 49755782138SLi Zefan 49855782138SLi Zefan TP_fast_assign( 49994b5eb28SJens Axboe __entry->nr_rq = depth; 50055782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 50155782138SLi Zefan ), 50255782138SLi Zefan 50355782138SLi Zefan TP_printk("[%s] %d", __entry->comm, __entry->nr_rq) 50455782138SLi Zefan ); 50555782138SLi Zefan 506881245dcSWilliam Cohen /** 50749cac01eSJens Axboe * block_unplug - release of operations requests in request queue 508881245dcSWilliam Cohen * @q: request queue to unplug 50994b5eb28SJens Axboe * @depth: number of requests just added to the queue 51049cac01eSJens Axboe * @explicit: whether this was an explicit unplug, or one from schedule() 511881245dcSWilliam Cohen * 512881245dcSWilliam Cohen * Unplug request queue @q because device driver is scheduled to work 513881245dcSWilliam Cohen * on elements in the request queue. 514881245dcSWilliam Cohen */ 51549cac01eSJens Axboe DEFINE_EVENT(block_unplug, block_unplug, 51655782138SLi Zefan 51749cac01eSJens Axboe TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit), 51855782138SLi Zefan 51949cac01eSJens Axboe TP_ARGS(q, depth, explicit) 52055782138SLi Zefan ); 52155782138SLi Zefan 522881245dcSWilliam Cohen /** 523881245dcSWilliam Cohen * block_split - split a single bio struct into two bio structs 524881245dcSWilliam Cohen * @q: queue containing the bio 525881245dcSWilliam Cohen * @bio: block operation being split 526881245dcSWilliam Cohen * @new_sector: The starting sector for the new bio 527881245dcSWilliam Cohen * 528881245dcSWilliam Cohen * The bio request @bio in request queue @q needs to be split into two 529881245dcSWilliam Cohen * bio requests. The newly created @bio request starts at 530881245dcSWilliam Cohen * @new_sector. This split may be required due to hardware limitation 531881245dcSWilliam Cohen * such as operation crossing device boundaries in a RAID system. 532881245dcSWilliam Cohen */ 53355782138SLi Zefan TRACE_EVENT(block_split, 53455782138SLi Zefan 53555782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio, 53655782138SLi Zefan unsigned int new_sector), 53755782138SLi Zefan 53855782138SLi Zefan TP_ARGS(q, bio, new_sector), 53955782138SLi Zefan 54055782138SLi Zefan TP_STRUCT__entry( 54155782138SLi Zefan __field( dev_t, dev ) 54255782138SLi Zefan __field( sector_t, sector ) 54355782138SLi Zefan __field( sector_t, new_sector ) 544c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 54555782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 54655782138SLi Zefan ), 54755782138SLi Zefan 54855782138SLi Zefan TP_fast_assign( 54974d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 5504f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 55155782138SLi Zefan __entry->new_sector = new_sector; 552ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 55355782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 55455782138SLi Zefan ), 55555782138SLi Zefan 55655782138SLi Zefan TP_printk("%d,%d %s %llu / %llu [%s]", 55755782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 5586556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 5596556d1dfSSteven Rostedt (unsigned long long)__entry->new_sector, 5606556d1dfSSteven Rostedt __entry->comm) 56155782138SLi Zefan ); 56255782138SLi Zefan 563881245dcSWilliam Cohen /** 564d07335e5SMike Snitzer * block_bio_remap - map request for a logical device to the raw device 565881245dcSWilliam Cohen * @q: queue holding the operation 566881245dcSWilliam Cohen * @bio: revised operation 567881245dcSWilliam Cohen * @dev: device for the operation 568881245dcSWilliam Cohen * @from: original sector for the operation 569881245dcSWilliam Cohen * 570d07335e5SMike Snitzer * An operation for a logical device has been mapped to the 571881245dcSWilliam Cohen * raw block device. 572881245dcSWilliam Cohen */ 573d07335e5SMike Snitzer TRACE_EVENT(block_bio_remap, 57455782138SLi Zefan 57555782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev, 57655782138SLi Zefan sector_t from), 57755782138SLi Zefan 57855782138SLi Zefan TP_ARGS(q, bio, dev, from), 57955782138SLi Zefan 58055782138SLi Zefan TP_STRUCT__entry( 58155782138SLi Zefan __field( dev_t, dev ) 58255782138SLi Zefan __field( sector_t, sector ) 58355782138SLi Zefan __field( unsigned int, nr_sector ) 58455782138SLi Zefan __field( dev_t, old_dev ) 58555782138SLi Zefan __field( sector_t, old_sector ) 586c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN) 58755782138SLi Zefan ), 58855782138SLi Zefan 58955782138SLi Zefan TP_fast_assign( 59074d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 5914f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 592aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 59355782138SLi Zefan __entry->old_dev = dev; 59455782138SLi Zefan __entry->old_sector = from; 595ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 59655782138SLi Zefan ), 59755782138SLi Zefan 59855782138SLi Zefan TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu", 59955782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 6006556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 6016556d1dfSSteven Rostedt __entry->nr_sector, 60255782138SLi Zefan MAJOR(__entry->old_dev), MINOR(__entry->old_dev), 6036556d1dfSSteven Rostedt (unsigned long long)__entry->old_sector) 60455782138SLi Zefan ); 60555782138SLi Zefan 606881245dcSWilliam Cohen /** 607881245dcSWilliam Cohen * block_rq_remap - map request for a block operation request 608881245dcSWilliam Cohen * @q: queue holding the operation 609881245dcSWilliam Cohen * @rq: block IO operation request 610881245dcSWilliam Cohen * @dev: device for the operation 611881245dcSWilliam Cohen * @from: original sector for the operation 612881245dcSWilliam Cohen * 613881245dcSWilliam Cohen * The block operation request @rq in @q has been remapped. The block 614881245dcSWilliam Cohen * operation request @rq holds the current information and @from hold 615881245dcSWilliam Cohen * the original sector. 616881245dcSWilliam Cohen */ 617b0da3f0dSJun'ichi Nomura TRACE_EVENT(block_rq_remap, 618b0da3f0dSJun'ichi Nomura 619b0da3f0dSJun'ichi Nomura TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev, 620b0da3f0dSJun'ichi Nomura sector_t from), 621b0da3f0dSJun'ichi Nomura 622b0da3f0dSJun'ichi Nomura TP_ARGS(q, rq, dev, from), 623b0da3f0dSJun'ichi Nomura 624b0da3f0dSJun'ichi Nomura TP_STRUCT__entry( 625b0da3f0dSJun'ichi Nomura __field( dev_t, dev ) 626b0da3f0dSJun'ichi Nomura __field( sector_t, sector ) 627b0da3f0dSJun'ichi Nomura __field( unsigned int, nr_sector ) 628b0da3f0dSJun'ichi Nomura __field( dev_t, old_dev ) 629b0da3f0dSJun'ichi Nomura __field( sector_t, old_sector ) 63075afb352SJun'ichi Nomura __field( unsigned int, nr_bios ) 631c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN) 632b0da3f0dSJun'ichi Nomura ), 633b0da3f0dSJun'ichi Nomura 634b0da3f0dSJun'ichi Nomura TP_fast_assign( 635b0da3f0dSJun'ichi Nomura __entry->dev = disk_devt(rq->rq_disk); 636b0da3f0dSJun'ichi Nomura __entry->sector = blk_rq_pos(rq); 637b0da3f0dSJun'ichi Nomura __entry->nr_sector = blk_rq_sectors(rq); 638b0da3f0dSJun'ichi Nomura __entry->old_dev = dev; 639b0da3f0dSJun'ichi Nomura __entry->old_sector = from; 64075afb352SJun'ichi Nomura __entry->nr_bios = blk_rq_count_bios(rq); 641ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq)); 642b0da3f0dSJun'ichi Nomura ), 643b0da3f0dSJun'ichi Nomura 64475afb352SJun'ichi Nomura TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u", 645b0da3f0dSJun'ichi Nomura MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 646b0da3f0dSJun'ichi Nomura (unsigned long long)__entry->sector, 647b0da3f0dSJun'ichi Nomura __entry->nr_sector, 648b0da3f0dSJun'ichi Nomura MAJOR(__entry->old_dev), MINOR(__entry->old_dev), 64975afb352SJun'ichi Nomura (unsigned long long)__entry->old_sector, __entry->nr_bios) 650b0da3f0dSJun'ichi Nomura ); 651b0da3f0dSJun'ichi Nomura 65255782138SLi Zefan #endif /* _TRACE_BLOCK_H */ 65355782138SLi Zefan 65455782138SLi Zefan /* This part must be outside protection */ 65555782138SLi Zefan #include <trace/define_trace.h> 65655782138SLi Zefan 657