Received: by 10.223.185.116 with SMTP id b49csp5267272wrg; Tue, 27 Feb 2018 10:22:40 -0800 (PST) X-Google-Smtp-Source: AH8x225938iQKorCUYiInNp3lBXd1ibOeKmRwZeNiWwn0GoYsGSaIgzPqRnh6CS9q0hcP8q0hr5r X-Received: by 2002:a17:902:9a41:: with SMTP id x1-v6mr14856429plv.256.1519755760453; Tue, 27 Feb 2018 10:22:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519755760; cv=none; d=google.com; s=arc-20160816; b=XDn7DYqlki5BIvI6/MHxwStM2C5YYjic5Q1tOhAsJoF5hu3j5VjM9+YtZ1I2l1OJyR vjyhXH58mkAcV9WVvSOIUvTSPDuigfh1+8QQ+uEOI1dIhil8e833bvBAtLS7GPf02RXn yKaDlt35Lo+MA9holCj5WVpk3yfWf8u4iauROS9V7xL6Y/nS6OSbk/fWUSij1hs1Y7rU JEJWK8rdKyxB1GEnq3lQzwBLooywHdMgAa6JC6K/Rx5P3iYVktS3v9UPvg/QpapumBE+ /Xv6RXWPOAC/L+84ZSPb8I4yf0jaO+O7KCW2yX5yLVGh41vrGQ1JqpOjlb9B6RXZfqTZ g8Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature :arc-authentication-results; bh=FgVPUDoxi8SBFxrXgnjlPyIDMhZwk4fRfDDmfK7IvhI=; b=NHAPV1pHKbw7r3DUdH/1TX5mz5Jdp+vb0aGXpQkcEWpO6NakBJOB9A1S6ySWYgyOyG 30WCHhljk6LyrdJocRPG4nr+QFhpPrC4Kfvkz/4Ntu4oX64+fUycg1DltoGJfCEH0qdb b+kkRYd/2I+W63WyX6uMw64V3drAGbL9o74tPDtBANaIZ+NUPw5LMenFWvup+NtSS2jL /n4iT6UpXqqbgagBFa19iVII9K4lLjVcREVRyG7yNpTlyjeDOEmtdC8Fmv2mrL7QA9rO DxrLUjhbkGTWH8SVvX+9nTKG8zEiwd9SyW5Mllqu3vG8j3/LPIOZDwkZoXNmMffxnZzQ 5J6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=ZxdJMe5F; 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 e1-v6si8755296ple.154.2018.02.27.10.22.25; Tue, 27 Feb 2018 10:22:40 -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=@sifive.com header.s=google header.b=ZxdJMe5F; 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 S1751554AbeB0SVq (ORCPT + 99 others); Tue, 27 Feb 2018 13:21:46 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:45708 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751062AbeB0SVo (ORCPT ); Tue, 27 Feb 2018 13:21:44 -0500 Received: by mail-pl0-f67.google.com with SMTP id v9-v6so9863535plp.12 for ; Tue, 27 Feb 2018 10:21:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=FgVPUDoxi8SBFxrXgnjlPyIDMhZwk4fRfDDmfK7IvhI=; b=ZxdJMe5FgvQu4pFu7UGpY81wDMtq5L1ppTFgv7zqVElCThs5ryM9iIF4jIttPaoqgH 0JPXMqF8aKLFiGwpAdsUibIJVCDKSpMAAPUyajOqanUre43kIYCx80sSBjtW2Mnxw/1n 3P2d5JKrGWa4ko5zXHMQRlI/naCGjH16KB10065FKLGcYHtoafzU4bYsuDRY2EpOrx74 rIRFhec9pJFNbxGubSyf2Oir7gQSc5zWkn7nl/Ji+k0s9KzWBgPLuuNjPMShntpInN6m OVkF053hLLnpPv1rByoqMvK4mOuv1lN42XD+uWaFoBe2m1JZeQ0QJ759y8uq+31gzQe1 PQ1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=FgVPUDoxi8SBFxrXgnjlPyIDMhZwk4fRfDDmfK7IvhI=; b=kwIXOu71OrE+r1JLC5psbzKd2yvy3Labe4QQBqiaUmRA3aYVBwQ78uus1sPMje0hwW gfxLYoAJ+kYvanmNW8Lua4jRmLtcSYBNPrA5Kf0YmHllbWSY3WMmT2sQpfn+8vUDrT3Y wHbELrM3ResqPmc6ujSnnaj3L8/vxhwDLz0+pXm2H/nmNAzDlBFS9kZpD/OUWvwI1kdi j+VB1sTzjxkRzVoEXTFkh/TaDE8vhWoNV44T7PPvQ6U1zksnefnGfCZ1O6/Hj4pBDBSs EI6ik41pGNX/D2hsGCoR8R6wzDSlYzBTqqw8kM9FE5O1DwibmjD6KYjmfzAmLGmnhWOh mdkQ== X-Gm-Message-State: APf1xPCkxY00RzQFhX0GOoNI7SqHa5zG4Nq7WyKAFN/MNRfNaERnB1wa L34I1qzMpWjBcAl/5MK8rGlWOw== X-Received: by 2002:a17:902:28c4:: with SMTP id f62-v6mr14905671plb.411.1519755704167; Tue, 27 Feb 2018 10:21:44 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id n67sm25193224pfh.150.2018.02.27.10.21.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 10:21:43 -0800 (PST) Date: Tue, 27 Feb 2018 10:21:43 -0800 (PST) X-Google-Original-Date: Tue, 27 Feb 2018 08:53:31 PST (-0800) Subject: Re: [PATCH] riscv/barrier: Define __smp_{store_release,load_acquire} In-Reply-To: <1519698251-19272-1-git-send-email-parri.andrea@gmail.com> CC: albert@sifive.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, parri.andrea@gmail.com From: Palmer Dabbelt To: parri.andrea@gmail.com, Daniel Lustig Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks!