RFC: FROMLIST: locking/percpu-rwsem: Optimize readers and reduce global impact
authorPeter Zijlstra <peterz@infradead.org>
Tue, 9 Aug 2016 15:44:12 +0000 (08:44 -0700)
committerAmit Pundir <amit.pundir@linaro.org>
Wed, 14 Sep 2016 08:56:20 +0000 (14:26 +0530)
commitd4d74af4b871915fe926d2f267e311949e0bf4b4
tree0cbb310a4266932a2dbbd36a03b543fe5ded614c
parent0e806c83bca02211f6b2e3de31df085eb4cf3508
RFC: FROMLIST: locking/percpu-rwsem: Optimize readers and reduce global impact

Currently the percpu-rwsem switches to (global) atomic ops while a
writer is waiting; which could be quite a while and slows down
releasing the readers.

This patch cures this problem by ordering the reader-state vs
reader-count (see the comments in __percpu_down_read() and
percpu_down_write()). This changes a global atomic op into a full
memory barrier, which doesn't have the global cacheline contention.

This also enables using the percpu-rwsem with rcu_sync disabled in order
to bias the implementation differently, reducing the writer latency by
adding some cost to readers.

Mailing-list-URL: https://lkml.org/lkml/2016/8/9/181
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
[jstultz: Backported to 4.4]
Change-Id: I8ea04b4dca2ec36f1c2469eccafde1423490572f
Signed-off-by: John Stultz <john.stultz@linaro.org>
include/linux/percpu-rwsem.h
kernel/locking/percpu-rwsem.c