Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp424960ybt; Mon, 6 Jul 2020 12:43:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSxu6URd0XPMksWl6V5ncULzgDdHkOGv6QGaXNtPxkKkuy6VaW1FP3GavfSdw8GJiE8kSk X-Received: by 2002:a17:906:b16:: with SMTP id u22mr19643794ejg.53.1594064599496; Mon, 06 Jul 2020 12:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594064599; cv=none; d=google.com; s=arc-20160816; b=sFzKPKYg5llDzlIqOJiivZL7sTC8IXU+x6iaQUPDwqIH3LNQnmyESXtH9cezN27uyP PVgvlQN2si9FQ/9gt7YFmmrofL0ll4BnECH8d3bT4elxPvlpG5GCve4LHPXJYoIZX/mO E2fs5GK8lrEoInQ1GuS9iKqg6wtouVgIg0CxxovvsEyTN9hPsRz5a2tT4x96ENTQUDyk 8bBsn51mF+t7BuESLeGWDTHoo5AghgwlcALpfuJpoYnjWGfXfKrzLnmfA1kD5rJLzVXJ 9fabRFI0EGNgm4cUamdF4J5Ud9UmEhBNfLqc+csVuP6FohiNIkOCje2l5AQwOnkd9kru Okdw== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=+k6FPtPDe7rtiiMNsNvxCYKKa0+YgfB5gXUrx5vMtJs=; b=U9ETlC1DI7WXz9ZeR5seOCm3B4Oq2AKALFcZilJzisvLCrMELWO5VIrwDQZTTEtUgi bm8W5j/7niOWeBdu5tZLLE9Bth1bSIpwP3Q0pIDbvwzTXOvpL7wZUcdkywrZvQOyVnX7 uVfT/TyiYXj8w8UL2s6jscpxzCAo8LJDPDxgy40LOn/Q1dF8h2xnkKIzY5wDt0rSdEbD p8VnxUn4RUOyOsJtmvLxbhb1IhKhVshFtnkQ0AE6x2g3e/EsBGX+NGZqh4Wy18Tj43I9 +YzFR6DOksjt0+FVg7+Lxlul16RpUPcakw3lr2Murz3eEbdZRPAmK3APTPmzedkkS8Aq GENg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lh3vxVKB; 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 d3si15703543edn.145.2020.07.06.12.42.57; Mon, 06 Jul 2020 12:43:19 -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=lh3vxVKB; 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 S1726889AbgGFTmk (ORCPT + 99 others); Mon, 6 Jul 2020 15:42:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:59306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726661AbgGFTmh (ORCPT ); Mon, 6 Jul 2020 15:42:37 -0400 Received: from paulmck-ThinkPad-P72.home (50-39-111-31.bvtn.or.frontiernet.net [50.39.111.31]) (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 2E08120675; Mon, 6 Jul 2020 19:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594064557; bh=gq8OONsZv2DL9Wl2RlB9KVkvm70QuCx2mh8QqqjtMbI=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=lh3vxVKBCu2a1xT47mTYziII5iB0/8GAkDAt71DAfoKVDSx6FVqCJSq59QVsEGSnP Q60Pvq90qvfChKmNKQJkCuTpUGESomfnWfhOoPesvmXeSdfBqBsiWX1GemxQCisw41 x0SD+lBBhKrCWfQ4CGoMu0RtilR1klMo8qmHvImM= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 181CE3522637; Mon, 6 Jul 2020 12:42:37 -0700 (PDT) Date: Mon, 6 Jul 2020 12:42:37 -0700 From: "Paul E. McKenney" To: Marco Elver Cc: Will Deacon , Dave Martin , Mark Rutland , "Michael S. Tsirkin" , Peter Zijlstra , Catalin Marinas , Jason Wang , virtualization@lists.linux-foundation.org, Arnd Bergmann , Alan Stern , Sami Tolvanen , Matt Turner , Android Kernel Team , Kees Cook , Boqun Feng , Josh Triplett , Ivan Kokshaysky , Linux ARM , Richard Henderson , Nick Desaulniers , LKML , linux-alpha@vger.kernel.org Subject: Re: [PATCH 18/18] arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y Message-ID: <20200706194237.GF9247@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200630173734.14057-1-will@kernel.org> <20200630173734.14057-19-will@kernel.org> <20200701170722.4rte5ssnmrn2uqzg@bakewell.cambridge.arm.com> <20200702072301.GA15963@willie-the-truck> <20200706160023.GB10992@arm.com> <20200706183542.GB23766@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 06, 2020 at 09:23:26PM +0200, Marco Elver wrote: > On Mon, 6 Jul 2020 at 20:35, Will Deacon wrote: > > On Mon, Jul 06, 2020 at 05:00:23PM +0100, Dave Martin wrote: > > > On Thu, Jul 02, 2020 at 08:23:02AM +0100, Will Deacon wrote: > > > > On Wed, Jul 01, 2020 at 06:07:25PM +0100, Dave P Martin wrote: > > > > > Also, can you illustrate code that can only be unsafe with Clang LTO? > > > > > > > > I don't have a concrete example, but it's an ongoing concern over on the LTO > > > > thread [1], so I cooked this to show one way we could deal with it. The main > > > > concern is that the whole-program optimisations enabled by LTO may allow the > > > > compiler to enumerate possible values for a pointer at link time and replace > > > > an address dependency between two loads with a control dependency instead, > > > > defeating the dependency ordering within the CPU. > > > > > > Why can't that happen without LTO? > > > > It could, but I'd argue that it's considerably less likely because there > > is less information available to the compiler to perform these sorts of > > optimisations. It also doesn't appear to be happening in practice. > > > > The current state of affairs is that, if/when we catch the compiler > > performing harmful optimistations, we look for a way to disable them. > > However, there are good reasons to enable LTO, so this is one way to > > do that without having to worry about the potential impact on dependency > > ordering. > > If it's of any help, I'll see if we can implement that warning in LLVM > if data dependencies somehow disappear (although I don't have any > cycles to pursue right now myself). Until then, short of manual > inspection or encountering a bug in the wild, there is no proof any of > this happens or doesn't happen. > > Also, as some anecdotal evidence it's extremely unlikely, even with > LTO: looking at the passes that LLVM runs, there are a number of > passes that seem to want to eliminate basic blocks, thereby getting > rid of branches. Intuitively, it makes sense, because branches are > expensive on most architectures (for GPU targets, I think it tries > even harder to get rid of branches). If we extend our reasoning and > assumptions of LTO's aggressiveness in that direction, we might > actually end up with fewer branches. That might be beneficial for the > data dependencies we worry about (but not so much for control > dependencies we want to keep). Still, no point in speculating (no pun > intended) until we have hard data what actually happens. :-) Anything along these lines would be very welcome!!! Thanx, Paul