Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8575159ybn; Tue, 1 Oct 2019 10:02:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzybbfVVxU2BDVP2eSsc+AETg5mHgu61et4FjU1+Q6nPD/7tdzKTEXA95u1v5FSbzM8bAAr X-Received: by 2002:a17:906:3746:: with SMTP id e6mr24406144ejc.238.1569949349014; Tue, 01 Oct 2019 10:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569949349; cv=none; d=google.com; s=arc-20160816; b=bxN3z4ox7O7c7JyBnJyb0cUP9A4qQ5bXbXBnoPqrxdM2bOcU7x1xfHHKyMmy1hcjiw c4gXP6crK3ynEciHeRtkvwM+xJgK4QfjwOy6h5+HorzZ3g3/hqKOy0XuGbroUtP1aCuZ BHsTVdODI3AzzyHD49sTLTZhQWqCDtHaMvcUw0ADg6+wPHYH5KZ7w+lSIizBd8JL42VE HJr1iEg6Vt0SYQFwcmJnFPoIUMKqJB6vvQR80tO8H/QIccz2rB/XTEVpkIWkF3ujI6yq cKXdjfvOagnYsLlBFiZnwpmQlr80vK0S9SeXhuwi6RTHz/EYpLYloZMoONrpmsorrGhK QsQg== 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=sbs4ARk1IFnOm2FQ09L4tRS3UDXzfbcE1hQYfeFzYOY=; b=UUxxOHXKJxpaPXoG9CN6Jldn39KwqFTjt5jbs3qAyUCvroZxyKG40OFwqMTmzvyRq7 Byonxe3WpVpWCTXfsR5BY9L8eieG714bIbv+zIkGi92+X+IFKTDmdkx5hWeLTOCc39Go nVzp7gNq2evrM/0NAUY1oZfgLhMNFutf/yNQAJa5siHlT8YUiwMsWpU4zCT0hDUf5UWk KlJpbbcYLwY15iD/8b/gjIVzwtp0jh7htBkuS4ajQFV0Ls2biWgUjemMGwmmVOOi95dJ vKJZ4F3/zpM7dvmTR/ZGdEFynu9Yxm+iBgJ3+P4xwleen7tnTMgrIYoT3Ox9KvdlIinY 3exg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yaOg32kj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e21si9525246edb.164.2019.10.01.10.01.59; Tue, 01 Oct 2019 10:02:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b=yaOg32kj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731503AbfJARBx (ORCPT + 99 others); Tue, 1 Oct 2019 13:01:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:43210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729317AbfJARBu (ORCPT ); Tue, 1 Oct 2019 13:01: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 71D082054F; Tue, 1 Oct 2019 17:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569949308; bh=bJnGJ3RhjW/8aLO07qPZQmJNbpODR84+mvK448XA88o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=yaOg32kjz9hD653NvILZdRQ7X/HdYptJmBc184vQlyHSvp23BmDSe5R8zcFK9i0hE qw+CdI6NHge3cdjg2NYe1TegjwR7ZTfcmqezNpCBsNxmpCQ//W7UMwX3qgDgVsOAbK ID0YrKYPlGuec6Xu+XKji1EYG4cwCBfmgTBjbRjw= Date: Tue, 1 Oct 2019 18:01:43 +0100 From: Will Deacon To: Nick Desaulniers Cc: Masahiro Yamada , Linus Torvalds , Nicolas Saenz Julienne , Andrew Morton , Ingo Molnar , Borislav Petkov , Miguel Ojeda , linux-arch , LKML , Catalin Marinas , Russell King , Stefan Wahren , Kees Cook Subject: Re: [PATCH] compiler: enable CONFIG_OPTIMIZE_INLINING forcibly Message-ID: <20191001170142.x66orounxuln7zs3@willie-the-truck> References: <20190830034304.24259-1-yamada.masahiro@socionext.com> <20190930112636.vx2qxo4hdysvxibl@willie-the-truck> <20190930121803.n34i63scet2ec7ll@willie-the-truck> <20191001092823.z4zhlbwvtwnlotwc@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 01, 2019 at 09:32:25AM -0700, Nick Desaulniers wrote: > On Tue, Oct 1, 2019 at 2:28 AM Will Deacon wrote: > > On Mon, Sep 30, 2019 at 02:50:10PM -0700, Nick Desaulniers wrote: > > > In this case, if there's a known codegen bug in a particular compiler > > > or certain versions of it, I recommend the use of either the C > > > preprocessor or __attribute__((no_inline)) to get the desired behavior > > > localized to the function in question, and for us to proceed with > > > Masahiro's cleanup. > > > > Hmm, I don't see how that would help. The problem occurs when things > > are moved out of line by the compiler (see below). > > It's being moved out of line because __attribute__((always_inline)) or > just inline provide no guarantees that outlining does not occur. It > would help to make functions that need to be inlined macros, because > the C preprocessor doesn't have that issue. Hmm, let me try to put it another way: enabling CONFIG_OPTIMIZE_INLINING has been shown to cause miscompilation with many versions of GCC on arm64 because the compiler moves things out of line that it otherwise doesn't appear to do. I don't see how __attribute__((no_inline)) helps with that, and replacing static functions with macros isn't great for type-checking and argument evaluation. > > > The comment above the use of CONFIG_OPTIMIZE_INLINING in > > > include/linux/compiler_types.h says: > > > * Force always-inline if the user requests it so via the .config. > > > Which makes me grimace (__attribute__((always_inline)) doesn't *force* > > > anything as per above), and the idea that forcing things marked inline > > > to also be __attribute__((always_inline)) is an "optimization" (re: > > > the name of the config; CONFIG_OPTIMIZE_INLINING) is also highly > > > suspect. Aggressive inlining leads to image size bloat, instruction > > > cache and register pressure; it is not exclusively an optimization. > > > > Agreed on all of this, but the fact remains that GCC has been shown to > > *miscompile* the arm64 kernel with CONFIG_OPTIMIZE_INLINING=y. Please, > > look at this thread: > > > > https://www.spinics.net/lists/arm-kernel/msg730329.html > > https://www.spinics.net/lists/arm-kernel/msg730512.html > > > > GCC decides to pull an atomic operation out-of-line and, in doing so, > > If the function is incorrect unless inlined, use a macro. The function is correct per the GCC documentation regarding register variables and inline asm. > > Reducing the instruction cache footprint is great, but not if the > > resulting code is broken! > > You don't have to convince compiler folks about correctness. ;) > Correctness trumps all, especially performance. Then why is this conversation so difficult? :( Will