Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp380827pxu; Tue, 1 Dec 2020 13:41:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyW7JcyFkm7JREhKLrNop1B/agjhHlGJBUU4gXu06Au4hoAaMK/Jl52JX08VzX9DRS5tIVt X-Received: by 2002:a17:906:1695:: with SMTP id s21mr5157189ejd.31.1606858900113; Tue, 01 Dec 2020 13:41:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606858900; cv=none; d=google.com; s=arc-20160816; b=Nae7IhWW1Dog07SSj53+yobbdRKtDmPeuXRa169P6wmTL3NGLtqV2YywroS/jA8IN/ t2Cxtl6wxdT9ClfwqtfOpbHbUG2ubDhMT7ItXFLcgWZg80EeZ18blhQ747evgW2vbySh fJuh6s1rkd4usZ920WKslawF/Q82zovvDxJw+HXl+SaZD7GbXpfvgdnUSigrhf8wIVNa anNvYa2q566gIp/VIWclYK/TRLTPDj6vdGWDOrqp0o10Vv0afAoXzG8u9DGtVrsK/NEP z6ye0haW8DpPLDfDWsmyGxA3wWXXEYK2eMQHy0JadX8Y7un1HRQC99XvyMt5VSK+ahZx VZ8Q== 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=vhe2fhhubG0SMFTgpBNX4/KlbzQ2mtF+9llrSjbBo08=; b=jjGxdeI06JLZpEbtExwk4Sm/rZNz33SckhDL2UcEhKMLLR/2LDlJWCi3O/sajSWi/q g6KodeP9NtrrbjMhdXtf2rso89GggK5NDhmSCxLPTI1LHg6jxy6zsr89jr13SuR2UhG0 XI00rJR1TnGUytwGohGpOHfiZOpxCiRxSSlSylkVFCubAw8HA82HCO+IlySRU+spD8bT iaV6yI8sYy77aFfzC+heNA1T7jq3HNnIhnV3kFuirFDlrB7EWze6yAOj4HidY8l27IM4 rNh3o8USnpuxH/K4eXiOy3y5PKl2XQ9Ex9BYNz+obXgkRkRo8U95OuUcyeDAwr44up61 HxUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WQCyqpyw; 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 x40si809007ede.441.2020.12.01.13.41.17; Tue, 01 Dec 2020 13:41:40 -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=WQCyqpyw; 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 S1730033AbgLAVir (ORCPT + 99 others); Tue, 1 Dec 2020 16:38:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgLAViq (ORCPT ); Tue, 1 Dec 2020 16:38:46 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B09F3C061A53 for ; Tue, 1 Dec 2020 13:37:20 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id u37so4002123ybi.15 for ; Tue, 01 Dec 2020 13:37:20 -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=vhe2fhhubG0SMFTgpBNX4/KlbzQ2mtF+9llrSjbBo08=; b=WQCyqpywTb9sjhDQE0uOd7b+9m6ebi816QKf9yVHZCPLWaGBG+ipLHxcUm8kqWX+KJ kfKXPytExTkGVOe4NfXDntXrOaPJsp9DGA/e+Z5eC+AB1fjt5JjOY6moHYKtMdYABXlc pqwT9bceah0mNt1zUgNTQJmG7XZ4Nqu08tOaPOFkTunOluNW1v+MiVxaG85YN4/M5u+k HXPgLPzYDq4JSCLjbyTdrYr0q8bfH/+KpCl0SDkUgF3lejzLr/TISZQcZo011awEDOER hEKx1vs28+FQbBudhpM53qOZF9Lg00bdHxOHtQRU8na1jUSF06Ou0gmHopnqw5/ud94s 4QmQ== 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=vhe2fhhubG0SMFTgpBNX4/KlbzQ2mtF+9llrSjbBo08=; b=ulF/3vlGhTeu7V2UIL6uaCNR27PAzkuPS1IS1l2rLDddxkMCzvkEBNmie+eqX48fio 71n3WZ6aM9DeKxHwTVs1qeHF9dgko7WWjy8R23e3DZwAY11YO3/gWL8VFUUhdLO5fMd7 elufcCSYvDmaHg/TDxJndU+abEVp+OzC6kvUoJK1VKgK4Wp8EzBrvewR2ZDuAk52Hnrd Q3ArYFI3u90RIbJeTE6UsloZErfJmptVoGTYuIaqWnT52FRUE6OoWUp5oJDnJ1BxYjuV LBxY309XVpcGd/MrfY9yCtNTJE3mC4f4KrZA1Y1VQec/wIJmerob6mmi9BhKTdPj/bp5 gqlQ== X-Gm-Message-State: AOAM533j+3JMWvCOInmOfylFKrs7KZhKz61T/RXwshOAITKlP0t8pxQO Y8t2B54UvdDytTURPI3Wcf4qu+QAcp3d0wI/rfA= 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:a25:468a:: with SMTP id t132mr5364497yba.312.1606858639932; Tue, 01 Dec 2020 13:37:19 -0800 (PST) Date: Tue, 1 Dec 2020 13:36:55 -0800 In-Reply-To: <20201201213707.541432-1-samitolvanen@google.com> Message-Id: <20201201213707.541432-5-samitolvanen@google.com> Mime-Version: 1.0 References: <20201201213707.541432-1-samitolvanen@google.com> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog Subject: [PATCH v8 04/16] 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 222ae96d179d..ac836907d8b1 100644 --- a/Makefile +++ b/Makefile @@ -899,6 +899,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.576.ga3fc446d84-goog