linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Christoph Hellwig' <hch@infradead.org>, Daniel Axtens <dja@axtens.net>
Cc: "viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] fs/select.c: batch user writes in do_sys_poll
Date: Thu, 13 Aug 2020 09:01:48 +0000	[thread overview]
Message-ID: <edb8988b36b44ef392b2948c7ee1a8e9@AcuMS.aculab.com> (raw)
In-Reply-To: <20200813073220.GB15436@infradead.org>

From: Christoph Hellwig
> Sent: 13 August 2020 08:32
> 
> On Thu, Aug 13, 2020 at 05:11:20PM +1000, Daniel Axtens wrote:
> > When returning results to userspace, do_sys_poll repeatedly calls
> > put_user() - once per fd that it's watching.
> >
> > This means that on architectures that support some form of
> > kernel-to-userspace access protection, we end up enabling and disabling
> > access once for each file descripter we're watching. This is inefficent
> > and we can improve things by batching the accesses together.
> >
> > To make sure there's not too much happening in the window when user
> > accesses are permitted, we don't walk the linked list with accesses on.
> > This leads to some slightly messy code in the loop, unfortunately.
> >
> > Unscientific benchmarking with the poll2_threads microbenchmark from
> > will-it-scale, run as `./poll2_threads -t 1 -s 15`:
> >
> >  - Bare-metal Power9 with KUAP: ~48.8% speed-up
> >  - VM on amd64 laptop with SMAP: ~25.5% speed-up
> >
> > Signed-off-by: Daniel Axtens <dja@axtens.net>
> 
> Seem like this could simply use a copy_to_user to further simplify
> things?

That would copy out 8 bytes/fd instead of 2.
So a slight change for 32bit kernels.
However the 'user copy hardening' checks that copy_to_user()
does probably make a measurable difference.

> Also please don't pointlessly add overly long lines.

Shorten the error label?

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


      parent reply	other threads:[~2020-08-13  9:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13  7:11 [PATCH] fs/select.c: batch user writes in do_sys_poll Daniel Axtens
2020-08-13  7:32 ` Christoph Hellwig
2020-08-13  8:48   ` Daniel Axtens
2020-08-13 11:36     ` Daniel Axtens
2020-08-13 12:23       ` David Laight
2020-08-13 13:00       ` Al Viro
2020-08-13  9:01   ` David Laight [this message]

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=edb8988b36b44ef392b2948c7ee1a8e9@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=dja@axtens.net \
    --cc=hch@infradead.org \
    --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;
as well as URLs for NNTP newsgroup(s).