When transitioning from unlocked - locked (for write), we notify readers of our presence by setting the _QW_WAITING flag using a cmpxchg. Given that we use another cmpxchg to transition to the _QW_LOCKED state, we can drop the barriers from the intermediate step by offering architectures the chance to implement cmpxchg_relaxed, in a similar manner to the cmpxchg64_relaxed macro in the lockref code. Signed-off-by: Will Deacon <will.deacon@xxxxxxx> --- kernel/locking/qrwlock.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/locking/qrwlock.c b/kernel/locking/qrwlock.c index a1b63df19a04..e3c51c4635d3 100644 --- a/kernel/locking/qrwlock.c +++ b/kernel/locking/qrwlock.c @@ -113,6 +113,10 @@ EXPORT_SYMBOL(queued_read_lock_slowpath); * queued_write_lock_slowpath - acquire write lock of a queue rwlock * @lock : Pointer to queue rwlock structure */ +#ifndef cmpxchg_relaxed +# define cmpxchg_relaxed cmpxchg +#endif + void queued_write_lock_slowpath(struct qrwlock *lock) { u32 cnts; @@ -133,7 +137,7 @@ void queued_write_lock_slowpath(struct qrwlock *lock) struct __qrwlock *l = (struct __qrwlock *)lock; if (!READ_ONCE(l->wmode) && - (cmpxchg(&l->wmode, 0, _QW_WAITING) == 0)) + (cmpxchg_relaxed(&l->wmode, 0, _QW_WAITING) == 0)) break; cpu_relax_lowlatency(); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html