Skip to content

Commit 2a90d4a

Browse files
bonziniaxboe
authored andcommitted
blk-mq: use get_cpu/put_cpu instead of preempt_disable/preempt_enable
blk-mq is using preempt_disable/enable in order to ensure that the queue runners are placed on the right CPU. This does not work with the RT patches, because __blk_mq_run_hw_queue takes a non-raw spinlock with the preemption-disabled region. If there is contention on the lock, this violates the rules for preemption-disabled regions. While this should be easily fixable within the RT patches just by doing migrate_disable/enable, we can do better and document _why_ this particular region runs with disabled preemption. After the previous patch, it is trivial to switch it to get/put_cpu; the RT patches then can change it to get_cpu_light, which lets virtio-blk run under RT kernels. Cc: Jens Axboe <[email protected]> Cc: Thomas Gleixner <[email protected]> Reported-by: Clark Williams <[email protected]> Tested-by: Clark Williams <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 398205b commit 2a90d4a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

block/blk-mq.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -802,14 +802,14 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
802802
return;
803803

804804
if (!async) {
805-
preempt_disable();
806-
if (cpumask_test_cpu(smp_processor_id(), hctx->cpumask)) {
805+
int cpu = get_cpu();
806+
if (cpumask_test_cpu(cpu, hctx->cpumask)) {
807807
__blk_mq_run_hw_queue(hctx);
808-
preempt_enable();
808+
put_cpu();
809809
return;
810810
}
811811

812-
preempt_enable();
812+
put_cpu();
813813
}
814814

815815
if (hctx->queue->nr_hw_queues == 1)

0 commit comments

Comments
 (0)