public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Eric Biggers <ebiggers3@gmail.com>
Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-kernel@vger.kernel.org, Eric Biggers <ebiggers@google.com>
Subject: Re: [PATCH] statx: optimize copy of struct statx to userspace
Date: Sat, 11 Mar 2017 19:28:20 +0000	[thread overview]
Message-ID: <9624.1489260500@warthog.procyon.org.uk> (raw)
In-Reply-To: <20170311101510.6504-1-ebiggers3@gmail.com>

Eric Biggers <ebiggers3@gmail.com> wrote:

> From: Eric Biggers <ebiggers@google.com>
> 
> I found that statx() was significantly slower than stat().  As a
> microbenchmark, I compared 10,000,000 invocations of fstat() on a tmpfs
> file to the same with statx() passed a NULL path:
> 
> 	$ time ./stat_benchmark
> 
> 	real	0m1.464s
> 	user	0m0.275s
> 	sys	0m1.187s
> 
> 	$ time ./statx_benchmark
> 
> 	real	0m5.530s
> 	user	0m0.281s
> 	sys	0m5.247s
> 
> statx is expected to be a little slower than stat because struct statx
> is larger than struct stat, but not by *that* much.  It turns out that
> most of the overhead was in copying struct statx to userspace,
> apparently mostly in all the stac/clac instructions that got generated
> for each __put_user() call.  (This was on x86_64, but some other
> architectures, e.g. arm64, have something similar now too.)
> 
> stat() instead initializes its struct on the stack and copies it to
> userspace with a single call to copy_to_user().  This turns out to be
> much faster, and changing statx to do this makes it almost as fast as
> stat:
> 
> 	$ time ./statx_benchmark
> 
> 	real	0m1.573s
> 	user	0m0.229s
> 	sys	0m1.344s
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Acked-by: David Howells <dhowells@redhat.com>

  reply	other threads:[~2017-03-11 19:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-11 10:15 [PATCH] statx: optimize copy of struct statx to userspace Eric Biggers
2017-03-11 19:28 ` David Howells [this message]
2017-03-11 21:44 ` Eric Biggers

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=9624.1489260500@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=ebiggers3@gmail.com \
    --cc=ebiggers@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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