[PATCH 3/6] blk-mq: optimise *end_request non-stat path

From: Pavel Begunkov
Date: Sat Oct 09 2021 - 08:26:46 EST


We already have a blk_mq_need_time_stamp() check in
__blk_mq_end_request() to get a timestamp, hide all the statistics
accounting under it. It cuts some cycles for requests that don't need
stats, and is free otherwise.

Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx>
---
block/blk-mq.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 9430a0def2c9..c3da521efd35 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -584,12 +584,11 @@ static inline void __blk_mq_end_request_acct(struct request *rq,

inline void __blk_mq_end_request(struct request *rq, blk_status_t error)
{
- u64 now = 0;
-
- if (blk_mq_need_time_stamp(rq))
- now = ktime_get_ns();
+ if (blk_mq_need_time_stamp(rq)) {
+ u64 now = ktime_get_ns();

- __blk_mq_end_request_acct(rq, error, now);
+ __blk_mq_end_request_acct(rq, error, now);
+ }

if (rq->end_io) {
rq_qos_done(rq->q, rq);
--
2.33.0