linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Ming Lei <ming.lei@redhat.com>
Cc: io-uring@vger.kernel.org, linux-block@vger.kernel.org
Subject: Re: [PATCH 1/4] bio: add allocation cache abstraction
Date: Tue, 10 Aug 2021 08:24:48 -0600	[thread overview]
Message-ID: <6c06ac42-bda4-cef6-6b8e-7c96eeeeec47@kernel.dk> (raw)
In-Reply-To: <79511eac-d5f2-2be3-f12c-7e296d9f1a76@kernel.dk>

On 8/10/21 7:53 AM, Jens Axboe wrote:
> On 8/10/21 7:15 AM, Ming Lei wrote:
>> Hi Jens,
>>
>> On Mon, Aug 09, 2021 at 03:23:58PM -0600, Jens Axboe wrote:
>>> Add a set of helpers that can encapsulate bio allocations, reusing them
>>> as needed. Caller must provide the necessary locking, if any is needed.
>>> The primary intended use case is polled IO from io_uring, which will not
>>> need any external locking.
>>>
>>> Very simple - keeps a count of bio's in the cache, and maintains a max
>>> of 512 with a slack of 64. If we get above max + slack, we drop slack
>>> number of bio's.
>>>
>>> The cache is intended to be per-task, and the user will need to supply
>>> the storage for it. As io_uring will be the only user right now, provide
>>> a hook that returns the cache there. Stub it out as NULL initially.
>>
>> Is it possible for user space to submit & poll IO from different io_uring
>> tasks?
>>
>> Then one bio may be allocated from bio cache of the submission task, and
>> freed to cache of the poll task?
> 
> Yes that is possible, and yes that would not benefit from this cache
> at all. The previous version would work just fine with that, as the
> cache is just under the ring lock and hence you can share it between
> tasks.
> 
> I wonder if the niftier solution here is to retain the cache in the
> ring still, yet have the pointer be per-task. So basically the setup
> that this version does, except we store the cache itself in the ring.
> I'll give that a whirl, should be a minor change, and it'll work per
> ring instead then like before.

That won't work, as we'd have to do a ctx lookup (which would defeat the
purpose), and we don't even have anything to key off of at that point...

The current approach seems like the only viable one, or adding a member
to kiocb so we can pass in the cache in question. The latter did work
just fine, but I really dislike the fact that it's growing the kiocb to
more than a cacheline.

-- 
Jens Axboe


  reply	other threads:[~2021-08-10 14:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09 21:23 [PATCHSET 0/4] Enable bio recycling for polled IO Jens Axboe
2021-08-09 21:23 ` [PATCH 1/4] bio: add allocation cache abstraction Jens Axboe
2021-08-10 13:15   ` Ming Lei
2021-08-10 13:53     ` Jens Axboe
2021-08-10 14:24       ` Jens Axboe [this message]
2021-08-10 14:48         ` Jens Axboe
2021-08-10 15:35           ` Jens Axboe
2021-08-10 15:54         ` Kanchan Joshi
2021-08-10 15:58           ` Jens Axboe
2021-08-09 21:23 ` [PATCH 2/4] fs: add bio alloc cache kiocb flag Jens Axboe
2021-08-09 21:24 ` [PATCH 3/4] io_uring: wire up bio allocation cache Jens Axboe
2021-08-10 12:25   ` Kanchan Joshi
2021-08-10 13:50     ` Jens Axboe
2021-08-09 21:24 ` [PATCH 4/4] block: enable use of " Jens Axboe
2021-08-10 12:39   ` Kanchan Joshi
2021-08-10 13:56     ` 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=6c06ac42-bda4-cef6-6b8e-7c96eeeeec47@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --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).