[RFC PATCH-tip/locking/core v3 08/10] locking/rwsem: Enable spinning readers

2016-06-17 Thread Waiman Long
patch BW after patch % change --- -- randrw1352 MB/s 2164 MB/s +60% randwrite 1710 MB/s 2550 MB/s +49% Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- kernel/locking/rwsem-xadd.c

[RFC PATCH-tip/locking/core v3 07/10] locking/rwsem: Change RWSEM_WAITING_BIAS for better disambiguation

2016-06-17 Thread Waiman Long
+ RWSEM_ACTIVE_READ_BIAS Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- arch/alpha/include/asm/rwsem.h|3 ++- arch/ia64/include/asm/rwsem.h |2 +- arch/s390/include/asm/rwsem.h |2 +- arch/x86/include/asm/rwsem.h |3 ++- include/asm-generic/rwsem.h |4 ++-- i

[RFC PATCH-tip/locking/core v3 05/10] locking/rwsem: move down rwsem_down_read_failed function

2016-06-17 Thread Waiman Long
Move the rwsem_down_read_failed() function down to below the optimistic spinning section before enabling optimistic spinning for the readers. It is because the rwsem_down_read_failed() function will call rwsem_optimistic_spin() in later patch. There is no change in code. Signed-off-by: Waiman

[RFC PATCH-tip/locking/core v3 03/10] locking/rwsem: Make rwsem_spin_on_owner() return a tri-state value

2016-06-17 Thread Waiman Long
This patch modifies rwsem_spin_on_owner() to return a tri-state value to better reflect the state of lock holder which enables us to make a better decision of what to do next. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- kernel/locking/rwsem-xadd.c | 14 +- 1 files c

[RFC PATCH-tip/locking/core v3 04/10] locking/rwsem: Enable count-based spinning on reader

2016-06-17 Thread Waiman Long
. Both the spinning threshold and the default value for rspin_enabled can be overridden by architecture specific rwsem.h header file. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- include/linux/rwsem.h | 19 +++- kernel/locking/rwsem-xadd.c

[RFC PATCH-tip/locking/core v3 01/10] locking/osq: Make lock/unlock proper acquire/release barrier

2016-06-17 Thread Waiman Long
purpose than is actually needed. Suggested-by: Peter Zijlstra (Intel) <pet...@infradead.org> Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- kernel/locking/osq_lock.c |7 ++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/kernel/locking/osq_lock.c b/ke

[RFC PATCH-tip/locking/core v3 02/10] locking/rwsem: Stop active read lock ASAP

2016-06-17 Thread Waiman Long
--- -- randrw1210 MB/s 1352 MB/s +12% randwrite 1622 MB/s 1710 MB/s +5.4% The write-only microbench also showed improvement because some read locking was done by the XFS code. Signed-off-by: Waiman Long <waiman.l...@hpe.com> ---

[RFC PATCH-tip/locking/core v3 06/10] locking/rwsem: Move common rwsem macros to asm-generic/rwsem_types.h

2016-06-17 Thread Waiman Long
ed-off-by: Waiman Long <waiman.l...@hpe.com> --- arch/alpha/include/asm/rwsem.h|8 +--- arch/ia64/include/asm/rwsem.h |7 ++- arch/s390/include/asm/rwsem.h |7 +-- arch/x86/include/asm/rwsem.h | 19 +-- include/asm-generic/rwsem.h

[RFC PATCH-tip/locking/core v3 10/10] locking/rwsem: Add a boot parameter to reader spinning threshold

2016-06-17 Thread Waiman Long
of different systems as well as for testing purposes. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- Documentation/kernel-parameters.txt |3 +++ kernel/locking/rwsem-xadd.c | 14 +- 2 files changed, 16 insertions(+), 1 deletions(-) diff --git a/Documen

[PATCH-tip v5 14/21] TP-futex, doc: Add TP futexes documentation

2017-02-03 Thread Waiman Long
This patch adds a new document file on how to use the TP futexes. Signed-off-by: Waiman Long <long...@redhat.com> --- Documentation/00-INDEX | 2 + Documentation/tp-futex.txt | 161 + 2 files changed, 163 insertions(+) create mode

[PATCH-tip v5 12/21] TP-futex: Return status code on FUTEX_LOCK calls

2017-02-03 Thread Waiman Long
the lock is acquired. 2) Bits 08-15: reserved 3) Bits 16-30: how many time the task sleeps in the optimistic spinning loop. By returning the TP status code, an external monitoring or tracking program can have a macro view of how the TP futexes are performing. Signed-off-by: Waiman Long <l

[PATCH-tip v5 08/21] futex: Allow direct attachment of futex_state objects to hash bucket

