From: Bart Van Assche <bvanassche@acm.org>
To: "Ionut Nechita (Wind River)" <ionut.nechita@windriver.com>,
axboe@kernel.dk, linux-block@vger.kernel.org
Cc: bigeasy@linutronix.de, clrkwllms@kernel.org, rostedt@goodmis.org,
ming.lei@redhat.com, muchun.song@linux.dev,
mkhalfella@purestorage.com, chris.friesen@windriver.com,
linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
linux-rt-users@vger.kernel.org, stable@vger.kernel.org,
ionut_n2001@yahoo.com, sunlightlinux@gmail.com
Subject: Re: [PATCH v6 1/1] block/blk-mq: use atomic_t for quiesce_depth to avoid lock contention on RT
Date: Wed, 6 May 2026 09:14:33 +0200 [thread overview]
Message-ID: <50187fa5-03a9-4ca3-bcaf-a36ed75bda2c@acm.org> (raw)
In-Reply-To: <406f424c0a718bf492d40c206983e355e600945a.1778048987.git.ionut.nechita@windriver.com>
On 5/6/26 8:56 AM, Ionut Nechita (Wind River) wrote:
> void blk_mq_quiesce_queue_nowait(struct request_queue *q)
> {
> - unsigned long flags;
> -
> - spin_lock_irqsave(&q->queue_lock, flags);
> - if (!q->quiesce_depth++)
> - blk_queue_flag_set(QUEUE_FLAG_QUIESCED, q);
> - spin_unlock_irqrestore(&q->queue_lock, flags);
> + atomic_inc(&q->quiesce_depth);
> + /*
> + * Pairs with smp_rmb() in blk_mq_run_hw_queue(): make the
> + * incremented quiesce_depth observable to readers re-checking
> + * the quiesce state, so they don't dispatch on a quiesced queue.
> + */
> + smp_mb__after_atomic();
> }
No, this is not sufficient to guarantee that blk_mq_run_hw_queue() sees
the latest value of q->quiesce_depth. If you want to achieve that I
think the only option is to protect the atomic_inc() above with
hctx->queue->queue_lock.
> @@ -2362,17 +2365,15 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
>
> need_run = blk_mq_hw_queue_need_run(hctx);
> if (!need_run) {
> - unsigned long flags;
> -
> /*
> - * Synchronize with blk_mq_unquiesce_queue(), because we check
> - * if hw queue is quiesced locklessly above, we need the use
> - * ->queue_lock to make sure we see the up-to-date status to
> - * not miss rerunning the hw queue.
> + * Re-check the quiesce state after a read barrier. Pairs with
> + * smp_mb__after_atomic() in blk_mq_quiesce_queue_nowait() and
> + * blk_mq_unquiesce_queue() so we don't miss rerunning the hw
> + * queue when a concurrent unquiesce has just dropped the
> + * quiesce_depth to zero.
> */
> - spin_lock_irqsave(&hctx->queue->queue_lock, flags);
> + smp_rmb();
> need_run = blk_mq_hw_queue_need_run(hctx);
> - spin_unlock_irqrestore(&hctx->queue->queue_lock, flags);
If the atomic_inc() in blk_mq_quiesce_queue_nowait() is protected by
hctx->queue->queue_lock then the above code doesn't have to be modified.
Thanks,
Bart.
next prev parent reply other threads:[~2026-05-06 7:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 6:56 [PATCH v6 0/1] block/blk-mq: use atomic_t for quiesce_depth to avoid lock contention on RT Ionut Nechita (Wind River)
2026-05-06 6:56 ` [PATCH v6 1/1] " Ionut Nechita (Wind River)
2026-05-06 7:14 ` Bart Van Assche [this message]
2026-05-06 7:47 ` Sebastian Andrzej Siewior
2026-05-06 9:43 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50187fa5-03a9-4ca3-bcaf-a36ed75bda2c@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=bigeasy@linutronix.de \
--cc=chris.friesen@windriver.com \
--cc=clrkwllms@kernel.org \
--cc=ionut.nechita@windriver.com \
--cc=ionut_n2001@yahoo.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=linux-rt-users@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=mkhalfella@purestorage.com \
--cc=muchun.song@linux.dev \
--cc=rostedt@goodmis.org \
--cc=stable@vger.kernel.org \
--cc=sunlightlinux@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox