summaryrefslogtreecommitdiffstats
path: root/lib/clz_tab.c
diff options
context:
space:
mode:
authorMichel Lespinasse <walken@google.com>2013-05-07 06:45:59 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-07 07:20:16 -0700
commitfe6e674c6187d4f452a679ced7e95262bd517936 (patch)
treeba04818049ec225a541f278940532473d3005b9c /lib/clz_tab.c
parent8cf5322ce69afea1fab6a6270db24d057d664798 (diff)
downloadlinux-fe6e674c6187d4f452a679ced7e95262bd517936.tar.gz
linux-fe6e674c6187d4f452a679ced7e95262bd517936.tar.bz2
linux-fe6e674c6187d4f452a679ced7e95262bd517936.zip
rwsem: implement support for write lock stealing on the fastpath
When we decide to wake up readers, we must first grant them as many read locks as necessary, and then actually wake up all these readers. But in order to know how many read shares to grant, we must first count the readers at the head of the queue. This might take a while if there are many readers, and we want to be protected against a writer stealing the lock while we're counting. To that end, we grant the first reader lock before counting how many more readers are queued. We also require some adjustments to the wake_type semantics. RWSEM_WAKE_NO_ACTIVE used to mean that we had found the count to be RWSEM_WAITING_BIAS, in which case the rwsem was known to be free as nobody could steal it while we hold the wait_lock. This doesn't make sense once we implement fastpath write lock stealing, so we now use RWSEM_WAKE_ANY in that case. Similarly, when rwsem_down_write_failed found that a read lock was active, it would use RWSEM_WAKE_READ_OWNED which signalled that new readers could be woken without checking first that the rwsem was available. We can't do that anymore since the existing readers might release their read locks, and a writer could steal the lock before we wake up additional readers. So, we have to use a new RWSEM_WAKE_READERS value to indicate we only want to wake readers, but we don't currently hold any read lock. Signed-off-by: Michel Lespinasse <walken@google.com> Reviewed-by: Peter Hurley <peter@hurleysoftware.com> Acked-by: Davidlohr Bueso <davidlohr.bueso@hp.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/clz_tab.c')
0 files changed, 0 insertions, 0 deletions