Skip to content

Commit

Permalink
blk-mq: Don't complete on a remote CPU in force threaded mode
Browse files Browse the repository at this point in the history
With force threaded interrupts enabled, raising softirq from an SMP
function call will always result in waking the ksoftirqd thread. This is
not optimal given that the thread runs at SCHED_OTHER priority.

Completing the request in hard IRQ-context on PREEMPT_RT (which enforces
the force threaded mode) is bad because the completion handler may
acquire sleeping locks which violate the locking context.

Disable request completing on a remote CPU in force threaded mode.

Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Daniel Wagner <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Sebastian Andrzej Siewior authored and axboe committed Dec 17, 2020
1 parent 53a7f65 commit 7142518
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
@@ -650,6 +650,14 @@ static inline bool blk_mq_complete_need_ipi(struct request *rq)
if (!IS_ENABLED(CONFIG_SMP) ||
!test_bit(QUEUE_FLAG_SAME_COMP, &rq->q->queue_flags))
return false;
/*
* With force threaded interrupts enabled, raising softirq from an SMP
* function call will always result in waking the ksoftirqd thread.
* This is probably worse than completing the request on a different
* cache domain.
*/
if (force_irqthreads)
return false;

/* same CPU or cache domain? Complete locally */
if (cpu == rq->mq_ctx->cpu ||

0 comments on commit 7142518

Please sign in to comment.