Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: move issue side time stamping to blk_account_io_start()

It's known needed at that point, and it's cleaner to just assign it
there rather than rely on it being reliably set before hitting the
IO accounting. Hence, move it out of blk_mq_rq_time_init(), which is
now only doing the allocation side timing.

While at it, get rid of the '0' time passing to blk_mq_rq_time_init(),
just pass in blk_time_get_ns() for the two cases where 0 is being
explicitly passed in. The rest pass in the previously cached allocation
time.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

+4 -8
+4 -8
block/blk-mq.c
··· 331 331 /* Set start and alloc time when the allocated request is actually used */ 332 332 static inline void blk_mq_rq_time_init(struct request *rq, u64 alloc_time_ns) 333 333 { 334 - if (blk_queue_io_stat(rq->q)) 335 - rq->start_time_ns = blk_time_get_ns(); 336 - else 337 - rq->start_time_ns = 0; 338 - 339 334 #ifdef CONFIG_BLK_RQ_ALLOC_TIME 340 335 if (blk_queue_rq_alloc_time(rq->q)) 341 - rq->alloc_time_ns = alloc_time_ns ?: rq->start_time_ns; 336 + rq->alloc_time_ns = alloc_time_ns; 342 337 else 343 338 rq->alloc_time_ns = 0; 344 339 #endif ··· 561 566 return NULL; 562 567 563 568 plug->cached_rq = rq_list_next(rq); 564 - blk_mq_rq_time_init(rq, 0); 569 + blk_mq_rq_time_init(rq, blk_time_get_ns()); 565 570 } 566 571 567 572 rq->cmd_flags = opf; ··· 998 1003 return; 999 1004 1000 1005 req->rq_flags |= RQF_IO_STAT; 1006 + req->start_time_ns = blk_time_get_ns(); 1001 1007 1002 1008 /* 1003 1009 * All non-passthrough requests are created from a bio with one ··· 2905 2909 plug->cached_rq = rq_list_next(rq); 2906 2910 rq_qos_throttle(rq->q, bio); 2907 2911 2908 - blk_mq_rq_time_init(rq, 0); 2912 + blk_mq_rq_time_init(rq, blk_time_get_ns()); 2909 2913 rq->cmd_flags = bio->bi_opf; 2910 2914 INIT_LIST_HEAD(&rq->queuelist); 2911 2915 }