On 1/15/24 11:42 PM, Yu Kuai wrote: > Hi, > > ? 2024/01/16 5:53, Jens Axboe ??: >> @@ -2810,7 +2810,7 @@ static void ioc_rqos_done(struct rq_qos *rqos, struct request *rq) >> return; >> } >> - on_q_ns = ktime_get_ns() - rq->alloc_time_ns; >> + on_q_ns = blk_time_get_ns() - rq->alloc_time_ns; > > Just notice that this is from io completion path, and the same as > blk_account_io_done(), where plug does not exist. Hence ktime_get_ns() > will still be called multiple times after patch 2. > > Do you think will this worth to be optimized? For example, add a new > field in request so that each rq completion will only call > ktime_get_ns() once. Furthermore, we can optimize io_tices precision > from jiffies to ns. Right, as mentioned this is just an issue side optimization, my intent is/was to convert all callers of ktime_get_ns() to use the internal one. The completion side will just not get any amortization of the frequency of time calls for now, but then it's prepared for that later on. That, to me, was nicer than doing selective conversions as then it's not clear if the two time sources could be compared. It isn't complete yet, I just did the main components. Putting it in the request is one way, ideally we'd have completion batching via struct io_comp_batch for the completion side. At least that was my plan. -- Jens Axboe