Skip to content

Commit e94f685

Browse files
isilenceaxboe
authored andcommitted
block: kill extra rcu lock/unlock in queue enter
blk_try_enter_queue() already takes rcu_read_lock/unlock, so we can avoid the second pair in percpu_ref_tryget_live(), use a newly added percpu_ref_tryget_live_rcu(). As rcu_read_lock/unlock imply barrier()s, it's pretty noticeable, especially for for !CONFIG_PREEMPT_RCU (default for some distributions), where __rcu_read_lock/unlock() are not inlined. 3.20% io_uring [kernel.vmlinux] [k] __rcu_read_unlock 3.05% io_uring [kernel.vmlinux] [k] __rcu_read_lock 2.52% io_uring [kernel.vmlinux] [k] __rcu_read_unlock 2.28% io_uring [kernel.vmlinux] [k] __rcu_read_lock Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/6b11c67ea495ed9d44f067622d852de4a510ce65.1634822969.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 3b13c16 commit e94f685

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/blk-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ EXPORT_SYMBOL(blk_cleanup_queue);
389389
static bool blk_try_enter_queue(struct request_queue *q, bool pm)
390390
{
391391
rcu_read_lock();
392-
if (!percpu_ref_tryget_live(&q->q_usage_counter))
392+
if (!percpu_ref_tryget_live_rcu(&q->q_usage_counter))
393393
goto fail;
394394

395395
/*

0 commit comments

Comments
 (0)