Whamcloud - gitweb
LU-4257 clio: replace semaphore with mutex 43/9943/2
authorShuichi Ihara <sihara@ddn.com>
Sun, 13 Apr 2014 14:11:03 +0000 (23:11 +0900)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 29 Apr 2014 00:15:15 +0000 (00:15 +0000)
commit72fcea9367c3087c7701d705b9246fe7ba962607
tree20a8e943e91ffacef040c9abb1ae269379108ef3
parent1b640c87de4daeffad746af454fcddc21c863664
LU-4257 clio: replace semaphore with mutex

According https://www.kernel.org/doc/Documentation/mutex-design.txt:
 - the mutex subsystem is slightly faster and has better scalability
   for contended workloads. In terms of 'ops per CPU cycle', the
   semaphore kernel performed 551 ops/sec per 1% of CPU time used,
   while the mutex kernel performed 3825 ops/sec per 1% of CPU time
   used - it was 6.9 times more efficient.
 - there are no fastpath tradeoffs, the mutex fastpath is just as
   tight as the semaphore fastpath. On x86, the locking fastpath is
   2 instructions.
 - 'struct mutex' semantics are well-defined and are enforced if
   CONFIG_DEBUG_MUTEXES is turned on. Semaphores on the other hand
   have virtually no debugging code or instrumentation.

One more benefit of mutex is optimistic spinning. It try to spin for
acquisition when there are no pending waiters and the lock owner is
currently running on a (different) CPU. The rationale is that if the
lock owner is running, it is likely to release the lock soon.

This significantly reduce amount of context switches when locked
region is small and we have high contention.

Lustre commit: 96f482b509867bb70cc26e94e60903df82b09f30
Lustre change: http://review.whamcloud.com/9095

Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Signed-off-by: Shuichi Ihara <sihara@ddn.com>
Change-Id: I29cb202468610636ebd45d49281c4e503930bde6
Reviewed-on: http://review.whamcloud.com/9943
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c