Received: by 10.223.185.116 with SMTP id b49csp773320wrg; Tue, 20 Feb 2018 07:39:44 -0800 (PST) X-Google-Smtp-Source: AH8x227Yp0eQWrCX9Fo55tA/Yld5fkLAcmCvjTwHdd+o98Dd+Lxs6MWCE1hF461REn26MLDpG0r7 X-Received: by 2002:a17:902:6985:: with SMTP id l5-v6mr61454plk.14.1519141184257; Tue, 20 Feb 2018 07:39:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519141184; cv=none; d=google.com; s=arc-20160816; b=ME3KYI+573TjiExLBVPuwkTGdlqnYPq/mufWK21HpGkSd0DewD2HctX5hQYzISIldN uh7/mzdezqZcgv4DYkVElolT8e3bIc4nGoub85JrUiDwP+KF9McgEYzX23G6AnLYcpj4 66gdACmu9q0cHArhCwtaBQEFlZY98rV6vO296Z50k40CNVG+2fkAZpAJuaIInZ6TudAt xPAUSdYyyM/1/QEJAF8WzO/73NrBYpsGhiAiKxybUsCzgeiIt/xSQNTMTzIGGkn1hhmd 7g2e4B/6KqBKoUXzSnkMCY8N8G/oYl6qACaxq3NQpDd3DqA+MH22EEqHuPw+mnQ4qrgM M2dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=ARw0lOj1vfYfl+3IVUyTS9ev1/HQF1FHiLbIMD18XDw=; b=FiPhN/J9K9Vivg5Cxo8C1ZZ+nW1v3FslGhzU49l7CcqIJuAFXBCbW5rLLzYfszPZmC CaBUFgByMAZ3rdu2KIXQIMx0bSi9zH0jnMoJ1+9IOPWfKPEWHFejoEl4YweTrCUt9rJr HS3ZL4DBobRZ0eIct2UvWiR0V122iiTIbyzS9zDdem1LrKOwBdm/chOwiU9pgtLRNCLp PYK11X184GlyFLqPsmD1d9ZMFzR5W4jCTKScP34ICRzRrS8iFl9TYjWT9jQMsNeJsdnK CTr7PzjW0KaCoqRWNdQhySJxqKv+cEgiTDws2OwZhky0O1MI/Zl8qAo7vnCrDMWNCOee a3SA== ARC-Authentication-Results: i=1; mx.google.com; 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 70-v6si2560429ple.147.2018.02.20.07.39.27; Tue, 20 Feb 2018 07:39:44 -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; 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 S1752501AbeBTPiv (ORCPT + 99 others); Tue, 20 Feb 2018 10:38:51 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:58996 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752381AbeBTPiu (ORCPT ); Tue, 20 Feb 2018 10:38:50 -0500 Received: (qmail 2945 invoked by uid 2102); 20 Feb 2018 10:38:49 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 20 Feb 2018 10:38:49 -0500 Date: Tue, 20 Feb 2018 10:38:49 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Andrea Parri cc: "Paul E. McKenney" , Akira Yokosawa , Kernel development list , , Will Deacon , , , , , Jade Alglave , Luc Maranget , Patrick Bellasi Subject: Re: [PATCH] tools/memory-model: remove rb-dep, smp_read_barrier_depends, and lockless_dereference In-Reply-To: <20180220093346.GA5505@andrea> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 20 Feb 2018, Andrea Parri wrote: > > This leaves us with a question: Do we want to change the kernel by > > adding memory barriers after unsuccessful RMW operations on Alpha, or > > do we want to change the model by excluding such operations from > > address dependencies? > > 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? Yes, this seems reasonable to me. If Will gives it his "Acked-by" to go with Peter's, you should submit it to Ingo Molnar. And once this is made, there shouldn't be any trouble with the proposed patch for the memory model. Alan > 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" > > > > > > Note that operations like atomic_add_unless() already include memory > > barriers. > > > > Alan