2017-02-03 Thread Waiman Long
o link the futex state objects as well as a new spinlock to manage them are added to the hash bucket. To limit size increase for UP systems, these new fields are only for SMP machines where the cacheline alignment of the hash bucket leaves it with enough empty space for the new fields. Signed-off-by: Waima

[PATCH-tip v5 07/21] futex: Add a new futex type field into futex_state

2017-02-03 Thread Waiman Long
As the futex_state structure will be overloaded in later patches to be used by non-PI futexes, it is necessary to add a type field to distinguish among different types of futexes. Signed-off-by: Waiman Long <long...@redhat.com> --- kernel/futex.c | 15 +++ 1 file chang

[PATCH-tip v5 13/21] TP-futex: Add timeout support

2017-02-03 Thread Waiman Long
in the serialization mutex. Signed-off-by: Waiman Long <long...@redhat.com> --- kernel/futex.c | 50 ++ 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index 22f7906..91b2e02 100644 --- a/kernel/f

[PATCH-tip v5 04/21] futex: Rename futex_pi_state to futex_state

2017-02-03 Thread Waiman Long
states are also renamed. Signed-off-by: Waiman Long <long...@redhat.com> --- include/linux/sched.h | 4 +- kernel/futex.c| 107 +- 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/include/linux/sched.h b/include/linux/s

[PATCH-tip v5 00/21] futex: Introducing throughput-optimized (TP) futexes

2017-02-03 Thread Waiman Long
erformance characteristics of the TP futexes when implementing userspace mutex and rwlock respectively when compared with other possible way of doing so via the wait-wake futexes. Waiman Long (21): perf bench: New microbenchmark for userspace mutex performance perf bench: New microbenchmark for

[PATCH-tip v5 09/21] futex: Introduce throughput-optimized (TP) futexes

2017-02-03 Thread Waiman Long
% 40 15,383,536 27,687,160 +80% 50 13,290,368 23,096,937 +74% 1008,577,763 14,410,909 +68% 1us sleep 176,450 179,660 +2% Signed-off-by: Waiman Long <long...@redhat.com> --- include/uapi/linux/f

[PATCH-tip v5 10/21] TP-futex: Enable robust handling

2017-02-03 Thread Waiman Long
-by: Waiman Long <long...@redhat.com> --- kernel/futex.c | 85 +- 1 file changed, 79 insertions(+), 6 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index 6a59e6d..46a1a4b 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -

[PATCH-tip v5 19/21] perf bench: Extend mutex/rwlock futex suite to test TP futexes

2017-02-03 Thread Waiman Long
This patch extends the futex-mutex and futex-rwlock microbenchmarks to test userspace mutexes and rwlocks built on top of the TP futexes. We can then compare the relative performance of those userspace locks based on different type of futexes. Signed-off-by: Waiman Long <long...@redhat.

[PATCH-tip v5 20/21] sched, TP-futex: Make wake_up_q() return wakeup count

2017-02-03 Thread Waiman Long
Unlike wake_up_process(), wake_up_q() doesn't tell us how many tasks have been woken up. This information can sometimes be useful for tracking purpose. So wake_up_q() is now modified to return that information. Signed-off-by: Waiman Long <long...@redhat.com> --- include/linux/sched/wake_q

Re: [PATCH-tip v5 17/21] TP-futex: Group readers together in wait queue

2017-02-03 Thread Waiman Long
On 02/03/2017 01:23 PM, valdis.kletni...@vt.edu wrote: > On Fri, 03 Feb 2017 13:03:50 -0500, Waiman Long said: > >> On a 2-socket 36-core E5-2699 v3 system (HT off) running on a 4.10 >> WW futex TP f

[PATCH-tip v5 17/21] TP-futex: Group readers together in wait queue

2017-02-03 Thread Waiman Long
. Lock starvation should not happen on the TP futexes as long as the underlying kernel mutex is lock starvation free which is the case for 4.10 and later kernel. Signed-off-by: Waiman Long <long...@redhat.com> --- kernel/futex.c | 136 ++

[PATCH-tip v5 21/21] futex: Dump internal futex state via debugfs

2017-02-03 Thread Waiman Long
For debugging purpose, it is sometimes useful to dump the internal states in the futex hash bucket table. This patch adds a file "futex_hash_table" in debugfs root filesystem to dump the internal futex states. Signed-off-by: Waiman Long <long...@redhat.com> --- ker

[PATCH-tip v5 18/21] TP-futex, doc: Update TP futexes document on shared locking

2017-02-03 Thread Waiman Long
The tp-futex.txt was updated to add description about shared locking support. Signed-off-by: Waiman Long <long...@redhat.com> --- Documentation/tp-futex.txt | 163 +++-- 1 file changed, 143 insertions(+), 20 deletions(-) diff --git a/Documentat

[PATCH-tip v5 15/21] TP-futex: Support userspace reader/writer locks

