On Thu, May 06, 2021 at 08:16:25PM -0700, Bart Van Assche wrote: > On 5/6/21 7:05 PM, Ming Lei wrote: > > Putting the lock pair after clearing rq mapping should work, but not see > > any benefit: not very readable, and memory barrier knowledge is required for > > understanding its correctness(cmpxchg has to be completed before unlock), ..., > > so is it better idea to move lock pair after clearing rq mapping? > > It depends on how much time will be spent inside > blk_mq_clear_rq_mapping(). If the time spent in the nested loop in > blk_mq_clear_rq_mapping() would be significant then the proposed change > will help to reduce interrupt latency in blk_mq_find_and_get_req(). interrupt latency in blk_mq_find_and_get_req() shouldn't be increased because interrupt won't be disabled when spinning on the lock. But interrupt may be disabled for a while in blk_mq_clear_rq_mapping() in case of big nr_requests and hw queue depth. Fair enough, will take this way for not holding lock for too long. Thanks, Ming