From: Christian Borntraeger <borntraeger@linux.ibm.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Ming Lei <ming.lei@redhat.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: model nowait as trylock for non-blocking queue enter
Date: Thu, 30 Jul 2026 21:37:34 +0200 [thread overview]
Message-ID: <bd8ef96d-a072-4082-81b0-a5d751e5f5d2@linux.ibm.com> (raw)
In-Reply-To: <20260730183005.444273-1-borntraeger@linux.ibm.com>
> Will this actually fix the lockdep splat for REQ_NOWAIT bios?
> Looking at the fast-path for bio submissions, bio_queue_enter() in
> block/blk.h still unconditionally passes 0 for the trylock parameter:
> block/blk.h:bio_queue_enter() {
> struct request_queue *q = bdev_get_queue(bio->bi_bdev);
> if (blk_try_enter_queue(q, false)) {
> rwsem_acquire_read(&q->io_lockdep_map, 0, 0, _RET_IP_);
> rwsem_release(&q->io_lockdep_map, _RET_IP_);
> return 0;
> }
> return __bio_queue_enter(q, bio);
> }
> Any non-blocking bio submission to an unfrozen queue (the vast majority of
> submissions) will hit this fast-path, causing lockdep to still falsely
> record a blocking dependency and potentially trigger the splat.
> Furthermore, is the updated annotation in __bio_queue_enter() ever
> reachable for a NOWAIT bio? If the queue is frozen, blk_try_enter_queue()
> fails, and the preceding loop immediately returns -EAGAIN for NOWAIT:
> if (nowait) {
> if (test_bit(GD_DEAD, &disk->state))
> goto dead;
> bio_wouldblock_error(bio);
> return -EAGAIN;
> }
> Does this make the nowait parameter in rwsem_acquire_read() here
> essentially dead code for bios?
Looks like sashiko is right on both counts. bio_queue_enter() in block/blk.h is
the only caller of __bio_queue_enter() and carries its own trylock=0 annotation
on the ▎ fast path, which is where practically every REQ_NOWAIT bio goes — so the
__bio_queue_enter() hunk alone fixes nothing for bios.
We need to annotate the fast path as well. Will do a v2.
And yes, the __bio_queue_enter() annotation is near-unreachable for a NOWAIT
bio: we only get there after the fast-path tryget already failed, and a second
failure returns -EAGAIN. It is reachable only if the queue becomes enterable
between the two attempts.
For consistency we might want to keep it?
Note the reported splat itself is on q_usage_counter(queue), via
blk_queue_enter() from dm-mpath's blk_mq_alloc_request(BLK_MQ_REQ_NOWAIT).
That path has no inline fast path so the fix should fix the report.
prev parent reply other threads:[~2026-07-30 19:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 18:30 [PATCH] block: model nowait as trylock for non-blocking queue enter Christian Borntraeger
2026-07-30 19:37 ` Christian Borntraeger [this message]
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=bd8ef96d-a072-4082-81b0-a5d751e5f5d2@linux.ibm.com \
--to=borntraeger@linux.ibm.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@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