2017-02-03 Thread Waiman Long
write lock/unlock code. This is by design to minimize any additional overhead for mutex lock and unlock. As a result, the TP futex rwlock prefers writers a bit more than readers. Signed-off-by: Waiman Long <long...@redhat.com> --- include/uapi/linux/futex.h | 28 +- ker

[PATCH-tip v5 16/21] TP-futex: Enable kernel reader lock stealing

2017-02-03 Thread Waiman Long
mechanism hasn't been enabled yet. A new field locksteal_disabled is added to the futex state object for controlling reader lock stealing. So the waiting reader must retrieve the futex state object first before doing it. Signed-off-by: Waiman Long <long...@redhat.com> --- kernel/futex.

[PATCH-tip v5 01/21] perf bench: New microbenchmark for userspace mutex performance

2017-02-03 Thread Waiman Long
% Exclusive unlock futex calls = 8.9% EAGAIN lock errors = 99.4% Process wakeups = 0.8% Per-thread Locking Rates: Avg = 126,202 ops/sec (+- 0.21%) Min = 120,114 ops/sec Max = 131,375 ops/sec Signed-off-by: Waiman Long <long...@redhat.com> --- tools/perf/Documen

[PATCH-tip v5 05/21] futex: Add helpers to get & cmpxchg futex value without lock

2017-02-03 Thread Waiman Long
Two new helper functions cmpxchg_futex_value() and get_futex_value() are added to access and change the futex value without the hash bucket lock. As a result, page fault is enabled and the page will be faulted in if not present yet. Signed-off-by: Waiman Long <long...@redhat.com> ---

[PATCH-tip v5 02/21] perf bench: New microbenchmark for userspace rwlock performance

2017-02-03 Thread Waiman Long
= 0.2% Per-thread Locking Rates: Avg = 75,392 ops/sec (+- 0.30%) Min = 71,259 ops/sec Max = 78,211 ops/sec Signed-off-by: Waiman Long <long...@redhat.com> --- tools/perf/Documentation/perf-bench.txt | 3 + tools/perf/bench/bench.h| 1 + tools/perf

[PATCH-tip v5 06/21] futex: Consolidate pure pi_state_list add & delete codes to helpers

2017-02-03 Thread Waiman Long
Two new helper functions (task_pi_list_add & task_pi_list_del) are created to consolidate all the pure pi_state_list addition and insertion codes. The set_owner argument in task_pi_list_add() will be needed in a later patch. Signed-off-by: Waiman Long <long...@redhat.com> --- kernel/fu

[PATCH-tip v5 11/21] TP-futex: Implement lock handoff to prevent lock starvation

2017-02-03 Thread Waiman Long
-by: Waiman Long <long...@redhat.com> --- kernel/futex.c | 59 -- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index 46a1a4b..348b44c 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -63,6

[RFC PATCH-tip v4 04/10] locking/rwsem: Enable count-based spinning on reader

2016-08-18 Thread Waiman Long
. Both the spinning threshold and the default value for rspin_enabled can be overridden by architecture specific rwsem.h header file. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- include/linux/rwsem.h | 19 +++- kernel/locking/rwsem-xadd.c

[RFC PATCH-tip v4 03/10] locking/rwsem: Make rwsem_spin_on_owner() return a tri-state value

2016-08-18 Thread Waiman Long
This patch modifies rwsem_spin_on_owner() to return a tri-state value to better reflect the state of lock holder which enables us to make a better decision of what to do next. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- kernel/locking/rwsem-xadd.c | 14 +- 1 files c

[RFC PATCH-tip v4 05/10] locking/rwsem: move down rwsem_down_read_failed function

2016-08-18 Thread Waiman Long
Move the rwsem_down_read_failed() function down to below the optimistic spinning section before enabling optimistic spinning for the readers. It is because the rwsem_down_read_failed() function will call rwsem_optimistic_spin() in later patch. There is no change in code. Signed-off-by: Waiman

[RFC PATCH-tip v4 08/10] locking/rwsem: Enable spinning readers

2016-08-19 Thread Waiman Long
patch BW after patch % change --- -- randrw1352 MB/s 2164 MB/s +60% randwrite 1710 MB/s 2550 MB/s +49% Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- kernel/locking/rwsem-xadd.c

[RFC PATCH-tip v4 10/10] locking/rwsem: Add a boot parameter to reader spinning threshold

2016-08-19 Thread Waiman Long
of different systems as well as for testing purposes. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- Documentation/kernel-parameters.txt |3 +++ kernel/locking/rwsem-xadd.c | 14 +- 2 files changed, 16 insertions(+), 1 deletions(-) diff --git a/Documen

[RFC PATCH-tip v4 00/10] locking/rwsem: Enable reader optimistic spinning

