Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp673167pxb; Wed, 18 Nov 2020 14:10:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJBxvxVKvIl1npav310DwSSzgBmeXdIRBDh5FKJvXvzlvu8xAs4gyicNrTS/vW7syh0j89 X-Received: by 2002:aa7:ce8d:: with SMTP id y13mr14974202edv.65.1605737459083; Wed, 18 Nov 2020 14:10:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605737459; cv=none; d=google.com; s=arc-20160816; b=NAc1gnnWUASxNqa+i4tyEBWML3SPwyp5u2Y5uITcWZx0FT/82NiYfh7A7ldxOYsF5o +iPUb0kSLsvf9OU18VIL+6rk+hvmLFwYS+BIO/262Wysez7Ekc11S3u0OPTwfs3uZaEi 83dCDc93kqwrotGl7a1LH/jVsfayDXXWFqwKeLACHdYLSR9MsEDhiQ54fbqvAUJi6YA/ v1uZRbSBNPYhauOiMmA7r/pVYwmenBzu0BCHXe91eYkbtSOAfwQoEzvTeyLdxVZsfbfw zOJ8Lqqv+5tWUx/LbLdmQoIWoQREdpq8oOpKT8paqH+QP3PjTKioNa0yt11igXEgdxaO Qz7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=OmvLBVHrXYJgk90zzJ7qPiL6Oqy/f8wdr2oL1+M7ruk=; b=sw7wz8BQZ7TOILLBxAsd/Wm//hik1z6WlQCpvn0jPyDcOhZDs4JgSJK7TBtsabEEEY kt1jbB4ximur0zmJZbZhD9yjmk/EU/kBsbostqaa2u+q7tCrni04F2LdRFrNG5uMbz2+ PhSUxpbLSuL3VBRRQHMkklJAeBs8h9EfojgUIlpiOMv3YuNNt1F2IvlsHYXtv4SklfLM ZAK6jSs6Z6BAv2QZdtsBjbT2KOssLivj/Rll2S4yR9McqV+ZCglRuLEpZ1uKR9eL9zT1 jjwRrpyGOjs/6B3I2moZ1YDzf7SEanCKFLTle3YmJmuvqLl0Nhbmx49JaisfCuoTrJuF QKWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OOlRBBd1; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d22si15243419ejz.82.2020.11.18.14.10.36; Wed, 18 Nov 2020 14:10:59 -0800 (PST) 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=@google.com header.s=20161025 header.b=OOlRBBd1; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727294AbgKRWHo (ORCPT + 99 others); Wed, 18 Nov 2020 17:07:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727253AbgKRWHl (ORCPT ); Wed, 18 Nov 2020 17:07:41 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF01DC061A4D for ; Wed, 18 Nov 2020 14:07:41 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id g14so2094502pfb.8 for ; Wed, 18 Nov 2020 14:07:41 -0800 (PST) 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=OmvLBVHrXYJgk90zzJ7qPiL6Oqy/f8wdr2oL1+M7ruk=; b=OOlRBBd15lFDmzj+eQqhl6JOtOXoAglrgb4iMn+oJHxK0ENZkBjJjpLRPk8q5A7SFY ZxOzbIi6eI8fOpXWY6S1PtuFb9wg3TX+Bl/FrS4kXMHRbAe+z1Spr6ZgEqWyaJ5aKKGh CYZOPt70DGmhjLkIIlNFkUn5wAZcqd9p24/TP07dxXRKEgV6/xSmfaZiGowvpnrChr3h oRO+CqR4Ru8/QzOnLXn22YARn7ZtJna8chF9gED7FTMLvJ5bG1fnbkKMtM2vVSGmCzM9 01mn+DFFeos8A/Ej3OQuxmZxuUaqeCTk5sVd6ATqwCmTjVTPWyZ/EVXTwx/DNAKAAf5i Lm3g== 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=OmvLBVHrXYJgk90zzJ7qPiL6Oqy/f8wdr2oL1+M7ruk=; b=iW3kBMrwmvNChoRa+HcF5dYDALwfe+yQYkZ6EkSAnU+FF+F0MQLN6olgyxPearzTNx /mRJBRooNIIOLVtRjXGHHC7svgSqq6eOSoVwIM7TbxHGOpssMrRR/ADaLYY9fa8ovQMX 4jYo8T07wpzEO/tkDh+3UVyT8cJEUMZzK8ZoCQFKEF2mvuaChDuey3IlvcPvIjHpuYKx E3SFFwnSAquSblg5zvDWaAQMNohEY6KRoy7+WzYiJF1UfYQP3SSI8lU/vFCRfC/BqqeE 23/oCZocMAbhZsJqbthZJqbDTfC7hl6DxCV2pp3qEuOeb/IgJMM8RGY9yTXK/mGHvE9l bDtg== X-Gm-Message-State: AOAM5315rS1EP8aSD5DeBHzK5Vm2AzHe2lwT2RvIQNV51snohWahHnWi kiCX5ehopTCsNWfuQoa+GoY7JgW8WwgqfxxvalI= Sender: "samitolvanen via sendgmr" X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) (user=samitolvanen job=sendgmr) by 2002:a63:550d:: with SMTP id j13mr10510189pgb.365.1605737261156; Wed, 18 Nov 2020 14:07:41 -0800 (PST) Date: Wed, 18 Nov 2020 14:07:18 -0800 In-Reply-To: <20201118220731.925424-1-samitolvanen@google.com> Message-Id: <20201118220731.925424-5-samitolvanen@google.com> Mime-Version: 1.0 References: <20201118220731.925424-1-samitolvanen@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v7 04/17] kbuild: lto: limit inlining From: Sami Tolvanen To: Masahiro Yamada , Steven Rostedt , Will Deacon Cc: Josh Poimboeuf , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 f27c0da5d05a..bee378f9fd50 100644 --- a/Makefile +++ b/Makefile @@ -901,6 +901,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 -- 2.29.2.299.gdc1121823c-goog