linux/include
Oleg Nesterov a1fd3e24d8 percpu_rw_semaphore: reimplement to not block the readers unnecessarily
Currently the writer does msleep() plus synchronize_sched() 3 times to
acquire/release the semaphore, and during this time the readers are
blocked completely.  Even if the "write" section was not actually started
or if it was already finished.

With this patch down_write/up_write does synchronize_sched() twice and
down_read/up_read are still possible during this time, just they use the
slow path.

percpu_down_write() first forces the readers to use rw_semaphore and
increment the "slow" counter to take the lock for reading, then it
takes that rw_semaphore for writing and blocks the readers.

Also.  With this patch the code relies on the documented behaviour of
synchronize_sched(), it doesn't try to pair synchronize_sched() with
barrier.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anton Arapov <anton@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-12-17 17:15:18 -08:00
..
acpi PCI changes for the v3.8 merge window: 2012-12-13 12:14:47 -08:00
asm-generic asm-generic: io: don't perform swab during {in,out} string functions 2012-12-17 17:15:13 -08:00
clocksource
crypto crypto: cast5/cast6 - move lookup tables to shared module 2012-12-06 17:16:26 +08:00
drm Merge branch 'drm-intel-fixes' of git://people.freedesktop.org/~danvet/drm-intel into drm-next 2012-12-16 06:05:03 +00:00
keys
linux percpu_rw_semaphore: reimplement to not block the readers unnecessarily 2012-12-17 17:15:18 -08:00
math-emu
media
memory
misc
net Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2012-12-13 12:00:02 -08:00
pcmcia
ras
rdma
rxrpc
scsi SCSI misc on 20121212 2012-12-13 19:20:31 -08:00
sound Merge remote-tracking branch 'asoc/topic/tlv320aic32x4' into asoc-next 2012-12-10 00:22:20 +09:00
target target/iscsi_target: Add NodeACL tags for initiator group support 2012-12-13 14:18:09 -08:00
trace There are two major features for this merge window. The first is 2012-12-16 17:33:01 -08:00
uapi Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2012-12-17 08:26:17 -08:00
video Merge tag 'omapdss-for-3.8' of git://gitorious.org/linux-omap-dss2/linux into for-linus 2012-12-13 14:30:56 +02:00
xen Features: 2012-12-13 14:29:16 -08:00
Kbuild