Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8626745ybn; Tue, 1 Oct 2019 10:47:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsZmy31s0N7xwJnm4MppsoNRniPsBCuCaWz1XZcz3xA4QfRw8f46y/2qKx6XKQX/PJmmJV X-Received: by 2002:a50:f391:: with SMTP id g17mr25199692edm.163.1569952022568; Tue, 01 Oct 2019 10:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569952022; cv=none; d=google.com; s=arc-20160816; b=lnE7AJPAd9PE9E/pg6t2eG5jDmjDV6Ctnjck9uZHJenLgS9X2iShq46uEf6DnfBcSE BJnNtZhQoy8HNkUqrYctfmOh5z5/FfhgeqBz8V2rIyLAxmNNEPnyvST4qQwwJtdQPikI fFv1iz5UbBQHkx/gJjZvW3U9AVG/160a3QmcKHqjSyUmZngJjVAoi4MVEBHcMd4j1eO/ /Q7avIj4H6ZzK0mtepEN65kYP6VVdQsw/IijR6WAXde5Mxhy2SYPhkP1+oe5dCCtUaeN 513irfK7BPyn0i5UNP1Bp+ddqzxF2u4YG8nH3usw2jjkEubKsFyohpXWllLlTtsoKvgz 1HXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/gqbc6TYblFlDfMj9onjuLvQJEblaBJvD07SOJm6VuA=; b=n7TabzvNse6Q/LGDHpM+CRffdg0eVeKcoGrLXGG2pdoOUGu1uLhobO7L3estQ/PuqH REDzsCzZ+XZZX0Anyz9o6N0OqWhIT83xumOvmdyzNJKQZSLZ1nEvOYSAQOHrh0aMNC6q hP2r3jJwrqxL/fknuFmNd9Rn7wmrua/BijR4zXIOFtsKZcVhMK001eZWbHNDnNWlDrPV yamzh8NNpEIL4PL6BNLqwoSUYRfDSRGnzRgrhoPKcBZDEavFxjs48I35+wwzLfRtw/le bpnLTrd+xWRRB/8uRZhcqrHYtHqq8+w5HrFn4i86mxhUXsDLCwN2LYtePxjulhMGnhFQ 16Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="lQLkyjl/"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y12si9215956ejp.103.2019.10.01.10.46.37; Tue, 01 Oct 2019 10:47:02 -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=@google.com header.s=20161025 header.b="lQLkyjl/"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729486AbfJARo6 (ORCPT + 99 others); Tue, 1 Oct 2019 13:44:58 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39061 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726030AbfJARo5 (ORCPT ); Tue, 1 Oct 2019 13:44:57 -0400 Received: by mail-pf1-f193.google.com with SMTP id v4so8543581pff.6 for ; Tue, 01 Oct 2019 10:44:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/gqbc6TYblFlDfMj9onjuLvQJEblaBJvD07SOJm6VuA=; b=lQLkyjl/DhgbjayPVz4D8rSRKvbUXsPFkOUvocLrL8DB82Ekb3f9PsCKJLtD8/JCfb YDXhQPdpT9NJaNzBH6E21BZ40acG8H3rCvnbW/JGbdtNjaPBXEvHt7MxZqQAcF+dKfUi 9WdK3KfYRVM4d2WH+HDyjtzuHBXpZE2dt2TnJ83tNUM+ogEOnu4/ZVrE5H5S5hxo5yki KV+SNn1FxyQp2OOJQOUN9q340JUFNwIx2diGITmcXLRVt1d+AZpPNYTwfdU8u9o2IFkO l5Q96sPbRU4cBjVkvx9Kw82CjvTK8Ybw8Pd119PpLFA8d3Hvbz21fod10+Gl+ClezGON RXqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/gqbc6TYblFlDfMj9onjuLvQJEblaBJvD07SOJm6VuA=; b=DFptk0lKOYo3HXwxbuVCvv94XXQyi0mvyglB6p+eSrN/UkF/msrcGFmJol9BgkKikH DKIzdck1inHzPnr/ibBPVVukrWeuSHdWgNTovcL6lXxqtzYVxkIgDUrRQXsSt9ePLyzP zbHVi3Cg30l1mLjtXlC3o2NBeQM/qytjhq7Oam9EUW+1w43WR+ccEoH28OruBlldp75u 7c5RUriaNeEHvgFI/2QvWFTWBGEgv6waBOgMdt5u/6g/MHgsSfRpR3FRdoPgg+rIeK6f H0HcsAiQsXnH/FKHLF1s0lJBwr2Gz4WxNxMhUzYToz3/yCP3SeM2P9Z1kHi41IsD9WRk nnVQ== X-Gm-Message-State: APjAAAVqG3FN1q2DOPE7Q/Fo5ouaixC4elA+/6EZGbFOz4pcw63nTB5T 6fpRVV9z9tW3rNWYJlcmlYNN39ONUpgW7qTEig/c4w== X-Received: by 2002:a62:798e:: with SMTP id u136mr29543173pfc.3.1569951896027; Tue, 01 Oct 2019 10:44:56 -0700 (PDT) MIME-Version: 1.0 References: <20190830034304.24259-1-yamada.masahiro@socionext.com> <20190930112636.vx2qxo4hdysvxibl@willie-the-truck> <20190930121803.n34i63scet2ec7ll@willie-the-truck> <20191001092823.z4zhlbwvtwnlotwc@willie-the-truck> <20191001170142.x66orounxuln7zs3@willie-the-truck> In-Reply-To: <20191001170142.x66orounxuln7zs3@willie-the-truck> From: Nick Desaulniers Date: Tue, 1 Oct 2019 10:44:43 -0700 Message-ID: Subject: Re: [PATCH] compiler: enable CONFIG_OPTIMIZE_INLINING forcibly To: Will Deacon 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 1, 2019 at 10:01 AM Will Deacon wrote: > > 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. Yes. That code should use the C preprocessor to force inlining. Then you can enable CONFIG_OPTIMIZE_INLINING for arm64. > I don't see how __attribute__((no_inline)) helps with that, Because that *wasn't* the point of what I said about __attribute__((no_inline)). My point is to use the C preprocessor to guarantee that no outlining occurs. My point related to __attribute__((no_inline)) was the simple decision matrix that should be used: Do I need strong guarantees that my code must be inlined? Use the C preprocessor. Do I need strong guarantees that my code is *not* to be inlined? Use __attribute__((no_inline)). The *former* is what applies here, not the latter. inline and __attribute__((always_inline)) don't provide strong guarantees (despite their fun sounding names; -funsafe-math-optimizations/-Ofast being the poster child for "that sounds nice, I would like my math to be fun, safe, and fast, let's use that, WCGW?"). The more we use them, the more we continuously be bitten by bugs related to outlining. Like the one you cited and the arm32 patch Masahiro wrote. Would using the C preprocessor to force inlining fix the GCC/arm64 miscompilation bug you described above? I suspect it would. > and replacing static functions with macros isn't great for type-checking > and argument evaluation. See typecheck (include/linux/typecheck.h). > > You don't have to convince compiler folks about correctness. ;) > > Correctness trumps all, especially performance. > > Then why is this conversation so difficult? :( I apologize; I don't mean to be difficult. I would just like to avoid surprises when code written with the assumption that it will be inlined is not. It sounds like we found one issue in arm32 and one in arm64 related to outlining. If we fix those two cases, I think we're close to proceeding with Masahiro's cleanup, which I view as a good thing for the health of the Linux kernel codebase. -- Thanks, ~Nick Desaulniers