From: Jens Axboe <axboe@kernel.dk>
To: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>, linux-block@vger.kernel.org
Subject: Re: [PATCH 2/2] blk-mq: ensure a q_usage_counter reference is held when splitting bios
Date: Thu, 11 Jan 2024 13:06:43 -0700 [thread overview]
Message-ID: <1d682398-9922-404b-ac50-2fb292793ddb@kernel.dk> (raw)
In-Reply-To: <20240111172438.GA22255@lst.de>
On 1/11/24 10:24 AM, Christoph Hellwig wrote:
> On Thu, Jan 11, 2024 at 10:18:31AM -0700, Jens Axboe wrote:
>> This also highlights a potential inefficiency in the patch, as now we're
>> grabbing+dropping references when we don't need to. May not be a big
>> deal, but it's one of the things that cached requests got rid of. Though
>> I'm not quite sure how to refactor to get rid of that, as we'd need to
>> shuffle the splitting and request get for that.
>>
>> Could you take another look at the series with that in mind?
>
> I thought about it, but it gets pretty ugly quickly. bio_queue_enter
> needs to move back into blk_mq_submit_bio, and then we'd skip it
> initially if bio_may_exceed_limits is false, and then we later need
> to add it back. (we'll probably also need to special case
> blk_queue_bounce as that setting could change to. I wish we could
> finally kill that)
Something like this? Not super pretty with the duplication, but...
Should suffice for a fix, and then we can refactor it on top of that.
ioprio is inherited when cloning, so we don't need to do that post the
split.
For the bounce side, how would these settings change at runtime? Should
be set at init time and then never change. And agree would be so nice to
kill that code...
diff --git a/block/blk-mq.c b/block/blk-mq.c
index aa9a05fdd023..01134e845d8d 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2945,12 +2945,6 @@ void blk_mq_submit_bio(struct bio *bio)
blk_status_t ret;
bio = blk_queue_bounce(bio, q);
- if (bio_may_exceed_limits(bio, &q->limits)) {
- bio = __bio_split_to_limits(bio, &q->limits, &nr_segs);
- if (!bio)
- return;
- }
-
bio_set_ioprio(bio);
if (plug) {
@@ -2959,6 +2953,11 @@ void blk_mq_submit_bio(struct bio *bio)
rq = NULL;
}
if (rq) {
+ if (unlikely(bio_may_exceed_limits(bio, &q->limits))) {
+ bio = __bio_split_to_limits(bio, &q->limits, &nr_segs);
+ if (!bio)
+ return;
+ }
if (!bio_integrity_prep(bio))
return;
if (blk_mq_attempt_bio_merge(q, bio, nr_segs))
@@ -2969,6 +2968,11 @@ void blk_mq_submit_bio(struct bio *bio)
} else {
if (unlikely(bio_queue_enter(bio)))
return;
+ if (unlikely(bio_may_exceed_limits(bio, &q->limits))) {
+ bio = __bio_split_to_limits(bio, &q->limits, &nr_segs);
+ if (!bio)
+ goto fail;
+ }
if (!bio_integrity_prep(bio))
goto fail;
}
--
Jens Axboe
next prev parent reply other threads:[~2024-01-11 20:06 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-11 13:57 ensure q_usage_counter is held over bio splits Christoph Hellwig
2024-01-11 13:57 ` [PATCH 1/2] blk-mq: rename blk_mq_can_use_cached_rq Christoph Hellwig
2024-01-11 13:57 ` [PATCH 2/2] blk-mq: ensure a q_usage_counter reference is held when splitting bios Christoph Hellwig
2024-01-11 16:12 ` Jens Axboe
2024-01-11 16:14 ` Christoph Hellwig
2024-01-11 16:17 ` Jens Axboe
2024-01-11 16:18 ` Christoph Hellwig
2024-01-11 17:10 ` Christoph Hellwig
2024-01-11 17:18 ` Jens Axboe
2024-01-11 17:24 ` Christoph Hellwig
2024-01-11 20:06 ` Jens Axboe [this message]
2024-01-12 5:44 ` Christoph Hellwig
2024-01-12 14:22 ` Jens Axboe
2024-01-12 14:25 ` Christoph Hellwig
2024-01-12 16:10 ` Jens Axboe
2024-01-15 11:20 ` Ulf Hansson
2024-01-22 7:34 ` mmc vs highmem, was: " Christoph Hellwig
2024-01-22 9:26 ` Arnd Bergmann
2024-01-22 13:39 ` Christoph Hellwig
2024-01-22 14:57 ` Arnd Bergmann
2024-01-23 9:11 ` Christoph Hellwig
2024-01-24 11:59 ` Arnd Bergmann
2024-01-24 12:33 ` Linus Walleij
2024-01-24 12:54 ` Arnd Bergmann
2024-01-24 13:16 ` Linus Walleij
2024-01-24 14:14 ` Arnd Bergmann
2024-01-24 12:45 ` Arnd Bergmann
2024-01-24 13:49 ` Linus Walleij
2024-01-24 16:35 ` Arnd Bergmann
2024-01-11 22:22 ` Ming Lei
2024-01-12 5:46 ` Christoph Hellwig
2024-01-11 16:03 ` ensure q_usage_counter is held over bio splits Jens Axboe
2024-01-14 14:38 ` (subset) " Jens Axboe
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=1d682398-9922-404b-ac50-2fb292793ddb@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