From: David Laight <David.Laight@ACULAB.COM>
To: lkp@lists.01.org
Subject: Re: [x86] d55564cfc2: will-it-scale.per_thread_ops -5.8% regression
Date: Fri, 08 Jan 2021 09:37:45 +0000 [thread overview]
Message-ID: <824461ae2cb642b1b2f82fac140a98da@AcuMS.aculab.com> (raw)
In-Reply-To: <CAHk-=whneXU5Sr=iOOrzcqZt6q85zp-8CUSviOwGPj5ePBW4CQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1621 bytes --]
From: Linus Torvalds
> Sent: 07 January 2021 19:34
>
> On Thu, Jan 7, 2021 at 11:04 AM Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > BTW, changing 'event' field in place from another thread is going to
> > be interesting - you have two 16bit values next to each other and
> > two CPUs modifying those with no exclusion. Sounds like a recipe
> > for massive trouble...
>
> It's perfectly fine on just about anything else than on an original
> pre-ev5 alpha.
Apart from the horrid cost of the cache-line bouncing.
> The C standard even - finally - made it a requirement that accesses to
> different members can't introduce data races.
>
> So I agree with you that it's a bit annoying, and it's likely not even
> very common, but I could easily imagine myself writing code that
> changes either 'fd' or 'events' in a threaded server.
>
> That's pretty much the whole point of 'poll()' after all - threaded
> servers that have that convenient array of pollable file descriptors.
I ended up using epoll().
One server thread does the epoll() and then all the threads process
the entries using atomic_increment() on the array index.
The lack of spinlocks in userspace really kills you.
If you use a futex to control a linked list a hardware interrupt
and then all the network and rcu softint callbacks can happen
in the few locked instrcutions.
It doesn't matter that one server thread is blocked for ~1ms,
but having them all blocked is a problem.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
WARNING: multiple messages have this Message-ID (diff)
From: David Laight <David.Laight@ACULAB.COM>
To: 'Linus Torvalds' <torvalds@linux-foundation.org>,
Al Viro <viro@zeniv.linux.org.uk>
Cc: kernel test robot <oliver.sang@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
Peter Zijlstra <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
"lkp@lists.01.org" <lkp@lists.01.org>,
kernel test robot <lkp@intel.com>,
"Huang, Ying" <ying.huang@intel.com>,
Feng Tang <feng.tang@intel.com>,
"zhengjun.xing@intel.com" <zhengjun.xing@intel.com>
Subject: RE: [x86] d55564cfc2: will-it-scale.per_thread_ops -5.8% regression
Date: Fri, 8 Jan 2021 09:37:45 +0000 [thread overview]
Message-ID: <824461ae2cb642b1b2f82fac140a98da@AcuMS.aculab.com> (raw)
In-Reply-To: <CAHk-=whneXU5Sr=iOOrzcqZt6q85zp-8CUSviOwGPj5ePBW4CQ@mail.gmail.com>
From: Linus Torvalds
> Sent: 07 January 2021 19:34
>
> On Thu, Jan 7, 2021 at 11:04 AM Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > BTW, changing 'event' field in place from another thread is going to
> > be interesting - you have two 16bit values next to each other and
> > two CPUs modifying those with no exclusion. Sounds like a recipe
> > for massive trouble...
>
> It's perfectly fine on just about anything else than on an original
> pre-ev5 alpha.
Apart from the horrid cost of the cache-line bouncing.
> The C standard even - finally - made it a requirement that accesses to
> different members can't introduce data races.
>
> So I agree with you that it's a bit annoying, and it's likely not even
> very common, but I could easily imagine myself writing code that
> changes either 'fd' or 'events' in a threaded server.
>
> That's pretty much the whole point of 'poll()' after all - threaded
> servers that have that convenient array of pollable file descriptors.
I ended up using epoll().
One server thread does the epoll() and then all the threads process
the entries using atomic_increment() on the array index.
The lack of spinlocks in userspace really kills you.
If you use a futex to control a linked list a hardware interrupt
and then all the network and rcu softint callbacks can happen
in the few locked instrcutions.
It doesn't matter that one server thread is blocked for ~1ms,
but having them all blocked is a problem.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2021-01-08 9:37 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-07 13:47 [x86] d55564cfc2: will-it-scale.per_thread_ops -5.8% regression kernel test robot
2021-01-07 13:47 ` kernel test robot
2021-01-07 17:43 ` Linus Torvalds
2021-01-07 17:43 ` Linus Torvalds
2021-01-07 18:33 ` Al Viro
2021-01-07 18:33 ` Al Viro
2021-01-07 18:40 ` Al Viro
2021-01-07 18:40 ` Al Viro
2021-01-07 18:55 ` Al Viro
2021-01-07 18:55 ` Al Viro
2021-01-07 18:47 ` Linus Torvalds
2021-01-07 18:47 ` Linus Torvalds
2021-01-07 18:58 ` Al Viro
2021-01-07 18:58 ` Al Viro
2021-01-07 19:04 ` Al Viro
2021-01-07 19:04 ` Al Viro
2021-01-07 19:33 ` Linus Torvalds
2021-01-07 19:33 ` Linus Torvalds
2021-01-07 19:57 ` Al Viro
2021-01-07 19:57 ` Al Viro
2021-01-08 9:29 ` David Laight
2021-01-08 9:29 ` David Laight
2021-01-08 9:37 ` David Laight [this message]
2021-01-08 9:37 ` David Laight
2021-01-08 9:51 ` Peter Zijlstra
2021-01-08 9:51 ` Peter Zijlstra
2021-01-08 10:44 ` David Laight
2021-01-08 10:44 ` David Laight
2021-01-08 9:49 ` David Laight
2021-01-08 9:49 ` David Laight
2021-01-08 6:13 ` Oliver Sang
2021-01-08 6:13 ` Oliver Sang
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=824461ae2cb642b1b2f82fac140a98da@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=lkp@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.