Received: by 10.223.185.116 with SMTP id b49csp5575968wrg; Tue, 27 Feb 2018 16:17:49 -0800 (PST) X-Google-Smtp-Source: AH8x2242E67ck26ok7LyMNMCZAOybLl8Gw6rh0DvuvgtvwCQ2vq7rnEyrTjShs6ZPiq2WYv3MZmP X-Received: by 2002:a17:902:a705:: with SMTP id w5-v6mr15607452plq.299.1519777069674; Tue, 27 Feb 2018 16:17:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519777069; cv=none; d=google.com; s=arc-20160816; b=qfOAUvKljATYKeJO57WP/AnQBuiG7E6FMcgqYPcYvB5DaHqNjafaCuQ2lr/wys5vV6 1X0oLCUEHmj7V1CpKweynJwEJi4wBFnpD38M0WvUsWWwsdQ8kibmCU1HMA7jTG+iMj+1 gC/u7SE/1qsTPiuksQ8VD3+dSQ+K6vcOSkmKxczcyL2ihFyL6cjSR76dnE1f6t9W47yy I0Rh+uVKtSCr9UPAKOunYSXuqIQIw9ATy8P7nexngl9My5SDhbkFzCKLn7oLzgUbPtjp rruW7ynGXApa9rRiFxWVGtA5e2DqeAFrn6NRHMslWEMkHB2iTgvc5lpkDPUk21U/LoKr Ikzg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=gEgtbqgjq0dYFl4LpC4S8YXLIDYQXNLxS54tmmM6FKo=; b=nsJIizf0Exo7s1lb2KY6SXF3eXW+6ET3pXaoFVFhKqgTIDcbV08Qx4JYN9A6Jn1ZDz /zyX2KbyuZNKusSI3sKQk/E4QExcIbULEZv6XfZHg4lI0S7HuY6opuXQ6CjQc82lGoDp 6253qnIs7LeEZsrW66IJbR62kr62MW78h1Pv8C/hEWNtYO6Yq1aTszNfv+wOi3X6pZLl WjTVyEy2rDv9Op8UNB5b7Wjp1kK4rFo4hqvbBLzhEjnsnSPnChCsVhq1gQfFs/1/Ho/A 8Iqs7vwcfqGPsY2eFzpPes/xz7eMnJmbxXbnNlaD5971NjNhdpUv7h0S/zPkEFFVdwZa LkCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i/n1kray; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n61-v6si267417plb.797.2018.02.27.16.17.27; Tue, 27 Feb 2018 16:17:49 -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=pass header.i=@gmail.com header.s=20161025 header.b=i/n1kray; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751631AbeB1APf (ORCPT + 99 others); Tue, 27 Feb 2018 19:15:35 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35094 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751117AbeB1APe (ORCPT ); Tue, 27 Feb 2018 19:15:34 -0500 Received: by mail-wm0-f66.google.com with SMTP id x7so1843432wmc.0 for ; Tue, 27 Feb 2018 16:15:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=gEgtbqgjq0dYFl4LpC4S8YXLIDYQXNLxS54tmmM6FKo=; b=i/n1krayJ0SblXcPRrzSdq3uvUW9lfHCtZqCRD/hcSb+O8AxoT56e4M/FXplZkFpBW RZU4UJuXw2BYpTrTBw+zPEa5axTWaChpJ3yis6Q/fBAH57R41HLqoBmPuoMGDdMNeg5P tZng0YD0MIYAJNsL+mMaj89BGCE7xHCu1vqJPcZ8x8WLyV0SpysPbxykzQMwtHyijUs6 EiqMmsWGnV/6s5JLtBS4Nh513cZo6tM7ZYbbF8kBgPVGVxeMapO9kfYZbKJco9tL6tOd 7+mGgGXPYVeINQVur2NMd/yOZzJ8hVZz75+SW+K8JBxTiRsMBW4ImHEFsOhQ+exk6LpQ VmQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=gEgtbqgjq0dYFl4LpC4S8YXLIDYQXNLxS54tmmM6FKo=; b=HR33VoyZU2aPUHgpO/W+JMTCf1WMjUu7XKuZcNLk+TmZdv+2DxkRTsLb4V3jNwW07h 4Kn3/rIWgw9cu5lE+MHXKttrtcvbEzdk43wi43DSpEeODdnr7mqaN7a0fRjV9l8JQweb Rk80onuTTqAHTe/qCCbxEpcns/UhNL9SGj02Ti2eFUc4LhSStrcEtiOn2wGPdmFubWiU W2FvPr93TE+4Nm6Ap95NIyNmf3wKSL7dHQ5iFOnaS64heaNv3va7FT+hW732W+D9LyIQ UE27PneEYQsC5HVy9gWmlyfwcH0zQgf5eoVg+Sx84mNzIpegrMgRwlbquR73sT57N/fu VDUg== X-Gm-Message-State: APf1xPCwAUlrwFahJJpnvXrtoIiowi7WOBWzmQSs6OvuNyRkwrWext1m d7AOFRm1gaq5gmxFTO0ReZA= X-Received: by 10.80.177.89 with SMTP id l25mr20991044edd.267.1519776932766; Tue, 27 Feb 2018 16:15:32 -0800 (PST) Received: from andrea (dynamic-2a00-1028-8386-da8a-d001-773d-d9d9-8d7c.ipv6.broadband.iol.cz. [2a00:1028:8386:da8a:d001:773d:d9d9:8d7c]) by smtp.gmail.com with ESMTPSA id f19sm658378edd.84.2018.02.27.16.15.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 16:15:32 -0800 (PST) Date: Wed, 28 Feb 2018 01:15:24 +0100 From: Andrea Parri To: Daniel Lustig Cc: Palmer Dabbelt , albert@sifive.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] riscv/barrier: Define __smp_{store_release,load_acquire} Message-ID: <20180228001524.GA3999@andrea> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 27, 2018 at 02:20:37PM -0800, Daniel Lustig wrote: > On 2/27/2018 10:21 AM, Palmer Dabbelt wrote: > > On Mon, 26 Feb 2018 18:24:11 PST (-0800), parri.andrea@gmail.com wrote: > >> Introduce __smp_{store_release,load_acquire}, and rely on the generic > >> definitions for smp_{store_release,load_acquire}. This avoids the use > >> of full ("rw,rw") fences on SMP. > >> > >> Signed-off-by: Andrea Parri > >> --- > >> ?arch/riscv/include/asm/barrier.h | 15 +++++++++++++++ > >> ?1 file changed, 15 insertions(+) > >> > >> diff --git a/arch/riscv/include/asm/barrier.h b/arch/riscv/include/asm/barrier.h > >> index 5510366d169ae..d4628e4b3a5ea 100644 > >> --- a/arch/riscv/include/asm/barrier.h > >> +++ b/arch/riscv/include/asm/barrier.h > >> @@ -38,6 +38,21 @@ > >> ?#define __smp_rmb()??? RISCV_FENCE(r,r) > >> ?#define __smp_wmb()??? RISCV_FENCE(w,w) > >> > >> +#define __smp_store_release(p, v)??????????????????? \ > >> +do {??????????????????????????????????? \ > >> +??? compiletime_assert_atomic_type(*p);??????????????? \ > >> +??? RISCV_FENCE(rw,w);??????????????????????? \ > >> +??? WRITE_ONCE(*p, v);??????????????????????? \ > >> +} while (0) > >> + > >> +#define __smp_load_acquire(p)??????????????????????? \ > >> +({??????????????????????????????????? \ > >> +??? typeof(*p) ___p1 = READ_ONCE(*p);??????????????? \ > >> +??? compiletime_assert_atomic_type(*p);??????????????? \ > >> +??? RISCV_FENCE(r,rw);??????????????????????? \ > >> +??? ___p1;??????????????????????????????? \ > >> +}) > >> + > >> ?/* > >> ? * This is a very specific barrier: it's currently only used in two places in > >> ? * the kernel, both in the scheduler.? See include/linux/spinlock.h for the two > > > > I'm adding Daniel just in case I misunderstood what's going on here, > > but these look good to me. As this is a non-trivial memory model > > change I'm going to let it bake in linux-next for a bit just so it > > gets some visibility. > > Looks good to me too. In particular, it also covers the > Write->release(p)->acquire(p)->Write ordering that we were debating > in the broader LKMM thread, which is good. Yeah, I think that other changes would be required to completely cover the issues debated in that thread: I plan to prepare and to post a new series/RFC to address those (unless someone precedes me of course ;-). Andrea > > Dan > > > > > Thanks