From: Peter Zijlstra Subject: Re: [PATCH 01/20] asm-generic/mmiowb: Add generic implementation of mmiowb() tracking Date: Thu, 7 Mar 2019 10:13:18 +0100 Message-ID: <20190307091318.GA32477@hirez.programming.kicks-ass.net> References: <20190301140348.25175-1-will.deacon@arm.com> <20190301140348.25175-2-will.deacon@arm.com> <1551575210.6lwpiqtg5k.astroid@bobo.none> <87ef7n7x9v.fsf@concordia.ellerman.id.au> <87k1hbv7ba.fsf@concordia.ellerman.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <87k1hbv7ba.fsf@concordia.ellerman.id.au> Sender: linux-kernel-owner@vger.kernel.org To: Michael Ellerman Cc: Linus Torvalds , Nicholas Piggin , linux-arch , Will Deacon , Andrea Parri , Arnd Bergmann , Benjamin Herrenschmidt , Rich Felker , David Howells , Daniel Lustig , Linux List Kernel Mailing , "Maciej W. Rozycki" , Ingo Molnar , Palmer Dabbelt , Paul Burton , "Paul E. McKenney" , Alan Stern , Tony Luck , Yoshinori Sato List-Id: linux-arch.vger.kernel.org On Thu, Mar 07, 2019 at 11:47:53AM +1100, Michael Ellerman wrote: > The mutex unlock fast path is just: > > if (atomic_long_cmpxchg_release(&lock->owner, curr, 0UL) == curr) > return true; > > And because it's the "release" variant we just use lwsync, which doesn't > order MMIO. If it was just atomic_long_cmpxchg() that would work because > we use sync for those. > > __up_write() uses atomic_long_sub_return_release(), so same story. As does spin_unlock() of course, which is a great segway into... my RCsc desires :-) If all your unlocks were to have SYNC, your locks would, aside from ordering MMIO, also be RCsc, Win-Win :-) There is, of course, that pesky little performance detail that keeps getting in the way.