From: Waiman Long <waiman.long@hpe.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Mike Galbraith <umgwanakikbuti@gmail.com>,
Ingo Molnar <mingo@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
<linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>,
Jason Low <jason.low2@hpe.com>,
Scott J Norton <scott.norton@hpe.com>,
Douglas Hatch <doug.hatch@hpe.com>
Subject: Re: [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes
Date: Thu, 22 Sep 2016 16:28:41 -0400 [thread overview]
Message-ID: <57E43EF9.8000400@hpe.com> (raw)
In-Reply-To: <57E43A46.9080601@hpe.com>
On 09/22/2016 04:08 PM, Waiman Long wrote:
> On 09/22/2016 11:11 AM, Davidlohr Bueso wrote:
>> On Thu, 22 Sep 2016, Thomas Gleixner wrote:
>>
>>> On Thu, 22 Sep 2016, Davidlohr Bueso wrote:
>>>> On Thu, 22 Sep 2016, Thomas Gleixner wrote:
>>>> > Also what's the reason that we can't do probabilistic spinning for
>>>> > FUTEX_WAIT and have to add yet another specialized variant of
>>>> futexes?
>>>>
>>>> Where would this leave the respective FUTEX_WAKE? A nop? Probably
>>>> have to
>>>> differentiate the fact that the queue was empty, but there was a
>>>> spinning,
>>>> instead of straightforward returning 0.
>>>
>>> Sorry, but I really can't parse this answer.
>>>
>>> Can you folks please communicate with proper and coherent explanations
>>> instead of throwing a few gnawed off bones in my direction?
>>
>> I actually think that FUTEX_WAIT is the better/nicer approach. But my
>> immediate
>> question above was how to handle the FUTEX_WAKE counter-part. If we
>> want to
>> maintain current FIFO ordering for wakeups, now with WAIT spinners
>> this will
>> create lock stealing scenarios (including if we even guard against
>> starvation).
>> Or we could reduce the scope of spinners, due to the restrictions,
>> similar to
>> the top-waiter only being able to spin for rtmutexes. This of course
>> will hurt
>> the effectiveness of spinning in FUTEX_WAIT in the first place.
>
> Actually, there can be a lot of lock stealing going on with the
> wait-wake futexes. If the critical section is short enough, many of
> the lock waiters can be waiting in the hash bucket spinlock queue and
> not sleeping yet while the futex value changes. As a result, they will
> exit the futex syscall and back to user space with EAGAIN where one of
> them may get the lock. So we can't assume that they will get the lock
> in the FIFO order anyway.
BTW, my initial attempt for the new futex was to use the same workflow
as the PI futexes, but use mutex which has optimistic spinning instead
of rt_mutex. That version can double the throughput compared with PI
futexes but still far short of what can be achieved with wait-wake
futex. Looking at the performance figures from the patch:
wait-wake futex PI futex TO futex
--------------- -------- --------
max time 3.49s 50.91s 2.65s
min time 3.24s 50.84s 0.07s
average time 3.41s 50.90s 1.84s
sys time 7m22.4s 55.73s 2m32.9s
lock count 3,090,294 9,999,813 698,318
unlock count 3,268,896 9,999,814 134
The problem with a PI futexes like version is that almost all the
lock/unlock operations were done in the kernel which added overhead and
latency. Now looking at the numbers for the TO futexes, less than 1/10
of the lock operations were done in the kernel, the number of unlock was
insignificant. Locking was done mostly by lock stealing. This is where
most of the performance benefit comes from, not optimistic spinning.
This is also the reason that a lock handoff mechanism is implemented to
prevent lock starvation which is likely to happen without one.
Cheers,
Longman
next prev parent reply other threads:[~2016-09-22 20:28 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-20 13:42 [RFC PATCH v2 0/5] futex: Introducing throughput-optimized futexes Waiman Long
2016-09-20 13:42 ` [RFC PATCH v2 1/5] futex: Add futex_set_timer() helper function Waiman Long
2016-09-22 21:31 ` Thomas Gleixner
2016-09-23 0:45 ` Waiman Long
2016-09-20 13:42 ` [RFC PATCH v2 2/5] futex: Rename futex_pi_state to futex_state Waiman Long
2016-09-20 13:42 ` [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes Waiman Long
2016-09-21 6:59 ` Mike Galbraith
2016-09-21 23:37 ` Waiman Long
2016-09-22 7:49 ` Peter Zijlstra
2016-09-22 13:04 ` Waiman Long
2016-09-22 13:34 ` Thomas Gleixner
2016-09-22 14:41 ` Davidlohr Bueso
2016-09-22 14:46 ` Thomas Gleixner
2016-09-22 15:11 ` Davidlohr Bueso
2016-09-22 20:08 ` Waiman Long
2016-09-22 20:28 ` Waiman Long [this message]
2016-09-22 20:38 ` Thomas Gleixner
2016-09-22 21:48 ` Waiman Long
2016-09-23 13:02 ` Thomas Gleixner
2016-09-26 22:02 ` Waiman Long
2016-09-22 21:39 ` Davidlohr Bueso
2016-09-22 21:41 ` Thomas Gleixner
2016-09-22 21:59 ` Waiman Long
2016-09-27 19:02 ` [PATCH v2 -tip] locking/rtmutex: Reduce top-waiter blocking on a lock Davidlohr Bueso
2016-10-24 18:08 ` Davidlohr Bueso
2016-10-24 18:48 ` Thomas Gleixner
2016-09-24 1:28 ` [PATCH " Davidlohr Bueso
2016-09-26 21:40 ` Waiman Long
2016-09-22 19:56 ` [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes Waiman Long
2016-09-22 20:26 ` Thomas Gleixner
2016-09-22 21:13 ` Waiman Long
2016-09-22 13:23 ` Peter Zijlstra
2016-09-22 17:21 ` Waiman Long
2016-09-20 13:42 ` [RFC PATCH v2 4/5] futex: Add timeout support to TO futexes Waiman Long
2016-09-20 13:42 ` [RFC PATCH v2 5/5] futex, doc: TO futexes document Waiman Long
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=57E43EF9.8000400@hpe.com \
--to=waiman.long@hpe.com \
--cc=corbet@lwn.net \
--cc=dave@stgolabs.net \
--cc=doug.hatch@hpe.com \
--cc=jason.low2@hpe.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=scott.norton@hpe.com \
--cc=tglx@linutronix.de \
--cc=umgwanakikbuti@gmail.com \
/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.