2016-08-18 Thread Waiman Long
new boot parameter to change the reader spinning threshold which can be system specific. Waiman Long (10): locking/osq: Make lock/unlock proper acquire/release barrier locking/rwsem: Stop active read lock ASAP locking/rwsem: Make rwsem_spin_on_owner() return a tri-state value locking/rwse

[RFC PATCH-tip v4 06/10] locking/rwsem: Move common rwsem macros to asm-generic/rwsem_types.h

2016-08-18 Thread Waiman Long
ed-off-by: Waiman Long <waiman.l...@hpe.com> --- arch/alpha/include/asm/rwsem.h|8 +--- arch/ia64/include/asm/rwsem.h |7 ++- arch/s390/include/asm/rwsem.h |7 +-- arch/x86/include/asm/rwsem.h | 19 +-- include/asm-generic/rwsem.h

[RFC PATCH-tip v4 02/10] locking/rwsem: Stop active read lock ASAP

2016-08-18 Thread Waiman Long
--- -- randrw1210 MB/s 1352 MB/s +12% randwrite 1622 MB/s 1710 MB/s +5.4% The write-only microbench also showed improvement because some read locking was done by the XFS code. Signed-off-by: Waiman Long <waiman.l...@hpe.com> ---

[RFC PATCH-tip v4 07/10] locking/rwsem: Change RWSEM_WAITING_BIAS for better disambiguation

2016-08-18 Thread Waiman Long
+ RWSEM_ACTIVE_READ_BIAS Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- arch/alpha/include/asm/rwsem.h|3 ++- arch/ia64/include/asm/rwsem.h |2 +- arch/s390/include/asm/rwsem.h |2 +- arch/x86/include/asm/rwsem.h |3 ++- include/asm-generic/rwsem.h |4 ++-- i

[RFC PATCH-tip v4 09/10] locking/rwsem: Enable reactivation of reader spinning

2016-08-18 Thread Waiman Long
. If there are sufficient more successful spin attempts than failed ones, it will try to reactivate reader spinning. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- include/linux/rwsem.h | 12 kernel/locking/rwsem-xadd.c | 27 +-- 2 files chang

[RFC PATCH-tip v4 01/10] locking/osq: Make lock/unlock proper acquire/release barrier

2016-08-18 Thread Waiman Long
org> Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- kernel/locking/osq_lock.c | 24 ++-- 1 files changed, 18 insertions(+), 6 deletions(-) diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c index 05a3785..3da0b97 100644 --- a/kernel/locking/osq_

[RFC PATCH 0/4] futex: Introducing throughput-optimized futexes

2016-09-06 Thread Waiman Long
, isn't quite working yet. More investigation will have to be done to see if this can be fixed or the timeout parameter has to be scrapped entirely. Waiman Long (4): futex: Add futex_set_timer() helper function futex: Rename futex_pi_state to futex_state futex: Throughput-optimized (TO) futexes

[RFC PATCH 3/4] futex: Throughput-optimized (TO) futexes

2016-09-06 Thread Waiman Long
57.76s 1.92s lock count 2,827,202 9,999,640 555,025 unlock count 3,027,002 9,999,64116,217 The lock and unlock counts above show the actual numbers of futex(2) lock and unlock syscalls that were being issued. Signed-off-by: Waiman Long <waima

Re: [PATCH -tip] locking/rtmutex: Reduce top-waiter blocking on a lock

2016-09-26 Thread Waiman Long
On 09/23/2016 09:28 PM, Davidlohr Bueso wrote: +#ifdef CONFIG_RT_MUTEX_SPIN_ON_OWNER +static bool rt_mutex_spin_on_owner(struct rt_mutex *lock, + struct task_struct *owner) +{ +bool ret = true; + +/* + * The last owner could have just released the lock, + *

Re: [RFC PATCH-tip v4 01/10] locking/osq: Make lock/unlock proper acquire/release barrier

2016-10-05 Thread Waiman Long
On 10/05/2016 08:19 AM, Waiman Long wrote: On 10/04/2016 03:06 PM, Davidlohr Bueso wrote: On Thu, 18 Aug 2016, Waiman Long wrote: The osq_lock() and osq_unlock() function may not provide the necessary acquire and release barrier in some cases. This patch makes sure that the proper barriers

Re: [RFC PATCH-tip v4 02/10] locking/rwsem: Stop active read lock ASAP

2016-10-07 Thread Waiman Long
On 10/06/2016 05:47 PM, Dave Chinner wrote: On Thu, Oct 06, 2016 at 11:17:18AM -0700, Davidlohr Bueso wrote: On Thu, 18 Aug 2016, Waiman Long wrote: Currently, when down_read() fails, the active read locking isn't undone until the rwsem_down_read_failed() function grabs the wait_lock

