Received: by 10.213.65.68 with SMTP id h4csp3014840imn; Mon, 9 Apr 2018 12:45:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx48+VBxBlZueh+ZcVay3e10vNHYFbmIQJ3R8M2BRphPY2/ynKOYQSUZYhgrMd5y8FNDsVq9p X-Received: by 2002:a17:902:6184:: with SMTP id u4-v6mr41166116plj.390.1523303101595; Mon, 09 Apr 2018 12:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523303101; cv=none; d=google.com; s=arc-20160816; b=I/OpzMscXjiB/yZT5wT7qd53lOKTB1fvaHyMQaOl/5Uj6ylhpClTbb0v2hn/O8hs84 gmFl6lNT43SEbvpyi5KGRUtpeSJomgakY5fS9wn7VwWLV/JUTrN1/y3uBl/40D6dZ77u GCxWBAZRdz9DXCNjiq5QPcORy2g9mPCFJcV8WuTKtEiNAv7WJcapQwJKPMPVtCWN9CXT p3+ZnOORX7UaQNk0wxHnM5ifS4LSaJ4HB9POwqM6/ezpM9N8C3+LeeA42A7ln/Hz1f9L DDYn7BlnQV+SvioET3sS1zNeylqGPv9C8mmudxAV+qPNsYdMRHCYjroF1+dWtc9pBbAz V4LA== 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:arc-authentication-results; bh=K7N2ysBq7WXWqu2B6mAaSebSFEsNIEj95b2bWwQ4bws=; b=idS9D430nzhTA3l5KnYJ8l1AuemYIinNjyeom1wNOfyf7rml59EtMK2CsVUJYVaNrB aNwdFJcLVRqd6PJmgQeBEFMYxa0rMF7ESuA302E9kupSNN9SKuygx+C5DTfbSb/tRZrL utXFi3j8kSwXslVfE/AcMbx67e4VCvmlk3AcX/v3ikh4TL1hd5xzU1+Cd6jVzjN3Ng1c edbUOYxEmt19b7Ia30Fx2h5iGvyGpECxXtwJONBexBzMkP3RswvTRD+seStyeYDT/S91 6lc+TZY9+NsS2Tut0jtKNBcBMP5zxZq98tIbVxccNYyiT7GPLxgT0fHZXk1rrkZ/Oi1y AvyA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d16-v6si894616pll.214.2018.04.09.12.44.24; Mon, 09 Apr 2018 12:45:01 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754418AbeDITkk (ORCPT + 99 others); Mon, 9 Apr 2018 15:40:40 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46470 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754312AbeDITkh (ORCPT ); Mon, 9 Apr 2018 15:40:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A9B834072440; Mon, 9 Apr 2018 19:40:36 +0000 (UTC) Received: from sandy.ghostprotocols.net (ovpn-112-5.gru2.redhat.com [10.97.112.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B95416791; Mon, 9 Apr 2018 19:40:35 +0000 (UTC) Received: by sandy.ghostprotocols.net (Postfix, from userid 1000) id A5BC049EF; Mon, 9 Apr 2018 16:40:32 -0300 (BRT) Date: Mon, 9 Apr 2018 16:40:32 -0300 From: Arnaldo Carvalho de Melo To: Mark Rutland Cc: linux-kernel@vger.kernel.org, lizhijian@cn.fujitsu.com, sandipan@linux.vnet.ibm.com Subject: Re: [PATCH] tools: restore READ_ONCE() C++ compatibility Message-ID: <20180409194032.GA7184@redhat.com> References: <20180404163445.16492-1-mark.rutland@arm.com> <20180409171041.6qfabrccsqu4bdlc@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180409171041.6qfabrccsqu4bdlc@lakrids.cambridge.arm.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.20 (2009-12-10) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 09 Apr 2018 19:40:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 09 Apr 2018 19:40:36 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'acme@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Apr 09, 2018 at 06:10:41PM +0100, Mark Rutland escreveu: > Hi Arnaldo, > > As Sandipan gave a Tested-by for this, are you happy to pick it up as a > fix for v4.17? > > Or would you prefer that I resend this? I forgot about this fix, but was exposed to it while processing Sandipan's patches for fixing up builtin clang support, so I ended up adding the following patch: https://git.kernel.org/acme/c/ad0902e0c400 This sidesteps this issue by removing the sequence of includes that ends up including the compiler.h from a C++ file. Now 'make LIBCLANGLLVM=1 -C tools/perf' works, but I'll look at the patch below, probably it will save some time in the future if we get to include compiler.h from C++ code again... Take a look at my perf/urgent branch, that I just asked Ingo to pull. - Arnaldo > Thanks, > Mark. > > On Wed, Apr 04, 2018 at 05:34:45PM +0100, Mark Rutland wrote: > > Our userspace defines READ_ONCE() in a way that clang > > doesn't like, as we have an anonymous union in which neither field is > > initialized. > > > > WRITE_ONCE() is fine since it initializes the __val field. For > > READ_ONCE() we can keep clang and GCC happy with a dummy initialization > > of the __c field, so let's do that. > > > > At the same time, let's split READ_ONCE() and WRITE_ONCE() over several > > lines for legibility, as we do in the in-kernel . > > > > Signed-off-by: Mark Rutland > > Fixes: 6aa7de059173a986 ("locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE()") > > Reported-by: Li Zhijian > > Reported-by: Sandipan Das > > Cc: Arnaldo Carvalho de Melo > > --- > > tools/include/linux/compiler.h | 20 +++++++++++++++----- > > 1 file changed, 15 insertions(+), 5 deletions(-) > > > > Hi, > > > > This is fallout from my automated ACCESS_ONCE() removal, and I'm not that > > familiar with using clang for perf. > > > > In local testing, this fixes READ_ONCE() when compiling with clang, but I > > subsequently hit some other issues which I believe are down to LLVM API > > changes. > > > > Zhijian, Sandipan, does this patch work for you? > > > > Thanks, > > Mark. > > > > diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h > > index 04e32f965ad7..1827c2f973f9 100644 > > --- a/tools/include/linux/compiler.h > > +++ b/tools/include/linux/compiler.h > > @@ -151,11 +151,21 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s > > * required ordering. > > */ > > > > -#define READ_ONCE(x) \ > > - ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) > > - > > -#define WRITE_ONCE(x, val) \ > > - ({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; __write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) > > +#define READ_ONCE(x) \ > > +({ \ > > + union { typeof(x) __val; char __c[1]; } __u = \ > > + { .__c = { 0 } }; \ > > + __read_once_size(&(x), __u.__c, sizeof(x)); \ > > + __u.__val; \ > > +}) > > + > > +#define WRITE_ONCE(x, val) \ > > +({ \ > > + union { typeof(x) __val; char __c[1]; } __u = \ > > + { .__val = (val) }; \ > > + __write_once_size(&(x), __u.__c, sizeof(x)); \ > > + __u.__val; \ > > +}) > > > > > > #ifndef __fallthrough > > -- > > 2.11.0 > >