From c631860448d9918445cb9d46fc6580ffbddd4b6b Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Wed, 22 Jun 2022 10:25:54 +0200 Subject: [PATCH] UPSTREAM: blk-mq: Don't disable preemption around __blk_mq_run_hw_queue(). __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(). Change-Id: Ia802417a96fdea68a3912a5ce59f2ea9b85cd664 Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Ming Lei Link: https://lore.kernel.org/r/YrLSEiNvagKJaDs5@linutronix.de Signed-off-by: Jens Axboe (cherry picked from commit 3c8f9da41ed90294d8ca42b3ad8a13c5379bd549) [ bvanassche: Additionally, this patch fixes a sleep-in-atomic-context bug for drivers that set BLK_MQ_F_BLOCKING ] Signed-off-by: Bart Van Assche --- block/blk-mq.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 686fe6f99651..2ece8ed55e72 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1569,14 +1569,10 @@ static void __blk_mq_delay_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async, 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,