Re: [RFC PATCH-tip v4 01/10] locking/osq: Make lock/unlock proper acquire/release barrier

2016-10-06 Thread Waiman Long
On 10/06/2016 01:47 AM, Davidlohr Bueso wrote: On Wed, 05 Oct 2016, Waiman Long wrote: diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c index 05a3785..1e6823a 100644 --- a/kernel/locking/osq_lock.c +++ b/kernel/locking/osq_lock.c @@ -12,6 +12,23 @@ */ static

Re: [RFC PATCH 3/4] futex: Throughput-optimized (TO) futexes

2016-09-22 Thread Waiman Long
On 09/22/2016 09:32 AM, Thomas Gleixner wrote: On Tue, 6 Sep 2016, Waiman Long wrote: +enum futex_type { + TYPE_PI = 0, + TYPE_TO, +}; Please introduce the futex_type magic and the related changes to the pi code in a seperate patch so it can be verified independently. It's sad

Re: [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes

2016-09-22 Thread Waiman Long
On 09/22/2016 05:41 PM, Thomas Gleixner wrote: On Thu, 22 Sep 2016, Davidlohr Bueso wrote: On Thu, 22 Sep 2016, Waiman Long wrote: 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. Btw

Re: [RFC PATCH v2 1/5] futex: Add futex_set_timer() helper function

2016-09-22 Thread Waiman Long
On 09/22/2016 05:31 PM, Thomas Gleixner wrote: On Tue, 20 Sep 2016, Waiman Long wrote: Please be more careful of your subject lines. First thing I thought was that you add a helper which is used in later patches to find out that you actualy consolidate duplicated code. Something like: futex

Re: [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes

2016-09-22 Thread Waiman Long
On 09/22/2016 04:38 PM, Thomas Gleixner wrote: On Thu, 22 Sep 2016, Waiman Long wrote: 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

Re: [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes

2016-09-22 Thread Waiman Long
On 09/22/2016 04:26 PM, Thomas Gleixner wrote: On Thu, 22 Sep 2016, Waiman Long wrote: On 09/22/2016 09:34 AM, Thomas Gleixner wrote: On Thu, 22 Sep 2016, Peter Zijlstra wrote: I'd leave out the TO part entirely (or only mention it in changelogs). That is, I'd call the futex ops: FUTEX_LOCK

Re: [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes

2016-09-21 Thread Waiman Long
On 09/21/2016 02:59 AM, Mike Galbraith wrote: On Tue, 2016-09-20 at 09:42 -0400, Waiman Long wrote: This patch introduces a new futex implementation called throughput-optimized (TO) futexes. nit: 'TO' sounds way too much like timeout... TP? You even use 'to' as shorthand for timeout

Re: [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes

2016-09-22 Thread Waiman Long
On 09/22/2016 09:23 AM, Peter Zijlstra wrote: On Tue, Sep 20, 2016 at 09:42:41AM -0400, Waiman Long wrote: +/* + * Spinning threshold before enabling lock handoff. + * Each sleep will decrement the threshold by 1/32 of the start value. + */ +#define TO_SPIN_THRESHOLD (1<< 13) +#

Re: [RFC PATCH 4/4] futex, doc: TO futexes document

2016-09-22 Thread Waiman Long
On 09/22/2016 09:51 AM, Thomas Gleixner wrote: On Thu, 22 Sep 2016, Waiman Long wrote: Yes, I will certainly send patch to update the manpages after the new futex gets merged into the upstream kernel. Or should I do that in parallel? It won't get merged w/o a patch to the manpage which

Re: [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes

2016-09-22 Thread Waiman Long
On 09/22/2016 09:34 AM, Thomas Gleixner wrote: On Thu, 22 Sep 2016, Peter Zijlstra wrote: I'd leave out the TO part entirely (or only mention it in changelogs). That is, I'd call the futex ops: FUTEX_LOCK and FUTEX_UNLOCK. That brings me to a different question: How is user space going to

Re: [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes

2016-09-22 Thread Waiman Long
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 spinn

Re: [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes

2016-09-22 Thread Waiman Long
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

[RFC PATCH v2 5/5] futex, doc: TO futexes document

2016-09-20 Thread Waiman Long
This patch adds a new document file on how to use the TO futexes. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- Documentation/00-INDEX |2 + Documentation/to-futex.txt | 140 2 files changed, 142 insertions(+), 0 deletions(-)

[RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes

2016-09-20 Thread Waiman Long
698,318 unlock count 3,268,896 9,999,814 134 The lock and unlock counts above show the actual numbers of futex(2) lock and unlock syscalls that were being issued. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- include/uapi/linux/futex.h |4 + kernel/f

[RFC PATCH v2 4/5] futex: Add timeout support to TO futexes

2016-09-20 Thread Waiman Long
This patch adds the timeout support in other futex types to TO futexes. However, the timeout isn't as precise as the other futex types due to the fact timer expiration can't currently be detected when the thread is waiting in the serialization mutex. Signed-off-by: Waiman Long <waima

[RFC PATCH v2 0/5] futex: Introducing throughput-optimized futexes

2016-09-20 Thread Waiman Long
xes in its calling convention, but provides better throughput than the wait-wake futexes by encouraging lock stealing and optimistic spinning. Waiman Long (5): futex: Add futex_set_timer() helper function futex: Rename futex_pi_state to futex_state futex: Throughput-optimized (TO) futexes fu

[RFC PATCH v2 2/5] futex: Rename futex_pi_state to futex_state

2016-09-20 Thread Waiman Long
states are also renamed. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- include/linux/sched.h |4 +- kernel/futex.c| 107 + 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/include/linux/sched.h b/include

Re: [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes

2016-09-22 Thread Waiman Long
On 09/22/2016 03:49 AM, Peter Zijlstra wrote: On Wed, Sep 21, 2016 at 07:37:34PM -0400, Waiman Long wrote: On 09/21/2016 02:59 AM, Mike Galbraith wrote: On Tue, 2016-09-20 at 09:42 -0400, Waiman Long wrote: This patch introduces a new futex implementation called throughput-optimized

Re: [RFC PATCH 4/4] futex, doc: TO futexes document

2016-09-22 Thread Waiman Long
On 09/22/2016 06:40 AM, Thomas Gleixner wrote: On Tue, 6 Sep 2016, Waiman Long wrote: This patch adds a new document file on how to use the TO futexes. Documentation is nice, but the proper place for documenting this is the futex(2) man page. Thanks, tglx Yes, I will certainly send

Re: [RFC PATCH-tip v4 10/10] locking/rwsem: Add a boot parameter to reader spinning threshold

2016-08-24 Thread Waiman Long
On 08/24/2016 12:00 AM, Davidlohr Bueso wrote: On Thu, 18 Aug 2016, Waiman Long wrote: The default reader spining threshold is current set to 4096. However, the right reader spinning threshold may vary from one system to another and among the different architectures. This patch adds a new

[PATCH v3 01/13] futex: Consolidate duplicated timer setup code

2016-09-30 Thread Waiman Long
A new futex_setup_timer() helper function is added to consolidate all the hrtimer_sleeper setup code. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- kernel/futex.c | 67 +++- 1 files changed, 37 insertions(+), 30 deletions(-)

[PATCH v3 09/13] futex: Implement lock handoff for TP futexes to prevent lock starvation

2016-09-30 Thread Waiman Long
Per-thread min/sec2 106 Per-thread max/sec 498 199 % Stddev 6.26% 0.97% Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- kernel/futex.c | 55 --- 1 files chang

[PATCH v3 05/13] futex: Add a new futex type field into futex_state

2016-09-30 Thread Waiman Long
As the futex_state structure will be overloaded in later patches to be used by non-PI futexes, it is necessary to add a type field to distinguish among different types of futexes. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- kernel/futex.c | 14 ++ 1 files chang

[PATCH v3 08/13] futex: Enable robust handling of TP futexes

2016-09-30 Thread Waiman Long
into the pi_state_list of the futex owner before the top waiter sleeps so that if exit_pi_state_list() is called, the wakeup will happen. The top waiter needs to remove its futex state object from the pi_state_list of the old owner if the ownership changes hand. Signed-off-by: Waiman Long <waiman.l...@hpe.

[PATCH v3 13/13] perf bench: New microbenchmark for userspace mutex performance

2016-09-30 Thread Waiman Long
. This microbenchmark then runs the locking rate measurement tests using either one of those mutexes or all of them consecutively. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- tools/perf/bench/Build |1 + tools/perf/bench/bench.h |1 + tools/perf/bench/futex-m

[PATCH v3 06/13] futex: Allow direct attachment of futex_state objects to hash bucket

2016-09-30 Thread Waiman Long
o link the futex state objects as well as a new spinlock to manage them are added to the hash bucket. To limit size increase for UP systems, these new fields are only for SMP machines where the cacheline alignment of the hash bucket leaves it with enough empty space for the new fields. Signed-off-by: Waima

[PATCH v3 00/13] futex: Introducing throughput-optimized futexes

2016-09-30 Thread Waiman Long
used to produce the performance data to the "perf bench futex" tool. Others can then use it to do their own evaluation. Waiman Long (13): futex: Consolidate duplicated timer setup code futex: Rename futex_pi_state to futex_state futex: Add helpers to get & cmpxchg futex value wit

[PATCH v3 04/13] futex: Consolidate pure pi_state_list add & delete codes to helpers

2016-09-30 Thread Waiman Long
Two new helper functions (task_pi_list_add & task_pi_list_del) are created to consolidate all the pure pi_state_list addition and insertion codes. The set_owner argument in task_pi_list_add() will be needed in a later patch. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- kern

[PATCH v3 03/13] futex: Add helpers to get & cmpxchg futex value without lock

2016-09-30 Thread Waiman Long
Two new helper functions cmpxchg_futex_value() and get_futex_value() are added to access and change the futex value without the hash bucket lock. As a result, page fault is enabled and the page will be faulted in if not present yet. Signed-off-by: Waiman Long <waiman.l...@hpe.com> ---

[PATCH v3 10/13] futex: Inform FUTEX_LOCK callers on how the lock is acquired

2016-09-30 Thread Waiman Long
the lock is acquired in the kernel. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- kernel/futex.c | 30 ++ 1 files changed, 22 insertions(+), 8 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index d260410..1219f32 100644 --- a/kernel/futex.c

[PATCH v3 02/13] futex: Rename futex_pi_state to futex_state

2016-09-30 Thread Waiman Long
states are also renamed. Signed-off-by: Waiman Long <waiman.l...@hpe.com> --- include/linux/sched.h |4 +- kernel/futex.c| 107 + 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/include/linux/sched.h b/include

Re: [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes

2016-09-26 Thread Waiman Long
On 09/23/2016 09:02 AM, Thomas Gleixner wrote: On Thu, 22 Sep 2016, Waiman Long wrote: Locking was done mostly by lock stealing. This is where most of the performance benefit comes from, not optimistic spinning. How does the lock latency distribution of all this look like and how fair

Re: [PATCH v3 07/13] futex: Throughput-optimized (TP) futexes

2016-10-01 Thread Waiman Long
On 10/01/2016 02:47 AM, Thomas Gleixner wrote: On Fri, 30 Sep 2016, Waiman Long wrote: + WRITE_ONCE(state->owner, current); + preempt_disable(); + for (;;) { + ret = futex_trylock(uaddr, vpid,, true); Did you actually read what I said? You CANNOT acc

[PATCH v4 07/20] futex: Introduce throughput-optimized (TP) futexes

2016-12-29 Thread Waiman Long
% 40 15,383,536 27,687,160 +80% 50 13,290,368 23,096,937 +74% 1008,577,763 14,410,909 +68% 1us sleep 176,450 179,660 +2% Signed-off-by: Waiman Long <long...@redhat.com> --- include/uapi/linux/f

[PATCH v4 02/20] futex: Rename futex_pi_state to futex_state

2016-12-29 Thread Waiman Long
states are also renamed. Signed-off-by: Waiman Long <long...@redhat.com> --- include/linux/sched.h | 4 +- kernel/futex.c| 107 +- 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/include/linux/sched.h b/include/linux/s

[PATCH v4 05/20] futex: Add a new futex type field into futex_state

2016-12-29 Thread Waiman Long
As the futex_state structure will be overloaded in later patches to be used by non-PI futexes, it is necessary to add a type field to distinguish among different types of futexes. Signed-off-by: Waiman Long <long...@redhat.com> --- kernel/futex.c | 15 +++ 1 file chang

[PATCH v4 06/20] futex: Allow direct attachment of futex_state objects to hash bucket

2016-12-29 Thread Waiman Long
o link the futex state objects as well as a new spinlock to manage them are added to the hash bucket. To limit size increase for UP systems, these new fields are only for SMP machines where the cacheline alignment of the hash bucket leaves it with enough empty space for the new fields. Signed-off-by: Waima

[PATCH v4 04/20] futex: Consolidate pure pi_state_list add & delete codes to helpers

2016-12-29 Thread Waiman Long
Two new helper functions (task_pi_list_add & task_pi_list_del) are created to consolidate all the pure pi_state_list addition and insertion codes. The set_owner argument in task_pi_list_add() will be needed in a later patch. Signed-off-by: Waiman Long <long...@redhat.com> --- kernel/fu

[PATCH v4 03/20] futex: Add helpers to get & cmpxchg futex value without lock

2016-12-29 Thread Waiman Long
Two new helper functions cmpxchg_futex_value() and get_futex_value() are added to access and change the futex value without the hash bucket lock. As a result, page fault is enabled and the page will be faulted in if not present yet. Signed-off-by: Waiman Long <long...@redhat.com> ---

[PATCH v4 01/20] futex: Consolidate duplicated timer setup code

2016-12-29 Thread Waiman Long
A new futex_setup_timer() helper function is added to consolidate all the hrtimer_sleeper setup code. Signed-off-by: Waiman Long <long...@redhat.com> --- kernel/futex.c | 67 -- 1 file changed, 37 insertions(+), 30 deletions(-) diff

[PATCH v4 00/20] futex: Introducing throughput-optimized (TP) futexes

2016-12-29 Thread Waiman Long
121,129152,242 - rwlock 99,149162,887 30,362 Patches 7 and 16 contain more detailed information about the performance characteristics of the TP futexes when implementing userspace mutex and rwlock respectively when compared with other possible way of doi

[PATCH v4 08/20] TP-futex: Enable robust handling

2016-12-29 Thread Waiman Long
-by: Waiman Long <long...@redhat.com> --- kernel/futex.c | 85 +- 1 file changed, 79 insertions(+), 6 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index 2374cce..2d3ec8d 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -

[PATCH v4 10/20] TP-futex: Return status code on FUTEX_LOCK calls

2016-12-29 Thread Waiman Long
the lock is acquired. 2) Bits 08-15: reserved 3) Bits 16-30: how many time the task sleeps in the optimistic spinning loop. By returning the TP status code, an external monitoring or tracking program can have a macro view of how the TP futexes are performing. Signed-off-by: Waiman Long <l

[PATCH v4 09/20] TP-futex: Implement lock handoff to prevent lock starvation

2016-12-29 Thread Waiman Long
-by: Waiman Long <long...@redhat.com> --- kernel/futex.c | 59 -- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index 2d3ec8d..711a2b4 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -63,6

[PATCH v4 13/20] perf bench: New microbenchmark for userspace mutex performance

2016-12-29 Thread Waiman Long
. This microbenchmark then runs the locking rate measurement tests using either one of those mutexes or all of them consecutively. Signed-off-by: Waiman Long <long...@redhat.com> --- tools/perf/bench/Build | 1 + tools/perf/bench/bench.h | 1 + tools/perf/bench/futex-locks.c

[PATCH v4 11/20] TP-futex: Add timeout support

2016-12-29 Thread Waiman Long
in the serialization mutex. Signed-off-by: Waiman Long <long...@redhat.com> --- kernel/futex.c | 50 ++ 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index 3308cc3..429d85f 100644 --- a/kernel/f

[PATCH v4 16/20] TP-futex: Group readers together in wait queue

2016-12-29 Thread Waiman Long
. Lock starvation should not happen on the TP futexes as long as the underlying kernel mutex is lock starvation free which is the case for 4.10 and later kernel. Signed-off-by: Waiman Long <long...@redhat.com> --- kernel/futex.c | 135 ++

[PATCH v4 17/20] TP-futex, doc: Update TP futexes document on shared locking

2016-12-29 Thread Waiman Long
The tp-futex.txt was updated to add description about shared locking support. Signed-off-by: Waiman Long <long...@redhat.com> --- Documentation/tp-futex.txt | 163 +++-- 1 file changed, 143 insertions(+), 20 deletions(-) diff --git a/Documentat

[PATCH v4 19/20] sched, TP-futex: Make wake_up_q() return wakeup count

2016-12-29 Thread Waiman Long
Unlike wake_up_process(), wake_up_q() doesn't tell us how many tasks have been woken up. This information can sometimes be useful for tracking purpose. So wake_up_q() is now modified to return that information. Signed-off-by: Waiman Long <long...@redhat.com> --- include/linux/sched

[PATCH v4 15/20] TP-futex: Enable kernel reader lock stealing

2016-12-29 Thread Waiman Long
mechanism hasn't been enabled yet. A new field locksteal_disabled is added to the futex state object for controlling reader lock stealing. So the waiting reader must retrieve the futex state object first before doing it. Signed-off-by: Waiman Long <long...@redhat.com> --- kernel/futex.

[PATCH v4 18/20] perf bench: New microbenchmark for userspace rwlock performance

2016-12-29 Thread Waiman Long
respectively. This microbenchmark then runs the locking rate measurement tests using either one of those rwlocks or all of them consecutively. Signed-off-by: Waiman Long <long...@redhat.com> --- tools/perf/bench/bench.h | 1 + tools/perf/bench/futex-locks.c

[PATCH v4 14/20] TP-futex: Support userspace reader/writer locks

2016-12-29 Thread Waiman Long
write lock/unlock code. This is by design to minimize any additional overhead for mutex lock and unlock. As a result, the TP futex rwlock prefers writers a bit more than readers. Signed-off-by: Waiman Long <long...@redhat.com> --- include/uapi/linux/futex.h | 28 +- ker

[PATCH v4 20/20] futex: Dump internal futex state via debugfs

2016-12-29 Thread Waiman Long
For debugging purpose, it is sometimes useful to dump the internal states in the futex hash bucket table. This patch adds a file "futex_hash_table" in debugfs root filesystem to dump the internal futex states. Signed-off-by: Waiman Long <long...@redhat.com> --- ker

  1   2   3   4   >