summaryrefslogtreecommitdiff
path: root/block/blk.h
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-10-09 13:25:41 +0100
committerJens Axboe <axboe@kernel.dk>2021-10-18 06:17:34 -0600
commitbe6bfe36db1795babe9d92178a47b2e02193cb0f (patch)
tree7660114e15888566a81a0c766c878c63910d29eb /block/blk.h
parent8a709512eae7ccd5ba73e8634474caadbc9ebe76 (diff)
block: inline hot paths of blk_account_io_*()
Extract hot paths of __blk_account_io_start() and __blk_account_io_done() into inline functions, so we don't always pay for function calls. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/b0662a636bd4cc7b4f84c9d0a41efa46a688ef13.1633781740.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk.h')
-rw-r--r--block/blk.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/block/blk.h b/block/blk.h
index 618482b29671..cab8d659d8a6 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -221,8 +221,8 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
bool blk_bio_list_merge(struct request_queue *q, struct list_head *list,
struct bio *bio, unsigned int nr_segs);
-void blk_account_io_start(struct request *req);
-void blk_account_io_done(struct request *req, u64 now);
+void __blk_account_io_start(struct request *req);
+void __blk_account_io_done(struct request *req, u64 now);
/*
* Plug flush limits
@@ -286,7 +286,25 @@ int blk_dev_init(void);
*/
static inline bool blk_do_io_stat(struct request *rq)
{
- return rq->rq_disk && (rq->rq_flags & RQF_IO_STAT);
+ return (rq->rq_flags & RQF_IO_STAT) && rq->rq_disk;
+}
+
+static inline void blk_account_io_done(struct request *req, u64 now)
+{
+ /*
+ * Account IO completion. flush_rq isn't accounted as a
+ * normal IO on queueing nor completion. Accounting the
+ * containing request is enough.
+ */
+ if (blk_do_io_stat(req) && req->part &&
+ !(req->rq_flags & RQF_FLUSH_SEQ))
+ __blk_account_io_done(req, now);
+}
+
+static inline void blk_account_io_start(struct request *req)
+{
+ if (blk_do_io_stat(req))
+ __blk_account_io_start(req);
}
static inline void req_set_nomerge(struct request_queue *q, struct request *req)