All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Yu Kuai <yukuai1@huaweicloud.com>, Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH 2/8] block: Do not run frozen queues
Date: Thu, 3 Jul 2025 09:51:27 +0800	[thread overview]
Message-ID: <aGXiH1HqSlLk-QSI@fedora> (raw)
In-Reply-To: <93500d50-ba11-425b-8d5f-1ce1930e4160@acm.org>

On Wed, Jul 02, 2025 at 06:30:34PM -0700, Bart Van Assche wrote:
> On 7/2/25 6:15 PM, Yu Kuai wrote:
> > Just a question, blk_mq_quiesce_queue also calls synchronize_rcu() to
> > wait for inflight dispatch work to be done, is it safe in following
> > patches? I think it's not, dispatch work can be running while there is
> > no request pending, menas queue can be frozen with active dispatch work.
> 
> No work is dispatched if a queue is frozen because freezing a queue only
> finishes after q_usage_counter drops to zero. queue_rq() and queue_rqs()
> are only called if one or more requests are being executed.
> q_usage_counter is increased when a request is allocated and decreased
> when a request is freed. Hence, q_usage_counter cannot be zero while
> queue_rq() or queue_rqs() is in progress. Hence, neither queue_rq() nor
> queue_rqs() are called while q_usage_counter is zero.

It isn't related with queue_rq() or queue_rqs() only.

The dispatch work is still in-progress when all requests are
completed(.q_usage_counter becomes zero), because request can complete any
time, even before queue_rq()/queue_rqs() returns.

The dispatch critical area is much _longer_ than queue_rq()/queue_rqs(),
block layer data structure may still be accessed after .q_usage_counter drops
to zero.

Please run 'git grep', and we did fix such kind of issues several times, such as:

662156641bc4 ("block: don't drain in-progress dispatch in blk_cleanup_queue()")


Thanks,
Ming


  reply	other threads:[~2025-07-03  1:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-02 20:38 [PATCH 0/8] Simplify the code modifying queue attributes Bart Van Assche
2025-07-02 20:38 ` [PATCH 1/8] block: Introduce QUEUE_FLAG_FROZEN Bart Van Assche
2025-07-02 20:38 ` [PATCH 2/8] block: Do not run frozen queues Bart Van Assche
2025-07-03  1:15   ` Yu Kuai
2025-07-03  1:30     ` Bart Van Assche
2025-07-03  1:51       ` Ming Lei [this message]
2025-07-03  2:19         ` Yu Kuai
2025-07-07 18:22         ` Bart Van Assche
2025-07-08  0:50           ` Ming Lei
2025-07-02 20:38 ` [PATCH 3/8] block: Remove the quiesce/unquiesce calls on " Bart Van Assche
2025-07-02 20:38 ` [PATCH 4/8] aoe: " Bart Van Assche
2025-07-02 20:38 ` [PATCH 5/8] ataflop: " Bart Van Assche
2025-07-02 20:38 ` [PATCH 6/8] sunvdc: " Bart Van Assche
2025-07-02 20:38 ` [PATCH 7/8] swim3: " Bart Van Assche
2025-07-04  2:01   ` Damien Le Moal
2025-07-02 20:38 ` [PATCH 8/8] mtd_blkdevs: " Bart Van Assche
2025-07-28 10:14   ` Miquel Raynal

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=aGXiH1HqSlLk-QSI@fedora \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=yukuai1@huaweicloud.com \
    --cc=yukuai3@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.