From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org, Pavel Begunkov <asml.silence@gmail.com>,
linux-block@vger.kernel.org,
Uday Shankar <ushankar@purestorage.com>,
Akilesh Kailash <akailash@google.com>
Subject: Re: [PATCH V9 4/7] io_uring: reuse io_mapped_buf for kernel buffer
Date: Thu, 7 Nov 2024 09:22:53 +0800 [thread overview]
Message-ID: <ZywWbb_RmuA9hp3Z@fedora> (raw)
In-Reply-To: <e27c7b11-4fa0-4c51-a596-67c0773a657a@kernel.dk>
On Wed, Nov 06, 2024 at 08:15:13AM -0700, Jens Axboe wrote:
> On 11/6/24 5:26 AM, Ming Lei wrote:
> > Prepare for supporting kernel buffer in case of io group, in which group
> > leader leases kernel buffer to io_uring, and consumed by io_uring OPs.
> >
> > So reuse io_mapped_buf for group kernel buffer, and unfortunately
> > io_import_fixed() can't be reused since userspace fixed buffer is
> > virt-contiguous, but it isn't true for kernel buffer.
> >
> > Also kernel buffer lifetime is bound with group leader request, it isn't
> > necessary to use rsrc_node for tracking its lifetime, especially it needs
> > extra allocation of rsrc_node for each IO.
>
> While it isn't strictly necessary, I do think it'd clean up the io_kiocb
> parts and hopefully unify the assign and put path more. So I'd strongly
> suggest you do use an io_rsrc_node, even if it does just map the
> io_mapped_buf for this.
Can you share your idea about how to unify buffer? I am also interested
in this area, so I may take it into account in this patch.
Will you plan to use io_rsrc_node for all buffer type(include buffer
select)?
>
> > +struct io_mapped_buf {
> > + u64 start;
> > + unsigned int len;
> > + unsigned int nr_bvecs;
> > +
> > + /* kbuf hasn't refs and accounting, its lifetime is bound with req */
> > + union {
> > + struct {
> > + refcount_t refs;
> > + unsigned int acct_pages;
> > + };
> > + /* pbvec is only for kbuf */
> > + const struct bio_vec *pbvec;
> > + };
> > + unsigned int folio_shift:6;
> > + unsigned int dir:1; /* ITER_DEST or ITER_SOURCE */
> > + unsigned int kbuf:1; /* kernel buffer or not */
> > + /* offset in the 1st bvec, for kbuf only */
> > + unsigned int offset;
> > + struct bio_vec bvec[] __counted_by(nr_bvecs);
> > +};
>
> And then I'd get rid of this union, and have it follow the normal rules
> for an io_mapped_buf in that the refs are valid. Yes it'll take 8b more,
> but honestly I think unifying these bits and keeping it consistent is a
> LOT more important than saving a bit of space.
>
> This is imho the last piece missing to make this conform more nicely
> with how resource nodes are generally handled and used.
OK.
thanks,
Ming
next prev parent reply other threads:[~2024-11-07 1:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 12:26 [PATCH V9 0/7] io_uring: support group buffer & ublk zc Ming Lei
2024-11-06 12:26 ` [PATCH V9 1/7] io_uring: rename io_mapped_ubuf as io_mapped_buf Ming Lei
2024-11-06 12:26 ` [PATCH V9 2/7] io_uring: rename ubuf of io_mapped_buf as start Ming Lei
2024-11-06 15:07 ` Jens Axboe
2024-11-06 12:26 ` [PATCH V9 3/7] io_uring: shrink io_mapped_buf Ming Lei
2024-11-06 15:09 ` Jens Axboe
2024-11-07 1:04 ` Ming Lei
2024-11-07 2:13 ` Jens Axboe
2024-11-06 12:26 ` [PATCH V9 4/7] io_uring: reuse io_mapped_buf for kernel buffer Ming Lei
2024-11-06 15:15 ` Jens Axboe
2024-11-07 1:22 ` Ming Lei [this message]
2024-11-07 2:16 ` Jens Axboe
2024-11-06 12:26 ` [PATCH V9 5/7] io_uring: support leased group buffer with REQ_F_GROUP_BUF Ming Lei
2024-11-06 15:17 ` Jens Axboe
2024-11-06 12:26 ` [PATCH V9 6/7] io_uring/uring_cmd: support leasing device kernel buffer to io_uring Ming Lei
2024-11-06 12:26 ` [PATCH V9 7/7] ublk: support leasing io " Ming Lei
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=ZywWbb_RmuA9hp3Z@fedora \
--to=ming.lei@redhat.com \
--cc=akailash@google.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=ushankar@purestorage.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.