Re: [PATCH v3 1/1] block/blk-mq: use atomic_t for quiesce_depth to avoid lock contention on RT

Sebastian Andrzej Siewior <[email protected]>
Newsgroups org.kernel.vger.linux-rt-users,org.kernel.vger.linux-block,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>
On 2026-02-11 22:39:29 [+0200], Ionut Nechita (Wind River) wrote:
> From: Ionut Nechita <[email protected]>
> 
> In RT kernel (PREEMPT_RT), commit 679b1874eba7 ("block: fix ordering
> between checking QUEUE_FLAG_QUIESCED request adding") causes severe
…

> Suggested-by: Sebastian Andrzej Siewior <[email protected]>
> Fixes: 679b1874eba7 ("block: fix ordering between checking QUEUE_FLAG_QUIESCED request adding")
This is
         6bda857bcbb86 ("block: fix ordering between checking QUEUE_FLAG_QUIESCED request adding")

in my tree. I don't have your hash anywhere. The hash at the top in the
email is also affected.

> Cc: [email protected]
> Signed-off-by: Ionut Nechita <[email protected]>

Otherwise
Reviewed-by: Sebastian Andrzej Siewior <[email protected]>

> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -314,21 +314,18 @@ EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue);
>   */
>  void blk_mq_unquiesce_queue(struct request_queue *q)
>  {
> -	unsigned long flags;
> -	bool run_queue = false;
> +	int depth;
>  
> -	spin_lock_irqsave(&q->queue_lock, flags);
> -	if (WARN_ON_ONCE(q->quiesce_depth <= 0)) {
> -		;
> -	} else if (!--q->quiesce_depth) {
> -		blk_queue_flag_clear(QUEUE_FLAG_QUIESCED, q);
> -		run_queue = true;
> -	}
> -	spin_unlock_irqrestore(&q->queue_lock, flags);
> +	depth = atomic_dec_if_positive(&q->quiesce_depth);
> +	if (WARN_ON_ONCE(depth < 0))
> +		return;

Ah. That is cute.

> -	/* dispatch requests which are inserted during quiescing */
> -	if (run_queue)
> +	if (depth == 0) {
> +		/* Ensure the decrement is visible before running queues */
> +		smp_mb__after_atomic();
> +		/* dispatch requests which are inserted during quiescing */
>  		blk_mq_run_hw_queues(q, true);
> +	}
>  }
>  EXPORT_SYMBOL_GPL(blk_mq_unquiesce_queue);
>  

Sebastian
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.