Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #undef TRACE_SYSTEM
0003 #define TRACE_SYSTEM block
0004 
0005 #if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
0006 #define _TRACE_BLOCK_H
0007 
0008 #include <linux/blktrace_api.h>
0009 #include <linux/blkdev.h>
0010 #include <linux/buffer_head.h>
0011 #include <linux/tracepoint.h>
0012 
0013 #define RWBS_LEN    8
0014 
0015 DECLARE_EVENT_CLASS(block_buffer,
0016 
0017     TP_PROTO(struct buffer_head *bh),
0018 
0019     TP_ARGS(bh),
0020 
0021     TP_STRUCT__entry (
0022         __field(  dev_t,    dev         )
0023         __field(  sector_t, sector          )
0024         __field(  size_t,   size            )
0025     ),
0026 
0027     TP_fast_assign(
0028         __entry->dev        = bh->b_bdev->bd_dev;
0029         __entry->sector     = bh->b_blocknr;
0030         __entry->size       = bh->b_size;
0031     ),
0032 
0033     TP_printk("%d,%d sector=%llu size=%zu",
0034         MAJOR(__entry->dev), MINOR(__entry->dev),
0035         (unsigned long long)__entry->sector, __entry->size
0036     )
0037 );
0038 
0039 /**
0040  * block_touch_buffer - mark a buffer accessed
0041  * @bh: buffer_head being touched
0042  *
0043  * Called from touch_buffer().
0044  */
0045 DEFINE_EVENT(block_buffer, block_touch_buffer,
0046 
0047     TP_PROTO(struct buffer_head *bh),
0048 
0049     TP_ARGS(bh)
0050 );
0051 
0052 /**
0053  * block_dirty_buffer - mark a buffer dirty
0054  * @bh: buffer_head being dirtied
0055  *
0056  * Called from mark_buffer_dirty().
0057  */
0058 DEFINE_EVENT(block_buffer, block_dirty_buffer,
0059 
0060     TP_PROTO(struct buffer_head *bh),
0061 
0062     TP_ARGS(bh)
0063 );
0064 
0065 /**
0066  * block_rq_requeue - place block IO request back on a queue
0067  * @rq: block IO operation request
0068  *
0069  * The block operation request @rq is being placed back into queue
0070  * @q.  For some reason the request was not completed and needs to be
0071  * put back in the queue.
0072  */
0073 TRACE_EVENT(block_rq_requeue,
0074 
0075     TP_PROTO(struct request *rq),
0076 
0077     TP_ARGS(rq),
0078 
0079     TP_STRUCT__entry(
0080         __field(  dev_t,    dev         )
0081         __field(  sector_t, sector          )
0082         __field(  unsigned int, nr_sector       )
0083         __array(  char,     rwbs,   RWBS_LEN    )
0084         __dynamic_array( char,  cmd,    1       )
0085     ),
0086 
0087     TP_fast_assign(
0088         __entry->dev       = rq->q->disk ? disk_devt(rq->q->disk) : 0;
0089         __entry->sector    = blk_rq_trace_sector(rq);
0090         __entry->nr_sector = blk_rq_trace_nr_sectors(rq);
0091 
0092         blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
0093         __get_str(cmd)[0] = '\0';
0094     ),
0095 
0096     TP_printk("%d,%d %s (%s) %llu + %u [%d]",
0097           MAJOR(__entry->dev), MINOR(__entry->dev),
0098           __entry->rwbs, __get_str(cmd),
0099           (unsigned long long)__entry->sector,
0100           __entry->nr_sector, 0)
0101 );
0102 
0103 DECLARE_EVENT_CLASS(block_rq_completion,
0104 
0105     TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes),
0106 
0107     TP_ARGS(rq, error, nr_bytes),
0108 
0109     TP_STRUCT__entry(
0110         __field(  dev_t,    dev         )
0111         __field(  sector_t, sector          )
0112         __field(  unsigned int, nr_sector       )
0113         __field(  int   ,   error           )
0114         __array(  char,     rwbs,   RWBS_LEN    )
0115         __dynamic_array( char,  cmd,    1       )
0116     ),
0117 
0118     TP_fast_assign(
0119         __entry->dev       = rq->q->disk ? disk_devt(rq->q->disk) : 0;
0120         __entry->sector    = blk_rq_pos(rq);
0121         __entry->nr_sector = nr_bytes >> 9;
0122         __entry->error     = blk_status_to_errno(error);
0123 
0124         blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
0125         __get_str(cmd)[0] = '\0';
0126     ),
0127 
0128     TP_printk("%d,%d %s (%s) %llu + %u [%d]",
0129           MAJOR(__entry->dev), MINOR(__entry->dev),
0130           __entry->rwbs, __get_str(cmd),
0131           (unsigned long long)__entry->sector,
0132           __entry->nr_sector, __entry->error)
0133 );
0134 
0135 /**
0136  * block_rq_complete - block IO operation completed by device driver
0137  * @rq: block operations request
0138  * @error: status code
0139  * @nr_bytes: number of completed bytes
0140  *
0141  * The block_rq_complete tracepoint event indicates that some portion
0142  * of operation request has been completed by the device driver.  If
0143  * the @rq->bio is %NULL, then there is absolutely no additional work to
0144  * do for the request. If @rq->bio is non-NULL then there is
0145  * additional work required to complete the request.
0146  */
0147 DEFINE_EVENT(block_rq_completion, block_rq_complete,
0148 
0149     TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes),
0150 
0151     TP_ARGS(rq, error, nr_bytes)
0152 );
0153 
0154 /**
0155  * block_rq_error - block IO operation error reported by device driver
0156  * @rq: block operations request
0157  * @error: status code
0158  * @nr_bytes: number of completed bytes
0159  *
0160  * The block_rq_error tracepoint event indicates that some portion
0161  * of operation request has failed as reported by the device driver.
0162  */
0163 DEFINE_EVENT(block_rq_completion, block_rq_error,
0164 
0165     TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes),
0166 
0167     TP_ARGS(rq, error, nr_bytes)
0168 );
0169 
0170 DECLARE_EVENT_CLASS(block_rq,
0171 
0172     TP_PROTO(struct request *rq),
0173 
0174     TP_ARGS(rq),
0175 
0176     TP_STRUCT__entry(
0177         __field(  dev_t,    dev         )
0178         __field(  sector_t, sector          )
0179         __field(  unsigned int, nr_sector       )
0180         __field(  unsigned int, bytes           )
0181         __array(  char,     rwbs,   RWBS_LEN    )
0182         __array(  char,         comm,   TASK_COMM_LEN   )
0183         __dynamic_array( char,  cmd,    1       )
0184     ),
0185 
0186     TP_fast_assign(
0187         __entry->dev       = rq->q->disk ? disk_devt(rq->q->disk) : 0;
0188         __entry->sector    = blk_rq_trace_sector(rq);
0189         __entry->nr_sector = blk_rq_trace_nr_sectors(rq);
0190         __entry->bytes     = blk_rq_bytes(rq);
0191 
0192         blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
0193         __get_str(cmd)[0] = '\0';
0194         memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
0195     ),
0196 
0197     TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
0198           MAJOR(__entry->dev), MINOR(__entry->dev),
0199           __entry->rwbs, __entry->bytes, __get_str(cmd),
0200           (unsigned long long)__entry->sector,
0201           __entry->nr_sector, __entry->comm)
0202 );
0203 
0204 /**
0205  * block_rq_insert - insert block operation request into queue
0206  * @rq: block IO operation request
0207  *
0208  * Called immediately before block operation request @rq is inserted
0209  * into queue @q.  The fields in the operation request @rq struct can
0210  * be examined to determine which device and sectors the pending
0211  * operation would access.
0212  */
0213 DEFINE_EVENT(block_rq, block_rq_insert,
0214 
0215     TP_PROTO(struct request *rq),
0216 
0217     TP_ARGS(rq)
0218 );
0219 
0220 /**
0221  * block_rq_issue - issue pending block IO request operation to device driver
0222  * @rq: block IO operation request
0223  *
0224  * Called when block operation request @rq from queue @q is sent to a
0225  * device driver for processing.
0226  */
0227 DEFINE_EVENT(block_rq, block_rq_issue,
0228 
0229     TP_PROTO(struct request *rq),
0230 
0231     TP_ARGS(rq)
0232 );
0233 
0234 /**
0235  * block_rq_merge - merge request with another one in the elevator
0236  * @rq: block IO operation request
0237  *
0238  * Called when block operation request @rq from queue @q is merged to another
0239  * request queued in the elevator.
0240  */
0241 DEFINE_EVENT(block_rq, block_rq_merge,
0242 
0243     TP_PROTO(struct request *rq),
0244 
0245     TP_ARGS(rq)
0246 );
0247 
0248 /**
0249  * block_bio_complete - completed all work on the block operation
0250  * @q: queue holding the block operation
0251  * @bio: block operation completed
0252  *
0253  * This tracepoint indicates there is no further work to do on this
0254  * block IO operation @bio.
0255  */
0256 TRACE_EVENT(block_bio_complete,
0257 
0258     TP_PROTO(struct request_queue *q, struct bio *bio),
0259 
0260     TP_ARGS(q, bio),
0261 
0262     TP_STRUCT__entry(
0263         __field( dev_t,     dev     )
0264         __field( sector_t,  sector      )
0265         __field( unsigned,  nr_sector   )
0266         __field( int,       error       )
0267         __array( char,      rwbs,   RWBS_LEN)
0268     ),
0269 
0270     TP_fast_assign(
0271         __entry->dev        = bio_dev(bio);
0272         __entry->sector     = bio->bi_iter.bi_sector;
0273         __entry->nr_sector  = bio_sectors(bio);
0274         __entry->error      = blk_status_to_errno(bio->bi_status);
0275         blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
0276     ),
0277 
0278     TP_printk("%d,%d %s %llu + %u [%d]",
0279           MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
0280           (unsigned long long)__entry->sector,
0281           __entry->nr_sector, __entry->error)
0282 );
0283 
0284 DECLARE_EVENT_CLASS(block_bio,
0285 
0286     TP_PROTO(struct bio *bio),
0287 
0288     TP_ARGS(bio),
0289 
0290     TP_STRUCT__entry(
0291         __field( dev_t,     dev         )
0292         __field( sector_t,  sector          )
0293         __field( unsigned int,  nr_sector       )
0294         __array( char,      rwbs,   RWBS_LEN    )
0295         __array( char,      comm,   TASK_COMM_LEN   )
0296     ),
0297 
0298     TP_fast_assign(
0299         __entry->dev        = bio_dev(bio);
0300         __entry->sector     = bio->bi_iter.bi_sector;
0301         __entry->nr_sector  = bio_sectors(bio);
0302         blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
0303         memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
0304     ),
0305 
0306     TP_printk("%d,%d %s %llu + %u [%s]",
0307           MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
0308           (unsigned long long)__entry->sector,
0309           __entry->nr_sector, __entry->comm)
0310 );
0311 
0312 /**
0313  * block_bio_bounce - used bounce buffer when processing block operation
0314  * @bio: block operation
0315  *
0316  * A bounce buffer was used to handle the block operation @bio in @q.
0317  * This occurs when hardware limitations prevent a direct transfer of
0318  * data between the @bio data memory area and the IO device.  Use of a
0319  * bounce buffer requires extra copying of data and decreases
0320  * performance.
0321  */
0322 DEFINE_EVENT(block_bio, block_bio_bounce,
0323     TP_PROTO(struct bio *bio),
0324     TP_ARGS(bio)
0325 );
0326 
0327 /**
0328  * block_bio_backmerge - merging block operation to the end of an existing operation
0329  * @bio: new block operation to merge
0330  *
0331  * Merging block request @bio to the end of an existing block request.
0332  */
0333 DEFINE_EVENT(block_bio, block_bio_backmerge,
0334     TP_PROTO(struct bio *bio),
0335     TP_ARGS(bio)
0336 );
0337 
0338 /**
0339  * block_bio_frontmerge - merging block operation to the beginning of an existing operation
0340  * @bio: new block operation to merge
0341  *
0342  * Merging block IO operation @bio to the beginning of an existing block request.
0343  */
0344 DEFINE_EVENT(block_bio, block_bio_frontmerge,
0345     TP_PROTO(struct bio *bio),
0346     TP_ARGS(bio)
0347 );
0348 
0349 /**
0350  * block_bio_queue - putting new block IO operation in queue
0351  * @bio: new block operation
0352  *
0353  * About to place the block IO operation @bio into queue @q.
0354  */
0355 DEFINE_EVENT(block_bio, block_bio_queue,
0356     TP_PROTO(struct bio *bio),
0357     TP_ARGS(bio)
0358 );
0359 
0360 /**
0361  * block_getrq - get a free request entry in queue for block IO operations
0362  * @bio: pending block IO operation (can be %NULL)
0363  *
0364  * A request struct has been allocated to handle the block IO operation @bio.
0365  */
0366 DEFINE_EVENT(block_bio, block_getrq,
0367     TP_PROTO(struct bio *bio),
0368     TP_ARGS(bio)
0369 );
0370 
0371 /**
0372  * block_plug - keep operations requests in request queue
0373  * @q: request queue to plug
0374  *
0375  * Plug the request queue @q.  Do not allow block operation requests
0376  * to be sent to the device driver. Instead, accumulate requests in
0377  * the queue to improve throughput performance of the block device.
0378  */
0379 TRACE_EVENT(block_plug,
0380 
0381     TP_PROTO(struct request_queue *q),
0382 
0383     TP_ARGS(q),
0384 
0385     TP_STRUCT__entry(
0386         __array( char,      comm,   TASK_COMM_LEN   )
0387     ),
0388 
0389     TP_fast_assign(
0390         memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
0391     ),
0392 
0393     TP_printk("[%s]", __entry->comm)
0394 );
0395 
0396 DECLARE_EVENT_CLASS(block_unplug,
0397 
0398     TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
0399 
0400     TP_ARGS(q, depth, explicit),
0401 
0402     TP_STRUCT__entry(
0403         __field( int,       nr_rq           )
0404         __array( char,      comm,   TASK_COMM_LEN   )
0405     ),
0406 
0407     TP_fast_assign(
0408         __entry->nr_rq = depth;
0409         memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
0410     ),
0411 
0412     TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
0413 );
0414 
0415 /**
0416  * block_unplug - release of operations requests in request queue
0417  * @q: request queue to unplug
0418  * @depth: number of requests just added to the queue
0419  * @explicit: whether this was an explicit unplug, or one from schedule()
0420  *
0421  * Unplug request queue @q because device driver is scheduled to work
0422  * on elements in the request queue.
0423  */
0424 DEFINE_EVENT(block_unplug, block_unplug,
0425 
0426     TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
0427 
0428     TP_ARGS(q, depth, explicit)
0429 );
0430 
0431 /**
0432  * block_split - split a single bio struct into two bio structs
0433  * @bio: block operation being split
0434  * @new_sector: The starting sector for the new bio
0435  *
0436  * The bio request @bio needs to be split into two bio requests.  The newly
0437  * created @bio request starts at @new_sector. This split may be required due to
0438  * hardware limitations such as operation crossing device boundaries in a RAID
0439  * system.
0440  */
0441 TRACE_EVENT(block_split,
0442 
0443     TP_PROTO(struct bio *bio, unsigned int new_sector),
0444 
0445     TP_ARGS(bio, new_sector),
0446 
0447     TP_STRUCT__entry(
0448         __field( dev_t,     dev             )
0449         __field( sector_t,  sector              )
0450         __field( sector_t,  new_sector          )
0451         __array( char,      rwbs,       RWBS_LEN    )
0452         __array( char,      comm,       TASK_COMM_LEN   )
0453     ),
0454 
0455     TP_fast_assign(
0456         __entry->dev        = bio_dev(bio);
0457         __entry->sector     = bio->bi_iter.bi_sector;
0458         __entry->new_sector = new_sector;
0459         blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
0460         memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
0461     ),
0462 
0463     TP_printk("%d,%d %s %llu / %llu [%s]",
0464           MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
0465           (unsigned long long)__entry->sector,
0466           (unsigned long long)__entry->new_sector,
0467           __entry->comm)
0468 );
0469 
0470 /**
0471  * block_bio_remap - map request for a logical device to the raw device
0472  * @bio: revised operation
0473  * @dev: original device for the operation
0474  * @from: original sector for the operation
0475  *
0476  * An operation for a logical device has been mapped to the
0477  * raw block device.
0478  */
0479 TRACE_EVENT(block_bio_remap,
0480 
0481     TP_PROTO(struct bio *bio, dev_t dev, sector_t from),
0482 
0483     TP_ARGS(bio, dev, from),
0484 
0485     TP_STRUCT__entry(
0486         __field( dev_t,     dev     )
0487         __field( sector_t,  sector      )
0488         __field( unsigned int,  nr_sector   )
0489         __field( dev_t,     old_dev     )
0490         __field( sector_t,  old_sector  )
0491         __array( char,      rwbs,   RWBS_LEN)
0492     ),
0493 
0494     TP_fast_assign(
0495         __entry->dev        = bio_dev(bio);
0496         __entry->sector     = bio->bi_iter.bi_sector;
0497         __entry->nr_sector  = bio_sectors(bio);
0498         __entry->old_dev    = dev;
0499         __entry->old_sector = from;
0500         blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
0501     ),
0502 
0503     TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
0504           MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
0505           (unsigned long long)__entry->sector,
0506           __entry->nr_sector,
0507           MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
0508           (unsigned long long)__entry->old_sector)
0509 );
0510 
0511 /**
0512  * block_rq_remap - map request for a block operation request
0513  * @rq: block IO operation request
0514  * @dev: device for the operation
0515  * @from: original sector for the operation
0516  *
0517  * The block operation request @rq in @q has been remapped.  The block
0518  * operation request @rq holds the current information and @from hold
0519  * the original sector.
0520  */
0521 TRACE_EVENT(block_rq_remap,
0522 
0523     TP_PROTO(struct request *rq, dev_t dev, sector_t from),
0524 
0525     TP_ARGS(rq, dev, from),
0526 
0527     TP_STRUCT__entry(
0528         __field( dev_t,     dev     )
0529         __field( sector_t,  sector      )
0530         __field( unsigned int,  nr_sector   )
0531         __field( dev_t,     old_dev     )
0532         __field( sector_t,  old_sector  )
0533         __field( unsigned int,  nr_bios     )
0534         __array( char,      rwbs,   RWBS_LEN)
0535     ),
0536 
0537     TP_fast_assign(
0538         __entry->dev        = disk_devt(rq->q->disk);
0539         __entry->sector     = blk_rq_pos(rq);
0540         __entry->nr_sector  = blk_rq_sectors(rq);
0541         __entry->old_dev    = dev;
0542         __entry->old_sector = from;
0543         __entry->nr_bios    = blk_rq_count_bios(rq);
0544         blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
0545     ),
0546 
0547     TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u",
0548           MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
0549           (unsigned long long)__entry->sector,
0550           __entry->nr_sector,
0551           MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
0552           (unsigned long long)__entry->old_sector, __entry->nr_bios)
0553 );
0554 
0555 #endif /* _TRACE_BLOCK_H */
0556 
0557 /* This part must be outside protection */
0558 #include <trace/define_trace.h>
0559