From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9460FC433ED for ; Mon, 20 Jul 2020 15:56:34 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 645782176B for ; Mon, 20 Jul 2020 15:56:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="er9RK2nX"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="a5D8vvsd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 645782176B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/TlD6+Fugsm3DPIXZz/WV2liRiQxTgekW6Qa1KPLJdw=; b=er9RK2nXZjRFEaeYUJaQgEPSB XTV4djRTQ4Oo6GxEtzmq6fiEtfsQpIftza1bmVC766keUndHDFsLNVgshSjRAJD9KLIPo5pSKKlGY SSsAgu/Bjh2vpfgr8HRW4o847hE0pZNr4RhQQvmwhUHaH/sdMLlOJzxG0hbdwZddL9S4qNaCOQNst d3D4DSXqw2z9aIiMTnV+CDaBjB2mJsUtjKPBBTXcclDikR898b5kL9Or1r/KkZdg4mCW+92cG5tNW 6p3fPLPvmNTsZ0RfKOT9l7rGimuPknJSaYDCinrYKDV6EFO6zFUF/GhYwn2s6WoV4g6RebvPf9QwG N/h9XXicg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxY8G-00063Q-M0; Mon, 20 Jul 2020 15:55:12 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxY8D-00061n-9j for linux-arm-kernel@lists.infradead.org; Mon, 20 Jul 2020 15:55:10 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0960B22BEF; Mon, 20 Jul 2020 15:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595260508; bh=CPfkp2QBSP3gKifkBSkUyRSWEi+JHbUnJ+ZB0izj7DY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=a5D8vvsdPtuyNYv8qE1jt1t3R9hwgKBR8Ede9nALJ4GZh3UC88Nws0YRzwzNNeorI I6F07W869uTS3luWta0bx2aHQA6vGJ8h5e5sxVfXxpGZN+kyk/pEq36G0rCjq/iKmZ /FYTeONkLgSEhZ5hG4MefWUaAVfzMFvXZKz/EBg0= Date: Mon, 20 Jul 2020 16:55:02 +0100 From: Will Deacon To: boqun.feng@gmail.com Subject: Re: [PATCH v3 02/19] compiler.h: Split {READ, WRITE}_ONCE definitions out into rwonce.h Message-ID: <20200720155501.GA12064@willie-the-truck> References: <20200710165203.31284-1-will@kernel.org> <20200710165203.31284-3-will@kernel.org> <20200713122322.GD72639@debian-boqun.qqnc3lrjykvubdpftowmye0fmh.lx.internal.cloudapp.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200713122322.GD72639@debian-boqun.qqnc3lrjykvubdpftowmye0fmh.lx.internal.cloudapp.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200720_115509_530146_AB767D1C X-CRM114-Status: GOOD ( 23.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joel Fernandes , Mark Rutland , Marco Elver , Kees Cook , "Paul E. McKenney" , "Michael S. Tsirkin" , Peter Zijlstra , Catalin Marinas , Jason Wang , Nick Desaulniers , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Ivan Kokshaysky , linux-arm-kernel@lists.infradead.org, Sami Tolvanen , linux-alpha@vger.kernel.org, Alan Stern , Matt Turner , kernel-team@android.com, Arnd Bergmann , Richard Henderson Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jul 13, 2020 at 08:23:22PM +0800, boqun.feng@gmail.com wrote: > On Fri, Jul 10, 2020 at 05:51:46PM +0100, Will Deacon wrote: > > diff --git a/include/asm-generic/rwonce.h b/include/asm-generic/rwonce.h > > new file mode 100644 > > index 000000000000..92cc2f223cb3 > > --- /dev/null > > +++ b/include/asm-generic/rwonce.h > > @@ -0,0 +1,91 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +/* > > + * Prevent the compiler from merging or refetching reads or writes. The > > + * compiler is also forbidden from reordering successive instances of > > + * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some > > + * particular ordering. One way to make the compiler aware of ordering is to > > + * put the two invocations of READ_ONCE or WRITE_ONCE in different C > > + * statements. > > + * > > + * These two macros will also work on aggregate data types like structs or > > + * unions. > > + * > > + * Their two major use cases are: (1) Mediating communication between > > + * process-level code and irq/NMI handlers, all running on the same CPU, > > + * and (2) Ensuring that the compiler does not fold, spindle, or otherwise > > + * mutilate accesses that either do not require ordering or that interact > > + * with an explicit memory barrier or atomic instruction that provides the > > + * required ordering. > > + */ > > +#ifndef __ASM_GENERIC_RWONCE_H > > +#define __ASM_GENERIC_RWONCE_H > > + > > +#ifndef __ASSEMBLY__ > > + > > +#include > > +#include > > +#include > > + > > +#include > > + > > +/* > > + * Use __READ_ONCE() instead of READ_ONCE() if you do not require any > > + * atomicity or dependency ordering guarantees. Note that this may result > > + * in tears! > > + */ > > +#define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) > > + > > +#define __READ_ONCE_SCALAR(x) \ > > +({ \ > > + __unqual_scalar_typeof(x) __x = __READ_ONCE(x); \ > > + smp_read_barrier_depends(); \ > > + (typeof(x))__x; \ > > +}) > > + > > +#define READ_ONCE(x) \ > > +({ \ > > + compiletime_assert_rwonce_type(x); \ > > Does it make sense if we also move the definition of this compile time > assertion into rwonce.h too? Yes, that looks straightforward enough. Thanks for the suggestion! I'll also try to get this lot into -next this week. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel