From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754576AbcDVQxP (ORCPT ); Fri, 22 Apr 2016 12:53:15 -0400 Received: from foss.arm.com ([217.140.101.70]:36016 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753878AbcDVQxO (ORCPT ); Fri, 22 Apr 2016 12:53:14 -0400 Date: Fri, 22 Apr 2016 17:53:11 +0100 From: Will Deacon To: Boqun Feng Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, waiman.long@hpe.com, mingo@redhat.com, paulmck@linux.vnet.ibm.com, torvalds@linux-foundation.org, dave@stgolabs.net Subject: Re: [RFC][PATCH 3/3] locking,arm64: Introduce cmpwait() Message-ID: <20160422165310.GN10289@arm.com> References: <20160404122250.340636238@infradead.org> <20160404123633.484451002@infradead.org> <20160412165941.GG26124@arm.com> <20160422160857.GA3369@insomnia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160422160857.GA3369@insomnia> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 23, 2016 at 12:08:57AM +0800, Boqun Feng wrote: > On Tue, Apr 12, 2016 at 05:59:41PM +0100, Will Deacon wrote: > [...] > > > +static inline void __cmpwait(volatile void *ptr, unsigned long val, int size) > > > +{ > > > + switch (size) { > > > + case 1: return __cmpwait_case_1(ptr, val); > > > + case 2: return __cmpwait_case_2(ptr, val); > > > + case 4: return __cmpwait_case_4(ptr, val); > > > + case 8: return __cmpwait_case_8(ptr, val); > > > + default: BUILD_BUG(); > > > + } > > > + > > > + unreachable(); > > > +} > > > + > > > +#define cmpwait(ptr, val) \ > > > + __cmpwait((ptr), (unsigned long)(val), sizeof(*(ptr))) > > > > We might want to call this cmpwait_relaxed, in case we decide to add > > fenced versions in the future. Or just make it cmpwait_acquire and > > remove the smp_rmb() from smp_cond_load_acquire(). Dunno. > > > > How about replace smp_rmb() with a smp_acquire_barrier__after_cmpwait()? > This barrier is designed to provide an ACQUIRE ordering when combining a > cmpwait() . > > And cmpwait() only has minimal ordering guarantee, but if it is actually > an ACQUIRE, then the corresponding smp_acquire_barrier__after_cmpwait() > is just empty. Maybe, but that makes it difficult for me to use a load-acquire instruction for the ACQUIRE case. Will