From: Jens Axboe <axboe@kernel.dk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org, brauner@kernel.org,
viro@zeniv.linux.org.uk
Subject: Re: [PATCHSET v6b 0/11] Turn single segment imports into ITER_UBUF
Date: Sun, 2 Apr 2023 16:22:05 -0600 [thread overview]
Message-ID: <d2447c57-efa0-8f52-e1f5-fd32f4322823@kernel.dk> (raw)
In-Reply-To: <df0f88e5-c0af-5d50-bdd5-b273218861bf@kernel.dk>
On 3/30/23 4:18 PM, Jens Axboe wrote:
> On 3/30/23 3:53 PM, Linus Torvalds wrote:
>> On Thu, Mar 30, 2023 at 10:33 AM Jens Axboe <axboe@kernel.dk> wrote:
>>>
>>> That said, there might be things to improve here. But that's a task
>>> for another time.
>>
>> So I ended up looking at this, and funnily enough, the *compat*
>> version of the "copy iovec from user" is actually written to be a lot
>> more efficient than the "native" version.
>>
>> The reason is that the compat version has to load the data one field
>> at a time anyway to do the conversion, so it open-codes the loop. And
>> it does it all using the efficient "user_access_begin()" etc, so it
>> generates good code.
>>
>> In contrast, the native version just does a "copy_from_user()" and
>> then loops over the result to verify it. And that's actually pretty
>> horrid. Doing the open-coded loop that fetches and verifies the iov
>> entries one at a time should be much better.
>>
>> I dunno. That's my gut feel, at least. And it may explain why your
>> "readv()" benchmark has "_copy_from_user()" much higher up than the
>> "read()" case.
>>
>> Something like the attached *may* help.
>>
>> Untested - I only checked the generated assembly to see that it seems
>> to be sane, but I might have done something stupid. I basically copied
>> the compat code, fixed it up for non-compat types, and then massaged
>> it a bit more.
>
> That's a nice improvement - about 6% better for the single vec case,
> And that's the full "benchmark". Here are the numbers in usec for
> the read-zero. Lower is better, obviously.
Linus, are you going to turn this into a proper patch? This is too
good to not pursue.
--
Jens Axboe
next prev parent reply other threads:[~2023-04-02 22:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 16:46 [PATCHSET v6b 0/11] Turn single segment imports into ITER_UBUF Jens Axboe
2023-03-30 16:46 ` [PATCH 01/11] block: ensure bio_alloc_map_data() deals with ITER_UBUF correctly Jens Axboe
2023-03-30 16:46 ` [PATCH 02/11] iov_iter: add iter_iovec() helper Jens Axboe
2023-03-30 16:46 ` [PATCH 03/11] IB/hfi1: check for user backed iterator, not specific iterator type Jens Axboe
2023-03-30 16:46 ` [PATCH 04/11] IB/qib: " Jens Axboe
2023-03-30 16:46 ` [PATCH 05/11] ALSA: pcm: " Jens Axboe
2023-03-30 16:46 ` [PATCH 06/11] iov_iter: add iter_iov_addr() and iter_iov_len() helpers Jens Axboe
2023-03-30 16:46 ` [PATCH 07/11] iov_iter: remove iov_iter_iovec() Jens Axboe
2023-03-30 16:46 ` [PATCH 08/11] iov_iter: set nr_segs = 1 for ITER_UBUF Jens Axboe
2023-03-30 16:47 ` [PATCH 09/11] iov_iter: overlay struct iovec and ubuf/len Jens Axboe
2023-03-30 16:47 ` [PATCH 10/11] iov_iter: convert import_single_range() to ITER_UBUF Jens Axboe
2023-03-30 16:47 ` [PATCH 11/11] iov_iter: import single vector iovecs as ITER_UBUF Jens Axboe
2023-03-30 17:11 ` [PATCHSET v6b 0/11] Turn single segment imports into ITER_UBUF Linus Torvalds
2023-03-30 17:33 ` Jens Axboe
2023-03-30 21:53 ` Linus Torvalds
2023-03-30 22:18 ` Jens Axboe
2023-04-02 22:22 ` Jens Axboe [this message]
2023-04-02 23:37 ` Linus Torvalds
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=d2447c57-efa0-8f52-e1f5-fd32f4322823@kernel.dk \
--to=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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).