Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2686965ybl; Thu, 29 Aug 2019 11:28:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyt7A7zxzD8YY0C6Fu2a08xZEwTHurwt6RDzbxGwVGDMbWY3ECc8c+u9lvZsPG/GcT5EEFe X-Received: by 2002:a65:6108:: with SMTP id z8mr9584776pgu.289.1567103321574; Thu, 29 Aug 2019 11:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567103321; cv=none; d=google.com; s=arc-20160816; b=qftA43qRTNxOprakMY5q7ljH623EBw0PCznETRR2HVogT5iAm1ziIT6Oehd2kxDSCH 2NYs66ld1W18vz7fEDKlbt/eZTuGKBfwNnMNMGd/HRWGdCp67UFYEAbFaJ3OUff2+JM3 HdHfRCiDtnYLCUpZq9KcC+ZW3Q1WNbeSditEh+YSApb70wSM3bbVvISCjlNB3na7m/cG x3Qk+ac+QrIWVsh6T89GUX3WpS7Lvxkio/3rtKB4xh4cdeEOTLpsTPu5tXqUZ3SRSvtb TkNx6TRorzWFSYmhKlGjeqI1PVnZKIoO8xJuOKpJPqzGhlGCjtqoeFws6qYG/MuqJc1F dKcw== 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=sR4WCPDuQLUM49jwD7zWV6jQzPdEIbVdaFJBv2+v+F0=; b=vx09OyDiPR5F0bGtu/7b4UJqtawILNY8/31FffYZcal0t5/j089ympb1BqiFEQ/iL5 aSS8tf8yn/aqILOZSYIX/PX/aK3iK13mFbj3ZE0ZaFErHhsfD/3+f01uypBrG2wZmpLn +TB625lIxae+i46RkHepkvMC0S7OVp8HtzMfRxj4zlGF0FnUq/Uk5A5bC0A+MG9PH8Yg FGOMkTQ7Zszzstlq4hG2PlF6pXcnVMABGXZJpR3ROctFHC8CXthXQqYzgmFkBe3iioGX SnDjc+1wTvaz3EeAyGn+FRfhxV5mCRRpDiTIBIsoK9oWq2eWgkXE0jpg01Myxc6PojOM 4aBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Q27etNQq; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j16si3498423pfh.0.2019.08.29.11.28.26; Thu, 29 Aug 2019 11:28:41 -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=@linux-foundation.org header.s=google header.b=Q27etNQq; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729275AbfH2SP0 (ORCPT + 99 others); Thu, 29 Aug 2019 14:15:26 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:35161 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729267AbfH2SPX (ORCPT ); Thu, 29 Aug 2019 14:15:23 -0400 Received: by mail-lj1-f196.google.com with SMTP id l14so3981612lje.2 for ; Thu, 29 Aug 2019 11:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sR4WCPDuQLUM49jwD7zWV6jQzPdEIbVdaFJBv2+v+F0=; b=Q27etNQqJrho/WpWtWPyEAO7C4sggphAGNNoPYTYaIC0X/UeOTUTQWxOsNwlS4xe50 2b21/BhdLQUe9h96f0Z0sa4Y1711aLD93dPnpdbpcUVoXOasM4Utub1mmX1zt4poyHjI VwSryBYXrojk5fEf95B7u+sWDd/hndAfWy1RA= 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=sR4WCPDuQLUM49jwD7zWV6jQzPdEIbVdaFJBv2+v+F0=; b=TTRulBbYzYBE3f6jS0lK6tGwwTc+w229p5/fiN8T/ixz1ndcQ1RA96M9DRPznWRPIe BgBlXpyuyN7tyh5iP2Y/yLt0R6KskPFcjwqhEJf2XpVd7//TK3P1lN5B3o4ua3lrjk6H 0e1TdhwGvK5Ls7PFlcWzhUym4BKRMKrZyEayQHTtSSKuLzHkGC/NHYm3dgxJxqkv3YAZ SImBXCEKJbNF2JV2+nZWf0XEYMEiC+8GRqVfh4UsmKCq5qf0IUDYHB7xcxhdh5cyIqj5 OoVSvTEuPz++MmrFpNvh53qOLwGIY6ffdh5ZEzcVpzsg89gXRllVrCxOPbWzHVthNvup yPug== X-Gm-Message-State: APjAAAWWwr7LTAUw7iCGHPmhpMSaCDU5Gvrq+Uo+F1WsOIEnh8Otp0lS q2Sn3m4bJNOdFTTKu45Ds15LYgC195Q= X-Received: by 2002:a2e:988c:: with SMTP id b12mr889383ljj.212.1567102521341; Thu, 29 Aug 2019 11:15:21 -0700 (PDT) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com. [209.85.208.172]) by smtp.gmail.com with ESMTPSA id f23sm453525lja.25.2019.08.29.11.15.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Aug 2019 11:15:20 -0700 (PDT) Received: by mail-lj1-f172.google.com with SMTP id e27so3946692ljb.7 for ; Thu, 29 Aug 2019 11:15:20 -0700 (PDT) X-Received: by 2002:a2e:8ed5:: with SMTP id e21mr6415604ljl.156.1567102520069; Thu, 29 Aug 2019 11:15:20 -0700 (PDT) MIME-Version: 1.0 References: <20190829083233.24162-1-linux@rasmusvillemoes.dk> In-Reply-To: From: Linus Torvalds Date: Thu, 29 Aug 2019 11:15:04 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 0/5] make use of gcc 9's "asm inline()" To: Nick Desaulniers Cc: Rasmus Villemoes , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , LKML , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Nadav Amit , Miguel Ojeda , Masahiro Yamada , clang-built-linux , Joe Perches 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 Thu, Aug 29, 2019 at 10:36 AM Nick Desaulniers wrote: > > I'm curious what "the size of the asm" means, and how it differs > precisely from "how many instructions GCC thinks it is." I would > think those are one and the same? Or maybe "the size of the asm" > means the size in bytes when assembled to machine code, as opposed to > the count of assembly instructions? The problem is that we do different sections in the inline asm, and the instruction counts are completely bogus as a result. The actual instruction in the code stream may be just a single instruction. But the out-of-line sections can be multiple instructions and/or a data section that contains exception information. So we want the asm inlined, because the _inline_ part (and the hot instruction) is small, even though the asm technically maybe generates many more bytes of additional data. The worst offenders for this tend to be - various exception tables for user accesses etc - "alternatives" where we list two or more different asm alternatives and then pick the right one at boot time depending on CPU ID flags - "BUG_ON()" instructions where there's a "ud2" instruction and various data annotations going with it so gcc may be "technically correct" that the inline asm statement contains ten instructions or more, but the actual instruction _code_ footprint in the asm is likely just a single instruction or two. The statement counting is also completely off by the fact that some of the "statements" are assembler directives (ie the ".pushsection"/".popsection" lines etc). So some of it is that the instruction counting is off, but the largest part is that it's just not relevant to the code footprint in that function. Un-inlining a function because it contains a single inline asm instruction is not productive. Yes, it might result in a smaller binary over-all (because all those other non-code sections do take up some space), but it actually results in a bigger code footprint. Linus