From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932659AbcFORSS (ORCPT ); Wed, 15 Jun 2016 13:18:18 -0400 Received: from merlin.infradead.org ([205.233.59.134]:38119 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751739AbcFORSP (ORCPT ); Wed, 15 Jun 2016 13:18:15 -0400 Date: Wed, 15 Jun 2016 19:18:00 +0200 From: Peter Zijlstra To: Boqun Feng Cc: Waiman Long , Ingo Molnar , linux-kernel@vger.kernel.org, x86@kernel.org, linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-s390@vger.kernel.org, linux-arch@vger.kernel.org, Davidlohr Bueso , Jason Low , Dave Chinner , Scott J Norton , Douglas Hatch Subject: Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper acquire/release barrier Message-ID: <20160615171800.GP30921@twins.programming.kicks-ass.net> References: <1465944489-43440-1-git-send-email-Waiman.Long@hpe.com> <1465944489-43440-2-git-send-email-Waiman.Long@hpe.com> <20160615080446.GA28443@insomnia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160615080446.GA28443@insomnia> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 15, 2016 at 04:04:46PM +0800, Boqun Feng wrote: > On Tue, Jun 14, 2016 at 06:48:04PM -0400, Waiman Long wrote: > > @@ -198,7 +198,7 @@ void osq_unlock(struct optimistic_spin_queue *lock) > > * Second most likely case. > > */ > > node = this_cpu_ptr(&osq_node); > > - next = xchg(&node->next, NULL); > > + next = xchg_release(&node->next, NULL); > > if (next) { > > WRITE_ONCE(next->locked, 1); > > So we still use WRITE_ONCE() rather than smp_store_release() here? > > Though, IIUC, This is fine for all the archs but ARM64, because there > will always be a xchg_release()/xchg() before the WRITE_ONCE(), which > carries a necessary barrier to upgrade WRITE_ONCE() to a RELEASE. Not sure. On PPC for example, you'll use lwsync() but will that not attach to the store to &node->next instead? Still leaving that store and the WRITE_ONCE() unordered. Also I don't see the control dependency between xchg-load and WRITE_ONCE helping anything to order the two stores. So yeah, subtle if not broken, definitely needs more explanation.