fs/locks: Replace lg_global with a percpu-rwsem
authorPeter Zijlstra <peterz@infradead.org>
Mon, 22 Jun 2015 12:16:33 +0000 (14:16 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 22 Sep 2016 13:25:53 +0000 (15:25 +0200)
commitaba37660738325d48c913f3a952a7116d6e6a74b
tree42a6a0d45ab43fb2e8db1162fe08b7954790bc92
parent11d9684ca638aad99f740ef3abcba2aa4c9290bf
fs/locks: Replace lg_global with a percpu-rwsem

Replace the global part of the lglock with a percpu-rwsem.

Since fcl_lock is a spinlock and itself nests under i_lock, which too
is a spinlock we cannot acquire sleeping locks at
locks_{insert,remove}_global_locks().

We can however wrap all fcl_lock acquisitions with percpu_down_read
such that all invocations of locks_{insert,remove}_global_locks() have
that read lock held.

This allows us to replace the lg_global part of the lglock with the
write side of the rwsem.

In the absense of writers, percpu_{down,up}_read() are free of atomic
instructions. This further avoids the very long preempt-disable
regions caused by lglock on larger machines.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: dave@stgolabs.net
Cc: der.herr@hofr.at
Cc: paulmck@linux.vnet.ibm.com
Cc: riel@redhat.com
Cc: tj@kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
fs/locks.c