Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp382337ybt; Mon, 6 Jul 2020 11:36:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwofsK3OaAZXheYdtpDRvZ5/I30SJxeN8yvvjGqcphf+9VN2PSuJD4ipPMYcF/cvTB0ZDQN X-Received: by 2002:a17:906:940f:: with SMTP id q15mr45452524ejx.470.1594060597396; Mon, 06 Jul 2020 11:36:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594060597; cv=none; d=google.com; s=arc-20160816; b=E+KqFouFRoumvYa7l9YewIT0+ARwJAUzKD5sQLsYf98+I1QI4npS07DSDJPGuK2G9Q klDEgMP55VfZi73BMm35/1BITSiC3PjbEKdSJCxtn/GWkKwP5Xed/QhPqwWNOwm20fUB daU33+ZsoIb3diOP7R5yLK1Oj72KJ+2x5wt0k8bVMfc5g/3txOZBjy29IH6VejPkU6Xx 2AmfvSv0QveGtBJAmPF3XO2Y7jl4yKCnPtnGiNy6/I/ZMu6eiKxhl7v1ZcPtX7HeSMJt xbt4ltUWWfSP+9XH8vgnqyyOs9Ob+waKs+HhWbYhrg+NJVNpZ/LTnHgPNTXugai3EOoT /vnw== 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=qGfkttNxoQeh5NEThF5l3CSkGR1PV0GvXJgmsVq7GuU=; b=PekvdVUTFw2KaZxoi9DuZlBU81Zx4y5UE8qdIUugqwq0WMkjyX0LAlbXp/PGmfChoS 20zcxpolcV1gtRQJIcETfyo2os3vcpvcA2mz62lanlSdr2RrvLY/TehONoA76vteiJkx aKCzZ+U/IaiMGoG30Fboz0YyggISRN+jGPU6mn87pLuMYE6OqFv4oQhRE1L53suN6wu+ GXaj5DzHF/TlxRqzfVqEpwSgUMdBOL2Hlhh8i1f3WinzYiCxEeRsEny+Zs64W8npp56x 4gJGYJOujzQJbYNMSrqRKMoStfKjY5Dgbzf3PtPPkXh2IIz+zmqE7NOq6ARZOIhkJRki zd0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VujbM6QU; 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 w18si6454058eds.406.2020.07.06.11.36.14; Mon, 06 Jul 2020 11:36:37 -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=VujbM6QU; 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 S1729805AbgGFSfu (ORCPT + 99 others); Mon, 6 Jul 2020 14:35:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:38032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729713AbgGFSfu (ORCPT ); Mon, 6 Jul 2020 14:35:50 -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 007982064C; Mon, 6 Jul 2020 18:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594060549; bh=QElTtoqqXckuhA9BZOgcYSdLXXIBOg7PR5IagnhwDho=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VujbM6QUizcvQdgwE+TRzHSqSJ0FHj+o1kzk/zYc4jni+539xqlVorsw42yU86v/1 fj31wKt7x318hyaDbrCvT9nj6jWUPko7rLCC9SURvyoUSijZsWNZD5QNo9NlOaG4ib xdY1aWUQF/pAYNyJsZqgjV6qCWWfW3H+OZPzglKM= Date: Mon, 6 Jul 2020 19:35:43 +0100 From: Will Deacon To: Dave Martin Cc: Mark Rutland , "Michael S. Tsirkin" , Peter Zijlstra , Catalin Marinas , Jason Wang , virtualization@lists.linux-foundation.org, Arnd Bergmann , Alan Stern , Sami Tolvanen , Matt Turner , kernel-team@android.com, Marco Elver , Kees Cook , "Paul E. McKenney" , Boqun Feng , Josh Triplett , Ivan Kokshaysky , linux-arm-kernel@lists.infradead.org, Richard Henderson , Nick Desaulniers , linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org Subject: Re: [PATCH 18/18] arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y Message-ID: <20200706183542.GB23766@willie-the-truck> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200706160023.GB10992@arm.com> 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 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. Will