From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, Nitesh Shetty <nitheshshetty@gmail.com>
Cc: Nitesh Shetty <nj.shetty@samsung.com>,
gost.dev@samsung.com, io-uring@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] io_uring/rsrc: send exact nr_segs for fixed buffer
Date: Thu, 17 Apr 2025 10:12:18 +0100 [thread overview]
Message-ID: <87cacc12-03d5-4d9d-a1b1-5a1da231be2d@gmail.com> (raw)
In-Reply-To: <fe9043f2-6f80-4dab-aba1-e51577ef2645@kernel.dk>
On 4/16/25 23:23, Jens Axboe wrote:
...
> Theoretically it is, but it always makes me a bit nervous as there are
> some _really_ odd iov_iter use cases out there. And passing down known
> wrong segment counts is pretty wonky.
>
>> Btw, where exactly does it stumble in there? I'd assume we don't
>
> Because segments != 1, and then that hits the slower path.
Right, but walking over entire bvec is not fast either. Sounds
like you're saying it's even more expensive and that's slightly
concerning.
>> need to do the segment correction for kbuf as the bio splitting
>> can do it (and probably does) in exactly the same way?
>
> It doesn't strictly need to, but we should handle that case too. That'd
> basically just be the loop addition I already did, something ala the
> below on top for both of them:
>
> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
> index d8fa7158e598..767ac89c8426 100644
> --- a/io_uring/rsrc.c
> +++ b/io_uring/rsrc.c
> @@ -1032,6 +1032,25 @@ static int validate_fixed_range(u64 buf_addr, size_t len,
> return 0;
> }
>
> +static int io_import_kbuf(int ddir, struct iov_iter *iter,
> + struct io_mapped_ubuf *imu, size_t len, size_t offset)
> +{
> + iov_iter_bvec(iter, ddir, iter->bvec, imu->nr_bvecs, len + offset);
> + iov_iter_advance(iter, offset);
> +
> + if (len + offset < imu->len) {
It should always be less or equal, are you trying to handle
the latter?
> + const struct bio_vec *bvec = iter->bvec;
> +
> + while (len > bvec->bv_len) {
> + len -= bvec->bv_len;
> + bvec++;
> + }
> + iter->nr_segs = bvec - iter->bvec;
> + }
> +
> + return 0;
> +}
> +
--
Pavel Begunkov
next prev parent reply other threads:[~2025-04-17 9:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250416055250epcas5p25fa8223a1bfeea5583ad8ba88c881a05@epcas5p2.samsung.com>
2025-04-16 5:44 ` [PATCH] io_uring/rsrc: send exact nr_segs for fixed buffer Nitesh Shetty
2025-04-16 14:19 ` Jens Axboe
2025-04-16 14:43 ` Jens Axboe
2025-04-16 14:49 ` Jens Axboe
2025-04-16 15:03 ` Pavel Begunkov
2025-04-16 15:07 ` Jens Axboe
2025-04-16 18:25 ` Jens Axboe
2025-04-16 19:57 ` Nitesh Shetty
2025-04-16 20:01 ` Jens Axboe
2025-04-16 20:29 ` Pavel Begunkov
2025-04-16 20:30 ` Jens Axboe
2025-04-16 21:03 ` Pavel Begunkov
2025-04-16 22:23 ` Jens Axboe
2025-04-16 22:42 ` Jens Axboe
2025-04-17 9:12 ` Pavel Begunkov [this message]
2025-04-16 20:03 ` Keith Busch
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=87cacc12-03d5-4d9d-a1b1-5a1da231be2d@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=gost.dev@samsung.com \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nitheshshetty@gmail.com \
--cc=nj.shetty@samsung.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