On Mon, Nov 04, 2013 at 12:17:20PM -0500, Waiman Long wrote:There is a pending patch in the rwsem patch series that adds a genericThis one does might address at least some of the earlier memory-barrier
MCS locking helper functions to do MCS-style locking. This patch
will enable the queue rwlock to use that generic MCS lock/unlock
primitives for internal queuing. This patch should only be merged
after the merging of that generic MCS locking patch.
Signed-off-by: Waiman Long<Waiman.Long@xxxxxx>
issues, at least assuming that the MCS lock is properly memory-barriered.
Then again, maybe not. Please see below.
Thanx, Paul
/*But mcs_spin_unlock() is only required to do a RELEASE barrier, which
* At the head of the wait queue now, try to increment the reader
@@ -172,12 +103,36 @@ void queue_read_lock_slowpath(struct qrwlock *lock)
while (ACCESS_ONCE(lock->cnts.writer))
cpu_relax();
}
- rspin_until_writer_unlock(lock, 1);
- signal_next(lock,&node);
+ /*
+ * Increment reader count& wait until writer unlock
+ */
+ cnts.rw = xadd(&lock->cnts.rw, QRW_READER_BIAS);
+ rspin_until_writer_unlock(lock, cnts);
+ mcs_spin_unlock(&lock->waitq,&node);
could still allow critical-section leakage.