Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp286457ybi; Fri, 24 May 2019 03:56:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrZDxP2BpFjTpjnvS505urb+eMafpRdi3+9nJI7rSjp/asVu+uoARCv8wop6CEGCeXLuZf X-Received: by 2002:a17:90a:e390:: with SMTP id b16mr7971221pjz.137.1558695369070; Fri, 24 May 2019 03:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558695369; cv=none; d=google.com; s=arc-20160816; b=DqQn5zetpGc9vIkAKmi2lxB0uzubTClY5DycMvpIRH+0VPZEUrCeBcsbMmETKEANoZ /TCkQlSqcDuaSHraxiT2IT0e3Q4Gbku5UU+FV0AjVq9jKXTAmrlX4JpWI8iAP6Kja6h2 e2BNVNo45oYbYPzevzVH/0jU2gXPCOSqRkYWJTacye079GMFRaMdeIuC7Jg5CaysDof1 TPAdgTwZI5ojz8Nxlx4vSZGPt1G/fCqmu1ozVq0zFEZRlBBW3IaWp5QqGtijpteZyO/V hmCWfThZ7NX02AhFtVLeGJ7QxH4ShZGxulehmL6Bji/6F80yXotQIJ6siyuXWWFRRKLQ yNjw== 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; bh=Xv1sQFMGEkbpAgub4xUEP+MbkyHVou9+ZSYeHYk1514=; b=xgA5UuahGnEGi1fEFoMgnPyXiz81FoHRO7u7PZYUv28cGFlER3/akoyCpk708JkBVE L7rGAYi1kcgAlTYtN+Z7Ml2KulPTtw3UgNMpHqtItvhRGexYTA62GK6bd+M6/iGshbzX IgAGj79SNRawoAN5b0ZckwBZenvOhArb53c9f/+9gaHklqO/90ZkG1u9LEf5iEUedNQ6 AZ87ukipJoM+lJ/k1mpcnej5DO5Bvmgece5qhz95zKB+r2Die+4INuHDoBNLM+qt/FwZ TZwhPoAX0dBGOM4h13pQbWHSmWET4VMF0UMi9jHTN+VrXR9K4cpyLIQiiP2cXYT2XuFL cZnA== 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 92si3556630plw.163.2019.05.24.03.55.54; Fri, 24 May 2019 03:56:09 -0700 (PDT) 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 S2390578AbfEXKxp (ORCPT + 99 others); Fri, 24 May 2019 06:53:45 -0400 Received: from foss.arm.com ([217.140.101.70]:40106 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390459AbfEXKxp (ORCPT ); Fri, 24 May 2019 06:53:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 427CE374; Fri, 24 May 2019 03:53:44 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BC7B83F703; Fri, 24 May 2019 03:53:42 -0700 (PDT) Date: Fri, 24 May 2019 11:53:40 +0100 From: Mark Rutland To: Andrea Parri Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Greg Kroah-Hartman , Jorgen Hansen , Peter Zijlstra , Will Deacon , "Paul E. McKenney" Subject: Re: [PATCH 2/2] compiler: Prevent evaluation of WRITE_ONCE() Message-ID: <20190524105339.GC12796@lakrids.cambridge.arm.com> References: <1558694136-19226-1-git-send-email-andrea.parri@amarulasolutions.com> <1558694136-19226-3-git-send-email-andrea.parri@amarulasolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1558694136-19226-3-git-send-email-andrea.parri@amarulasolutions.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This would be better titled as: compiler: don't return a value from WRITE_ONCE() ... since we do want the WRITE_ONCE() itself to be evaluated. On Fri, May 24, 2019 at 12:35:36PM +0200, Andrea Parri wrote: > Now that there's no single use of the value of WRITE_ONCE(), change > the implementation to eliminate it. I hope that's the case, but it's possible that some macros might be relying on this, so it's probably worth waiting to see if the kbuild test robot screams. Otherwise, I agree that WRITE_ONCE() returning a value is surprising, and unnecessary. IIRC you said that trying to suport that in other implementations was painful, so aligning on a non-returning version sounds reasonable to me. > > Suggested-by: Mark Rutland > Signed-off-by: Andrea Parri > Cc: Arnd Bergmann > Cc: Greg Kroah-Hartman > Cc: Jorgen Hansen > Cc: Peter Zijlstra > Cc: Will Deacon > Cc: Mark Rutland > Cc: "Paul E. McKenney" > --- > include/linux/compiler.h | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/include/linux/compiler.h b/include/linux/compiler.h > index 8aaf7cd026b06..4024c809a6c63 100644 > --- a/include/linux/compiler.h > +++ b/include/linux/compiler.h > @@ -277,12 +277,11 @@ unsigned long read_word_at_a_time(const void *addr) > } > > #define WRITE_ONCE(x, val) \ > -({ \ > +do { \ > union { typeof(x) __val; char __c[1]; } __u = \ > { .__val = (__force typeof(x)) (val) }; \ > __write_once_size(&(x), __u.__c, sizeof(x)); \ > - __u.__val; \ > -}) > +} while (0) With the title fixed, and assuming that the kbuild test robot doesn't find uses we've missed: Acked-by: Mark Rutland Thanks, Mark. > > #endif /* __KERNEL__ */ > > -- > 2.7.4 >