From: Keith Busch <[email protected]>
To: Jens Axboe <[email protected]>
Cc: [email protected], [email protected], [email protected]
Subject: Re: [PATCH 4/6] block: clear BIO_PERCPU_CACHE flag if polling isn't supported
Date: Fri, 13 Aug 2021 13:31:38 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On Fri, Aug 13, 2021 at 02:19:11PM -0600, Jens Axboe wrote:
> On 8/13/21 2:17 PM, Keith Busch wrote:
> > On Thu, Aug 12, 2021 at 11:41:58AM -0600, Jens Axboe wrote:
> >> Indeed. Wonder if we should make that a small helper, as any clear of
> >> REQ_HIPRI should clear BIO_PERCPU_CACHE as well.
> >>
> >>
> >> diff --git a/block/blk-core.c b/block/blk-core.c
> >> index 7e852242f4cc..d2722ecd4d9b 100644
> >> --- a/block/blk-core.c
> >> +++ b/block/blk-core.c
> >> @@ -821,11 +821,8 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)
> >> }
> >> }
> >>
> >> - if (!test_bit(QUEUE_FLAG_POLL, &q->queue_flags)) {
> >> - /* can't support alloc cache if we turn off polling */
> >> - bio_clear_flag(bio, BIO_PERCPU_CACHE);
> >> - bio->bi_opf &= ~REQ_HIPRI;
> >> - }
> >> + if (!test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
> >> + bio_clear_hipri(bio);
> >
> > Since BIO_PERCPU_CACHE doesn't work without REQ_HIRPI, should this check
> > look more like this?
> >
> > if (!test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
> > bio->bi_opf &= ~REQ_HIPRI;
> > if (!(bio->bi_opf & REQ_HIPRI))
> > bio_clear_flag(bio, BIO_PERCPU_CACHE);
> >
> > I realise the only BIO_PERCPU_CACHE user in this series never sets it
> > without REQ_HIPRI, but it looks like a problem waiting to happen if
> > nothing enforces this pairing: someone could set the CACHE flag on a
> > QUEUE_FLAG_POLL enabled queue without setting HIPRI and get the wrong
> > bio_put() action.
>
> I'd rather turn that into a WARN_ON or similar. But probably better to
> do that on the freeing side, honestly. That'll be the most reliable way,
> but a shame to add cycles to the hot path...
Yeah, it is a coding error if that happened, so a WARN sounds okay. I
also don't like adding these kinds of checks, so please feel free to not
include it if you think the usage is clear enough.
next prev parent reply other threads:[~2021-08-13 20:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-12 15:41 [PATCHSET v5 0/6] Enable bio recycling for polled IO Jens Axboe
2021-08-12 15:41 ` [PATCH 1/6] bio: optimize initialization of a bio Jens Axboe
2021-08-12 16:16 ` Christoph Hellwig
2021-08-12 15:41 ` [PATCH 2/6] fs: add kiocb alloc cache flag Jens Axboe
2021-08-12 16:20 ` Christoph Hellwig
2021-08-12 15:41 ` [PATCH 3/6] bio: add allocation cache abstraction Jens Axboe
2021-08-12 16:32 ` Christoph Hellwig
2021-08-12 16:39 ` Jens Axboe
2021-08-12 15:41 ` [PATCH 4/6] block: clear BIO_PERCPU_CACHE flag if polling isn't supported Jens Axboe
2021-08-12 16:33 ` Christoph Hellwig
2021-08-12 17:31 ` Keith Busch
2021-08-12 17:41 ` Jens Axboe
2021-08-13 20:17 ` Keith Busch
2021-08-13 20:19 ` Jens Axboe
2021-08-13 20:31 ` Keith Busch [this message]
2021-08-13 20:33 ` Jens Axboe
2021-08-12 15:41 ` [PATCH 5/6] io_uring: enable use of bio alloc cache Jens Axboe
2021-08-12 16:39 ` Christoph Hellwig
2021-08-12 16:46 ` Jens Axboe
2021-08-12 15:41 ` [PATCH 6/6] block: use the percpu bio cache in __blkdev_direct_IO Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2021-08-11 19:35 [PATCHSET v4 0/6] Enable bio recycling for polled IO Jens Axboe
2021-08-11 19:35 ` [PATCH 4/6] block: clear BIO_PERCPU_CACHE flag if polling isn't supported 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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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