linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>,
	Matthew Wilcox <willy@infradead.org>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [RFC] what to do with IOCB_DSYNC?
Date: Mon, 23 May 2022 09:44:12 -0600	[thread overview]
Message-ID: <f74235f7-8c55-8def-9a3f-bc5bacd7ee3c@kernel.dk> (raw)
In-Reply-To: <6594c360-0c7c-412f-29c9-377ddda16937@kernel.dk>

On 5/23/22 9:12 AM, Jens Axboe wrote:
>> Current branch pushed to #new.iov_iter (at the moment; will rename
>> back to work.iov_iter once it gets more or less stable).
> 
> Sounds good, I'll see what I need to rebase.

On the previous branch, ran a few quick numbers. dd from /dev/zero to
/dev/null, with /dev/zero using ->read() as it does by default:

32      260MB/sec
1k      6.6GB/sec
4k      17.9GB/sec
16k     28.8GB/sec

now comment out ->read() so it uses ->read_iter() instead:

32      259MB/sec
1k      6.6GB/sec
4k      18.0GB/sec
16k	28.6GB/sec

which are roughly identical, all things considered. Just a sanity check,
but looks good from a performance POV in this basic test.

Now let's do ->read_iter() but make iov_iter_zero() copy from the zero
page instead:

32      250MB/sec
1k      7.7GB/sec
4k      28.8GB/sec
16k	71.2GB/sec

Looks like it's a tad slower for 32-bytes, considerably better for 1k,
and massively better at page size and above. This is on an Intel 12900K,
so recent CPU. Let's try cacheline and above:

Size	Method			BW		
64	copy_from_zero()	508MB/sec
128	copy_from_zero()	1.0GB/sec
64	clear_user()		513MB/sec
128	clear_user()		1.0GB/sec

Something like the below may make sense to do, the wins at bigger sizes
is substantial and that gets me the best of both worlds. If we really
care, we could move the check earlier and not have it per-segment. I
doubt it matters in practice, though.

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index e93fcfcf2176..f4b80ef446b9 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1049,12 +1049,19 @@ static size_t pipe_zero(size_t bytes, struct iov_iter *i)
 	return bytes;
 }
 
+static unsigned long copy_from_zero(void __user *buf, size_t len)
+{
+	if (len >= 128)
+		return copy_to_user(buf, page_address(ZERO_PAGE(0)), len);
+	return clear_user(buf, len);
+}
+
 size_t iov_iter_zero(size_t bytes, struct iov_iter *i)
 {
 	if (unlikely(iov_iter_is_pipe(i)))
 		return pipe_zero(bytes, i);
 	iterate_and_advance(i, bytes, base, len, count,
-		clear_user(base, len),
+		copy_from_zero(base, len),
 		memset(base, 0, len)
 	)
 

-- 
Jens Axboe


  reply	other threads:[~2022-05-23 15:44 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-21  0:46 [RFC] what to do with IOCB_DSYNC? Al Viro
2021-06-21 13:59 ` Christoph Hellwig
2021-06-21 14:03   ` Matthew Wilcox
2021-06-21 14:09     ` Christoph Hellwig
2021-06-21 14:16       ` Matthew Wilcox
2021-06-21 14:22         ` Christoph Hellwig
2021-06-21 14:32           ` Al Viro
2021-06-21 14:35             ` Christoph Hellwig
2021-06-21 15:22               ` Jens Axboe
2022-05-21 17:48               ` Al Viro
2022-05-21 19:03                 ` Jens Axboe
2022-05-21 22:14                   ` Jens Axboe
2022-05-22  7:45                     ` Christoph Hellwig
2022-05-22 10:23                       ` Matthew Wilcox
2022-05-22 10:36                         ` Al Viro
2022-05-22 11:15                           ` Matthew Wilcox
2022-05-22 11:45                             ` Christoph Hellwig
2022-05-22 12:39                               ` Jens Axboe
2022-05-22 12:48                                 ` Al Viro
2022-05-22 13:02                                   ` Jens Axboe
2022-05-22 13:07                                     ` Al Viro
2022-05-22 13:09                                       ` Jens Axboe
2022-05-22 18:06                                         ` Jens Axboe
2022-05-22 18:25                                           ` Al Viro
2022-05-22 18:29                                             ` Jens Axboe
2022-05-22 18:39                                               ` Al Viro
2022-05-22 18:48                                                 ` Jens Axboe
2022-05-22 19:04                                                   ` Al Viro
2022-05-22 20:03                                                     ` Jens Axboe
2022-05-23  0:42                                                       ` Al Viro
2022-05-23  1:22                                                         ` Jens Axboe
2022-05-23  1:28                                                           ` Jens Axboe
2022-05-23  1:50                                                             ` Jens Axboe
2022-05-23  2:43                                                               ` Jens Axboe
2022-05-23 14:22                                                                 ` Al Viro
2022-05-23 14:34                                                                   ` Jens Axboe
2022-05-23 14:47                                                                     ` Al Viro
2022-05-23 15:12                                                                       ` Jens Axboe
2022-05-23 15:44                                                                         ` Jens Axboe [this message]
2022-05-23 15:49                                                                           ` Matthew Wilcox
2022-05-23 15:55                                                                             ` Jens Axboe
2022-05-23 16:03                                                                               ` Jens Axboe
2022-05-26 14:46                                                                                 ` Jason A. Donenfeld
2022-05-27 10:09                                                                                   ` Ingo Molnar
2022-05-27 10:15                                                                                     ` Jason A. Donenfeld
2022-05-27 14:45                                                                                       ` Samuel Neves
2022-05-27 10:25                                                                                     ` Ingo Molnar
2022-05-27 10:36                                                                                       ` Borislav Petkov
2022-05-28 20:54                                                                                         ` Sedat Dilek
2022-05-28 20:38                                                                                       ` Sedat Dilek
2022-05-28 20:39                                                                                         ` Sedat Dilek
2022-05-23 16:15                                                                         ` Al Viro
2022-05-25 14:34                                                         ` Matthew Wilcox
2022-05-26 23:19                                                     ` Al Viro
2022-05-27 14:51                                                       ` Jens Axboe
2022-05-22 12:21                             ` Al Viro
2022-05-22  7:43                 ` Christoph Hellwig
2022-05-22 12:41                   ` Al Viro
2022-05-22 12:51                     ` Christoph Hellwig
2021-06-21 14:22       ` Al Viro

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=f74235f7-8c55-8def-9a3f-bc5bacd7ee3c@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /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).