From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH v10 1/4] qrwlock: A queue read/write lock implementation Date: Thu, 23 Jan 2014 11:07:51 +0100 Message-ID: <20140123100751.GS30183@twins.programming.kicks-ass.net> References: <1390426438-31252-1-git-send-email-Waiman.Long@hp.com> <1390426438-31252-2-git-send-email-Waiman.Long@hp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from merlin.infradead.org ([205.233.59.134]:55995 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751678AbaAWKIa (ORCPT ); Thu, 23 Jan 2014 05:08:30 -0500 Content-Disposition: inline In-Reply-To: <1390426438-31252-2-git-send-email-Waiman.Long@hp.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Waiman Long Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Arnd Bergmann , linux-arch@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Steven Rostedt , Andrew Morton , Michel Lespinasse , Andi Kleen , Rik van Riel , "Paul E. McKenney" , Linus Torvalds , Raghavendra K T , George Spelvin , Tim Chen , "Aswin Chandramouleeswaran\"" , Scott J Norton On Wed, Jan 22, 2014 at 04:33:55PM -0500, Waiman Long wrote: > +/** > + * queue_read_unlock - release read lock of a queue rwlock > + * @lock : Pointer to queue rwlock structure > + */ > +static inline void queue_read_unlock(struct qrwlock *lock) > +{ > + /* > + * Atomically decrement the reader count > + */ > + atomic_sub(_QR_BIAS, &lock->cnts.rwa); > +} > + > +/** > + * queue_write_unlock - release write lock of a queue rwlock > + * @lock : Pointer to queue rwlock structure > + */ > +static inline void queue_write_unlock(struct qrwlock *lock) > +{ > + /* > + * If the writer field is atomic, it can be cleared directly. > + * Otherwise, an atomic subtraction will be used to clear it. > + */ > + if (__native_word(lock->cnts.writer)) > + smp_store_release(&lock->cnts.writer, 0); > + else > + atomic_sub(_QW_LOCKED, &lock->cnts.rwa); > +} Both these unlocks miss a barrier; atomic_sub() doesn't imply any barrier what so ever. The smp_store_release() does, but the other two are invalid release ops in generic.