Received: by 10.223.185.116 with SMTP id b49csp613135wrg; Tue, 20 Feb 2018 05:05:38 -0800 (PST) X-Google-Smtp-Source: AH8x226/pVSe8ho1PBfurWJgmluadbdSysfeH6m0QyhDyAQhHzMO/ByuvHQTFipx1dCrEVmja+8e X-Received: by 2002:a17:902:4683:: with SMTP id p3-v6mr17392607pld.408.1519131938555; Tue, 20 Feb 2018 05:05:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519131938; cv=none; d=google.com; s=arc-20160816; b=Ww+ch27k7p4vM0e/2/Vpi6xftP/77IZBLv4PQPB6nG+bU6X1XN0jP5HL/tl8oE/SU2 KemEfPfKXKco6Y3lfsZUAQ1TtCBP++XXCsNH6wJ5Cr0dlifR+3V1hcU4QXRlMwhcfYnz H1MnGZi9FKFQnxGh4i9OOHWp/szz2QfFVAd+BCLvXPsJr4vwoRFx6TXuhb1cBnc/RbFY 1+kLbJYnSmItF67CGNLYxfW71i4O4kKXw+4+jCKWLErY90DG2RoUfHRqAit4JsMWWhzl JT/Ud2u32mn0NQ0u/OsW+ivpX5rohyj/JH5iK0TwvuzkFWkLIuoIP0K3/hzrARPf7VkQ 1cdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=JUrgDshRcrybfyDPpYTh8LqBJa2dgH5kb4WsblXYeGQ=; b=fKD4OmqaQeNxLNOOBG6ICUgH6aKwALRUWlVPQrXwTISoZX0+k3Yf282VoLp0GBuM+s 7bPYWn2/hPU/p0tlgi+tGM92CqxA5GZdSsA+nziYZIfHhricOlNbPw825+E0tPhC/Dyf Ql/siHbQ6s2wAUKQqbicqV0/2+RioGRtF9Y15ugEHDcz2xFUu7+TjS4ZgsX17xmSNN9+ L6HRjnbtabX1cDQI1sZsMSZgRlU/EbJlJ77uEqXBbfrQqX2gwwWDRe1I3fN8S/z+4Fze uV3DXtbj1+xnLTsaf62lYDUAPCPlAzJ7vq7Wy3J1bFLM3a5ikcEAsfD6u3KfFRtDPLgF moAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=oFYYGn93; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y38-v6si5671121plh.448.2018.02.20.05.05.06; Tue, 20 Feb 2018 05:05:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=oFYYGn93; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752258AbeBTNCz (ORCPT + 99 others); Tue, 20 Feb 2018 08:02:55 -0500 Received: from merlin.infradead.org ([205.233.59.134]:55480 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751940AbeBTNCN (ORCPT ); Tue, 20 Feb 2018 08:02:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JUrgDshRcrybfyDPpYTh8LqBJa2dgH5kb4WsblXYeGQ=; b=oFYYGn93TW2tRCBwoRK+gsGF8 Jh2igw//OvAyQiY1hVTOkyv4H/3BTsITZxImzx22QQiHYKhmcQHQ+ohWZ0tJMGbm0lIXuC30tDFnH l3D5cLETpb9URvvd0S5AVWLWenl2IedAeo/15QMoSWOrg+rANJgMj+hdFxtJ4wY05WSUGX5k4nslc EZXGq/Oa0T8ZUGEif6PKL5+sPckGhFxxZB/U7lShcuUkFOnQ3wH5QXS9hP47Jekol/tDQgEjiyA5+ KWJK3sfBu/qX+EDlVzlcxnVyPkh8WX/mpBOK5T4FQM8ThAIQLM9+hpzMw3DHy8Pk0bb0vOQlJZjS2 EUxJVP+lQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eo7YU-00084O-1A; Tue, 20 Feb 2018 13:01:58 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0C3622038D7A9; Tue, 20 Feb 2018 14:01:54 +0100 (CET) Date: Tue, 20 Feb 2018 10:51:58 +0100 From: Peter Zijlstra To: Andrea Parri Cc: Alan Stern , "Paul E. McKenney" , Akira Yokosawa , Kernel development list , mingo@kernel.org, Will Deacon , boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, Jade Alglave , Luc Maranget , Patrick Bellasi Subject: Re: [PATCH] tools/memory-model: remove rb-dep, smp_read_barrier_depends, and lockless_dereference Message-ID: <20180220095158.GJ25181@hirez.programming.kicks-ass.net> References: <20180217151413.GA3785@andrea> <20180220093346.GA5505@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180220093346.GA5505@andrea> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 20, 2018 at 10:33:47AM +0100, Andrea Parri wrote: > I'd like to continue to treat R[once] and R*[once] equally if possible. > Given the (unconditional) smp_read_barrier_depends in READ_ONCE and in > atomics, it seems reasonable to have it unconditionally in cmpxchg. > > As with the following patch? > > Andrea > > --- > diff --git a/arch/alpha/include/asm/xchg.h b/arch/alpha/include/asm/xchg.h > index 68dfb3cb71454..e2660866ce972 100644 > --- a/arch/alpha/include/asm/xchg.h > +++ b/arch/alpha/include/asm/xchg.h > @@ -128,10 +128,9 @@ ____xchg(, volatile void *ptr, unsigned long x, int size) > * store NEW in MEM. Return the initial value in MEM. Success is > * indicated by comparing RETURN with OLD. > * > - * The memory barrier should be placed in SMP only when we actually > - * make the change. If we don't change anything (so if the returned > - * prev is equal to old) then we aren't acquiring anything new and > - * we don't need any memory barrier as far I can tell. > + * The memory barrier is placed in SMP unconditionally, in order to > + * guarantee that dependency ordering is preserved when a dependency > + * is headed by an unsuccessful operation. > */ > > static inline unsigned long > @@ -150,8 +149,8 @@ ____cmpxchg(_u8, volatile char *m, unsigned char old, unsigned char new) > " or %1,%2,%2\n" > " stq_c %2,0(%4)\n" > " beq %2,3f\n" > - __ASM__MB > "2:\n" > + __ASM__MB > ".subsection 2\n" > "3: br 1b\n" > ".previous" > @@ -177,8 +176,8 @@ ____cmpxchg(_u16, volatile short *m, unsigned short old, unsigned short new) > " or %1,%2,%2\n" > " stq_c %2,0(%4)\n" > " beq %2,3f\n" > - __ASM__MB > "2:\n" > + __ASM__MB > ".subsection 2\n" > "3: br 1b\n" > ".previous" > @@ -200,8 +199,8 @@ ____cmpxchg(_u32, volatile int *m, int old, int new) > " mov %4,%1\n" > " stl_c %1,%2\n" > " beq %1,3f\n" > - __ASM__MB > "2:\n" > + __ASM__MB > ".subsection 2\n" > "3: br 1b\n" > ".previous" > @@ -223,8 +222,8 @@ ____cmpxchg(_u64, volatile long *m, unsigned long old, unsigned long new) > " mov %4,%1\n" > " stq_c %1,%2\n" > " beq %1,3f\n" > - __ASM__MB > "2:\n" > + __ASM__MB > ".subsection 2\n" > "3: br 1b\n" > ".previous" ACK