]> git.baikalelectronics.ru Git - kernel.git/commit
seqlock: Add a new locking reader type
authorWaiman Long <Waiman.Long@hp.com>
Thu, 12 Sep 2013 14:55:34 +0000 (10:55 -0400)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 12 Sep 2013 16:25:23 +0000 (09:25 -0700)
commitccfc61ec18282d8708d4b3a889fb0a8df80aa87c
tree9e3c2e9b0e0a7f67e50898e8ff5ecb462f260625
parentaccee23fe96ec9b0ee87a9b57399b7d6bb04be40
seqlock: Add a new locking reader type

The sequence lock (seqlock) was originally designed for the cases where
the readers do not need to block the writers by making the readers retry
the read operation when the data change.

Since then, the use cases have been expanded to include situations where
a thread does not need to change the data (effectively a reader) at all
but have to take the writer lock because it can't tolerate changes to
the protected structure.  Some examples are the d_path() function and
the getcwd() syscall in fs/dcache.c where the functions take the writer
lock on rename_lock even though they don't need to change anything in
the protected data structure at all.  This is inefficient as a reader is
now blocking other sequence number reading readers from moving forward
by pretending to be a writer.

This patch tries to eliminate this inefficiency by introducing a new
type of locking reader to the seqlock locking mechanism.  This new
locking reader will try to take an exclusive lock preventing other
writers and locking readers from going forward.  However, it won't
affect the progress of the other sequence number reading readers as the
sequence number won't be changed.

Signed-off-by: Waiman Long <Waiman.Long@hp.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/seqlock.h