From: Jens Axboe <axboe@kernel.dk>
To: Ming Lei <ming.lei@redhat.com>, linux-block@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] block: model freeze & enter queue as rwsem for supporting lockdep
Date: Sat, 19 Oct 2024 16:46:13 -0600 [thread overview]
Message-ID: <4f4cdf6a-e1d3-4e0c-bb57-9cbe767ac112@kernel.dk> (raw)
In-Reply-To: <20241018013542.3013963-1-ming.lei@redhat.com>
On 10/17/24 7:35 PM, Ming Lei wrote:
> Recently we got several deadlock report[1][2][3] caused by blk_mq_freeze_queue
> and blk_enter_queue().
>
> Turns out the two are just like one rwsem, so model them as rwsem for
> supporting lockdep:
>
> 1) model blk_mq_freeze_queue() as down_write_trylock()
> - it is exclusive lock, so dependency with blk_enter_queue() is covered
> - it is trylock because blk_mq_freeze_queue() are allowed to run concurrently
>
> 2) model blk_enter_queue() as down_read()
> - it is shared lock, so concurrent blk_enter_queue() are allowed
> - it is read lock, so dependency with blk_mq_freeze_queue() is modeled
> - blk_queue_exit() is often called from other contexts(such as irq), and
> it can't be annotated as rwsem_release(), so simply do it in
> blk_enter_queue(), this way still covered cases as many as possible
>
> NVMe is the only subsystem which may call blk_mq_freeze_queue() and
> blk_mq_unfreeze_queue() from different context, so it is the only
> exception for the modeling. Add one tagset flag to exclude it from
> the lockdep support.
>
> With lockdep support, such kind of reports may be reported asap and
> needn't wait until the real deadlock is triggered.
I think this is a great idea. We've had way too many issues in this
area, getting lockdep to grok it (and report issues) is the ideal way to
avoid that, and even find issues we haven't come across yet.
--
Jens Axboe
next prev parent reply other threads:[~2024-10-19 22:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 1:35 [PATCH] block: model freeze & enter queue as rwsem for supporting lockdep Ming Lei
2024-10-18 16:57 ` Bart Van Assche
2024-10-21 2:20 ` Ming Lei
2024-10-22 6:26 ` Christoph Hellwig
2024-10-18 18:45 ` kernel test robot
2024-10-19 22:46 ` Jens Axboe [this message]
2024-10-21 11:17 ` Ming Lei
2024-10-22 6:18 ` Christoph Hellwig
2024-10-22 7:19 ` Peter Zijlstra
2024-10-22 7:21 ` Christoph Hellwig
2024-10-23 3:22 ` Ming Lei
2024-10-23 6:07 ` Christoph Hellwig
2024-10-22 15:05 ` Bart Van Assche
2024-10-23 7:59 ` Ming Lei
2024-10-23 18:05 ` 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=4f4cdf6a-e1d3-4e0c-bb57-9cbe767ac112@kernel.dk \
--to=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.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;
as well as URLs for NNTP newsgroup(s).