hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IAGRKP CVE: NA
--------------------------------
The time will be reused for completing bio, to avoid getting ns time again.
Signed-off-by: Yu Kuai yukuai3@huawei.com --- block/blk-mq.c | 6 +++++- block/blk-mq.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c index be503078aadf..539586b05646 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -371,6 +371,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, blk_mq_get_alloc_task(rq, data->bio);
rq->io_start_time_ns = 0; + request_to_wrapper(rq)->io_end_time_ns = 0; rq->nr_phys_segments = 0; #if defined(CONFIG_BLK_DEV_INTEGRITY) rq->nr_integrity_segments = 0; @@ -580,7 +581,10 @@ EXPORT_SYMBOL_GPL(blk_mq_free_request);
inline void __blk_mq_end_request(struct request *rq, blk_status_t error) { - u64 now = blk_time_get_ns(); + u64 now = request_to_wrapper(rq)->io_end_time_ns; + + if (!now) + now = blk_time_get_ns();
if (rq->rq_flags & RQF_STATS) { blk_mq_poll_stats_start(rq->q); diff --git a/block/blk-mq.h b/block/blk-mq.h index 01009f774f54..46f7f382ecaf 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -37,6 +37,7 @@ struct blk_mq_ctx { } ____cacheline_aligned_in_smp;
struct request_wrapper { + u64 io_end_time_ns; #ifdef CONFIG_BLK_BIO_ALLOC_TIME u64 bi_alloc_time_ns; #endif