On Fri, Apr 17, 2015 at 10:03:18PM -0400, Waiman Long wrote:
@@ -478,7 +515,28 @@ struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem)successful trylock? I think we're having 'issues' on if failed trylocks
{
unsigned long flags;
- raw_spin_lock_irqsave(&sem->wait_lock, flags);
+ /*
+ * If a spinner is present, it is not necessary to do the wakeup.
+ * Try to do wakeup only if the trylock succeeds to minimize
+ * spinlock contention which may introduce too much delay in the
+ * unlock operation.
+ *
+ * In case the spinning writer is just going to break out of the
+ * waiting loop, it will still do a trylock in
+ * rwsem_down_write_failed() before sleeping.
+ * IOW, if rwsem_has_spinner() is true, it will guarantee at least
+ * one trylock attempt on the rwsem.
(and cmpxchg) imply full barriers.
+ *Ordering comes in pairs, this is incomplete.
+ * spinning writer
+ * ---------------
+ * [S] osq_unlock()
+ * MB
+ * [RmW] rwsem_try_write_lock()
+ */