From mboxrd@z Thu Jan 1 00:00:00 1970 From: Will Deacon Subject: Re: [PATCH 18/18] arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y Date: Wed, 1 Jul 2020 11:19:23 +0100 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-Transfer-Encoding: 7bit Return-path: 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= Content-Disposition: inline In-Reply-To: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" To: Arnd Bergmann Cc: Mark Rutland , Marco Elver , Kees Cook , "Paul E. McKenney" , "Michael S. Tsirkin" , Peter Zijlstra , Catalin Marinas , Nick Desaulniers , "linux-kernel@vger.kernel.org" , Josh Triplett , Ivan Kokshaysky , Sami Tolvanen , alpha , Alan Stern , Matt Turner , virtualization@lists.linux-foundation.org, Android Kernel Team , Boqun Feng , Linux ARM , Richard Henderson 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