diff mbox series

[v2] blk-mq: Don't disable preemption around __blk_mq_run_hw_queue().

Message ID YrLSEiNvagKJaDs5@linutronix.de (mailing list archive)
State New, archived
Headers show
Series [v2] blk-mq: Don't disable preemption around __blk_mq_run_hw_queue(). | expand

Commit Message

Sebastian Andrzej Siewior June 22, 2022, 8:25 a.m. UTC
__blk_mq_delay_run_hw_queue() disables preemption to get a stable
current CPU number and then invokes __blk_mq_run_hw_queue() if the CPU
number is part the mask.

__blk_mq_run_hw_queue() acquires a spin_lock_t which is a sleeping lock
on PREEMPT_RT and can't be acquired with disabled preemption.

It is not required for correctness to invoke __blk_mq_run_hw_queue() on
a CPU matching hctx->cpumask. Both (async and direct requests) can run
on a CPU not matching hctx->cpumask.

The CPU mask without disabling preemption and invoking
__blk_mq_run_hw_queue().

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
v1…v2:
  - Drop migrate_disable() as per Ming Lei.

 block/blk-mq.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Ming Lei June 22, 2022, 8:35 a.m. UTC | #1
On Wed, Jun 22, 2022 at 10:25:54AM +0200, Sebastian Andrzej Siewior wrote:
> __blk_mq_delay_run_hw_queue() disables preemption to get a stable
> current CPU number and then invokes __blk_mq_run_hw_queue() if the CPU
> number is part the mask.
> 
> __blk_mq_run_hw_queue() acquires a spin_lock_t which is a sleeping lock
> on PREEMPT_RT and can't be acquired with disabled preemption.
> 
> It is not required for correctness to invoke __blk_mq_run_hw_queue() on
> a CPU matching hctx->cpumask. Both (async and direct requests) can run
> on a CPU not matching hctx->cpumask.
> 
> The CPU mask without disabling preemption and invoking
> __blk_mq_run_hw_queue().
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Looks fine:

Reviewed-by: Ming Lei <ming.lei@redhat.com>

Thanks,
Ming
Jens Axboe June 22, 2022, 5:46 p.m. UTC | #2
On Wed, 22 Jun 2022 10:25:54 +0200, Sebastian Andrzej Siewior wrote:
> __blk_mq_delay_run_hw_queue() disables preemption to get a stable
> current CPU number and then invokes __blk_mq_run_hw_queue() if the CPU
> number is part the mask.
> 
> __blk_mq_run_hw_queue() acquires a spin_lock_t which is a sleeping lock
> on PREEMPT_RT and can't be acquired with disabled preemption.
> 
> [...]

Applied, thanks!

[1/1] blk-mq: Don't disable preemption around __blk_mq_run_hw_queue().
      commit: c9198d784fa93d447afe8e4627dfe205f0ce5ec8

Best regards,
diff mbox series

Patch

--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2085,14 +2085,10 @@  static void __blk_mq_delay_run_hw_queue(
 		return;
 
 	if (!async && !(hctx->flags & BLK_MQ_F_BLOCKING)) {
-		int cpu = get_cpu();
-		if (cpumask_test_cpu(cpu, hctx->cpumask)) {
+		if (cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask)) {
 			__blk_mq_run_hw_queue(hctx);
-			put_cpu();
 			return;
 		}
-
-		put_cpu();
 	}
 
 	kblockd_mod_delayed_work_on(blk_mq_hctx_next_cpu(hctx), &hctx->run_work,