From patchwork Fri Sep 18 20:14:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 11786281 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E77792C for ; Fri, 18 Sep 2020 20:34:24 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2583021707 for ; Fri, 18 Sep 2020 20:34:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0AhdSOXb"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="rc/QdCJz"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="pyxY37Ar" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2583021707 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dJMnUDpfCUmTIidxjmICl0Ju4XGEy9CVl4fjhD8hDFQ=; b=0AhdSOXbdBaDAFHoLnfqd1Nwq U/wjP+0MSR172QTUO4v138XYjZH3bnt0azoCEn+mVXGm1qM2Bo/G5kK06kvax5qoEZ/B8SJXD/8TC w4bps18J81C43UN7XHK3Ha7c6ULGfo3CA8LVe+Z8FLS7ga93i6kFs3eNUcPXnJUQgC1EfiQRCZhN9 Az5+5ar5CRMVglAbvCRTTVhKdfBYHz5+vEMz1y5R8qeCGNzbz9RcWiu3N8PBoVPDAaB1L1XKjbWmy bJj4XSXkwOkmiARmA79YczeSf1LjstToVCjZgSdoFAfjQYJoPBtY7DJXtu2UMut1hhOnY4k7EkXB3 Ci4FOvmJg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJN3w-0007Rc-0x; Fri, 18 Sep 2020 20:32:56 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJN2i-0006xG-QS for linux-arm-kernel@merlin.infradead.org; Fri, 18 Sep 2020 20:31:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=AuswF6CKDN8dO1xH74r4m5G29uexAro1Nb2/kCMl6ng=; b=rc/QdCJzqutAnMZ3S0IGEWAMXx Ee9VTbHzuMkMltOm2WTOAk3pYT2L2FOF1XDwjkZzZySM48JIHTyYzOTuNFDz0abLnCHjqiA8KXP+1 27lZz6qmHVemzjoht/Hxq2/XpNkslqxvalKqDjKahpi3Fm+rrXiim0bjUYpIAXal+F4g0g9Inm2pt 4h0Lf83xelq9VlYE3zVDgQPiUfDXyEd7A3MqDqhwZ+kZIY0+rhpGLtE1VmcRTLUw+lIPkAuMMxUeL ZG+IH+ErE65AjzH5NFwJGjbNm/C/hUe4nKKvVPIUfMwkktvzjfE3KQhf34P+P2BQoCrfxDW8iMZ+9 m1/SxXhA==; Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJMmp-0004sY-UH for linux-arm-kernel@lists.infradead.org; Fri, 18 Sep 2020 20:15:22 +0000 Received: by mail-pf1-x44a.google.com with SMTP id o21so4387490pfd.14 for ; Fri, 18 Sep 2020 13:15:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=AuswF6CKDN8dO1xH74r4m5G29uexAro1Nb2/kCMl6ng=; b=pyxY37ArYBcWk0pTveeYem7o3r7m0QxYR7o9ddMazv3C4wUXpf2wO5JjRX0hn4D99a ZfGgMQ7Y6Q0IcMD2Az+PMWVEf1UQD0bMp5UvODjcuy5A+HFY6tfMzIjH2TOqDSGxfrkm bzhUpRLa1APdzJJuc3rFYJAUGU6Q8y3Q93uvmCIMm/1oh0Z+W85oIwCWP5Q55yaYOmbE gk8wLX192p13Gd0rr4JArg+R3FEIeSJsV0U3a+yj521FBPN70Pf7378jB++mxf7g6bky 21wEGkI2GQeXxYFaCDkQXFqja2UN6FX7KM68hCqpPYC8vhf6aqeVZ+IoZbZQITt213Zj ebpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=AuswF6CKDN8dO1xH74r4m5G29uexAro1Nb2/kCMl6ng=; b=gvriBvsTdMzNuIW7IGnmW03Jc5FgPOlv3TXBmsWVLt8FrIyppkrSzpjEUoCmR3u0Q3 +9ws0pBPby+KBlI9/2yzU5nyZM/qq/lRtSpHWTepatBMgllDug+nMLEzZPM74CmOwMD1 8VpwMoOkuZ5Arwr1yRYuVKGZLSnAB44hQ8WCItFgwZW62BGMEHHjFcmOL+a2IG1NPgLT qpePdvV2Ylhb2wJsdHyImGVHcfzplnjg2Am7WK2oV1Yqwg8tPcDH6p5MtiWOtvuZdbux U2O7FFhGwXD00Yq7ZSV/n+qT/jFlQFb1GiZ3IljYumfEeSXn1Sdj2587QjHpN+0mWiyN zBMA== X-Gm-Message-State: AOAM533k9Du69we11qa+RzljNd5pyf3X/yRNlTYUln+8qKbHsNTnvZxU QsmbcZMxr6tVGghN6e1ohSb8RL5Dd/4mEcHhbkg= X-Google-Smtp-Source: ABdhPJxzZeQUOl2JhbPGv5v7ZLZFcYcdjlAn8PduxMhR73rTNKLtzUhom6BcaktSr/Lr+jGrmaYuXtBeO2vdou5k7ZQ= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) (user=samitolvanen job=sendgmr) by 2002:a17:902:d70e:b029:d1:e626:d12f with SMTP id w14-20020a170902d70eb02900d1e626d12fmr17241070ply.74.1600460111357; Fri, 18 Sep 2020 13:15:11 -0700 (PDT) Date: Fri, 18 Sep 2020 13:14:20 -0700 In-Reply-To: <20200918201436.2932360-1-samitolvanen@google.com> Message-Id: <20200918201436.2932360-15-samitolvanen@google.com> Mime-Version: 1.0 References: <20200918201436.2932360-1-samitolvanen@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 14/30] kbuild: lto: limit inlining From: Sami Tolvanen To: Masahiro Yamada , Will Deacon X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200918_211516_254374_639812F1 X-CRM114-Status: GOOD ( 12.23 ) X-Spam-Score: -9.6 (---------) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-9.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:44a listed in] [list.dnswl.org] -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, x86@kernel.org, Kees Cook , "Paul E. McKenney" , kernel-hardening@lists.openwall.com, Peter Zijlstra , Greg Kroah-Hartman , linux-kbuild@vger.kernel.org, Nick Desaulniers , linux-kernel@vger.kernel.org, Steven Rostedt , clang-built-linux@googlegroups.com, Sami Tolvanen , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This change limits function inlining across translation unit boundaries in order to reduce the binary size with LTO. The -import-instr-limit flag defines a size limit, as the number of LLVM IR instructions, for importing functions from other TUs, defaulting to 100. Based on testing with arm64 defconfig, we found that a limit of 5 is a reasonable compromise between performance and binary size, reducing the size of a stripped vmlinux by 11%. Suggested-by: George Burgess IV Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 629d4b18e413..973155c24711 100644 --- a/Makefile +++ b/Makefile @@ -912,6 +912,9 @@ else CC_FLAGS_LTO += -flto endif CC_FLAGS_LTO += -fvisibility=default + +# Limit inlining across translation units to reduce binary size +KBUILD_LDFLAGS += -mllvm -import-instr-limit=5 endif ifdef CONFIG_LTO