Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp486067ybt; Wed, 1 Jul 2020 03:20:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz82S1ogs/YpmBCi2uqBb7BFNXaKGuKiwlHHcKzGSmsnRvwX8EAdcVtTsUgwJGMHRF4KEeI X-Received: by 2002:a17:906:915:: with SMTP id i21mr22574092ejd.313.1593598844592; Wed, 01 Jul 2020 03:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593598844; cv=none; d=google.com; s=arc-20160816; b=ewEhAKCcz3AZ4CRecaaMWoRIDDqDD3TaMJLMaKIxa3gf2QEYABrONv4Upv4lhKIwZ1 IY87fCp18mBlIDuTQ/UytJfz58NUHEgiuf6gwE7jncA5zQKQGMHD1Lwy8fB2BLdoj3Bh eYtM2luSKaZrfCnJG5TRK1A6FvsFoRUg6RkhxofRTE29s+sl7Vdu9bo90PnjrVvCWZGR hnaw5KiGj0VpRrTT7Zv0n6Caa8BDPSpZwHD+d4wVxMBJ6SHLyDj7triMqHkLGJS5aXwv K65/3CtbqqH/Ogc+IL1mWdvwj0+AOYea5KTxLREXH/oo4rMehuVZkComdiES6j1n84z/ wcHg== 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:dkim-signature; bh=3mSiBHSptoo0Vi0ShqXKZpb5VPisDVdy+4v1fSPg4kg=; b=F/U8XxywqsSI90y31CQ4CGFedfxgg9VndTYDIqD2nAyEU7X8bKnQf0Yn5lN0BNpLYx tCnIyEIJwgne+C98fMwE3ayy1wHg02Y1wUqoOlh9+xpZG+gYbOlH5t+KLWyClb+W2VuA m8T9LMhxuur3uFZ3/xjQalvvtf5Q/1/uDVSdS6w76eA57b3Lk/NTORZyo+ocSA6g6xH2 4FgBp+mfBJiBWxJfP4RB87c9qqKA1b8pvvOjjiFvl1lU9+w5TyYGIkP1/0uA+/UAkqGI z9x1Cxza32wXRAXKrJQ8e65e004XTjUxR273l1dHdYZJDKSaH6Sr3v+YVt+3ON2GF5i3 aaCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XMtZZ1Da; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v21si3457728edw.286.2020.07.01.03.20.20; Wed, 01 Jul 2020 03:20:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XMtZZ1Da; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729834AbgGAKTr (ORCPT + 99 others); Wed, 1 Jul 2020 06:19:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:42302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729887AbgGAKTi (ORCPT ); Wed, 1 Jul 2020 06:19:38 -0400 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 DD328206B6; Wed, 1 Jul 2020 10:19:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593598769; bh=9Kej8N7/444vyXQnl8/ioGdJ8CvpVggYRN8p0S6A3hA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XMtZZ1DarIqro0ULGuCiTjSVyJcESurJDaZsh5CFvc6CBXTm3pedcUVJFRlirmjlr 92x2fLcppQnSp5oM9ELuhyJpmszSzZJYg4gVTVdrHIX069eolAhFnwXqU1AJ25irZh XNHpUTaw9KdSfGins0gbmJvLeNQsCViZVDBnjSYk= Date: Wed, 1 Jul 2020 11:19:23 +0100 From: Will Deacon To: Arnd Bergmann Cc: "linux-kernel@vger.kernel.org" , Sami Tolvanen , Nick Desaulniers , Kees Cook , Marco Elver , "Paul E. McKenney" , Josh Triplett , Matt Turner , Ivan Kokshaysky , Richard Henderson , Peter Zijlstra , Alan Stern , "Michael S. Tsirkin" , Jason Wang , Boqun Feng , Catalin Marinas , Mark Rutland , Linux ARM , alpha , virtualization@lists.linux-foundation.org, Android Kernel Team Subject: Re: [PATCH 18/18] arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y Message-ID: <20200701101922.GC14959@willie-the-truck> References: <20200630173734.14057-1-will@kernel.org> <20200630173734.14057-19-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 30, 2020 at 09:25:03PM +0200, Arnd Bergmann wrote: > On Tue, Jun 30, 2020 at 7:39 PM Will Deacon wrote: > > +#define __READ_ONCE(x) \ > > +({ \ > > + int atomic = 1; \ > > + union { __unqual_scalar_typeof(x) __val; char __c[1]; } __u; \ > > + typeof(&(x)) __x = &(x); \ > > + switch (sizeof(x)) { \ > ... > > + atomic ? (typeof(x))__u.__val : (*(volatile typeof(x) *)__x); \ > > +}) > > This expands (x) nine times (five in __unqual_scala_typeof()), which can > lead to significant code bloat after preprocessing if something passes a > compound expression into READ_ONCE(). > The compiler works it out eventually, but we've seen an actual slowdown > in compile speed from this recently, especially on clang. > > I think if you move the > > typeof(&(x)) __x = &(x); > > line first, all other instances can use typeof(*__x) instead of typeof(x) > and avoid this problem. Cheers, I was only thinking about side-effects when I wrote this, but bloating built time is very unpopular, so I'll go with your suggestion. > Once we make gcc-4.9 the minimum version, > this could be further improved to > > __auto_type __x = &(x); Is anybody working on moving to 4.9? I've seen the mails from Linus championing it, but I thought there was a RHEL in support that people might care about? Will