Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4110426pxk; Tue, 29 Sep 2020 14:51:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMa/mHUH4klFV7CbmpVaYwLrS5mcJiRgeUtNLEuQDUT4ZoGMDlHqeZck6QL9VX2MWFaniY X-Received: by 2002:a17:906:c1c6:: with SMTP id bw6mr6209580ejb.374.1601416267092; Tue, 29 Sep 2020 14:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601416267; cv=none; d=google.com; s=arc-20160816; b=mRT8+HRR3LkOaDJcYqqUS1wDMzurSYCwGUmjiclGkVZa+xSCxlKMJ2IpK4CAiwGXon CkJkiOpyMqaL/K9XB018MtoyjfI8gatoRRR00KQTVJ3ZePkJdV1tk4w4TzD9H99OK2Ej 87qcmmpCdDEyYrg3z+A2xIuVzIdnLnKMp4o/cD94jWExrpVmtMmEQgLOL+eHAIgLCw2G aHq30sNSk/6IEdw9h8H1TPjB3rPmwDeLgWLTbZ9HFXWHY2or56AMR0Rq4RMsPfUExcyY Jvv7D1OW3RNkb40ufcZj/EzvMSzzryGoTGiSBJEqZXUPKRMeH0/DQnOA7bGy1XshO5sC cbpg== 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=3CV3/71SvI9Aae4EB6SuVg1gWevq6V3dKGQQ0SLCSxM=; b=igwYMGmHEFjax/0zKYXx727sB4/JnFBgm68Y+kRkqBzzvMy3KmsHeM1RnV0rQY/LRt M+rqLxiPDjEpkLwOimm1uBHCpxJtD41EgTji7vua/XlLQBHGAkN6o5ymSeU+0FS0zjvM dwW3oc/t05YLZ5ODPlg7OAhe0NI3GpwjZDwLuJ4pp/OqEJLRCg+J/3H54KGXDWoMy8y0 rFbIgCnY3+20CkbVvJ5jKKhVlkLaQ1siOqb6ggYHrigOlO5Bghh3+lQnuSvdR6ZVSEDi dvxMRUTCYSo4mTMIIg4lMWjUJRrb3fzEWL5XfIOvg/jBsGjLT0FWjYf0UcMe8gRBM2hk 8ctA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VsL4ntl5; 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 k23si2049368ejk.246.2020.09.29.14.50.44; Tue, 29 Sep 2020 14:51:07 -0700 (PDT) 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=VsL4ntl5; 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 S1728349AbgI2VrV (ORCPT + 99 others); Tue, 29 Sep 2020 17:47:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728814AbgI2VrH (ORCPT ); Tue, 29 Sep 2020 17:47:07 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BCD0C0613D9 for ; Tue, 29 Sep 2020 14:47:05 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id e6so4077396qtg.13 for ; Tue, 29 Sep 2020 14:47:05 -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=3CV3/71SvI9Aae4EB6SuVg1gWevq6V3dKGQQ0SLCSxM=; b=VsL4ntl5+hY0sK9YbHIOCU/8xkMTUwfbSaQJDJE3/xjI5F6RvBhZ95rjnSx9qzKP19 c8dtjWQ9X1ycYC5cQdhz1pOUlwobIqAkhxQS/79ifUywIFe8vgvwUcWjLeboFlrrbcYK f+yGk+07cGJpo17CclConQX5GRnPs77eYx1X4Y/VF+Ljh28bTgeQSAfYO28SLdB3x+Y9 NGL1RCxovqI1uJnDovNqoqdjqzucm59FJTBc3enczCyNqTlCQDgreBEoQ6ZIkYl4frgU j3XEkn1c1qgjUZRuJJnggDEhbR6LNJUg+9sOgKjHf5cebOSVhsYP16Et9tjoyV5Q4Nqx WMXQ== 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=3CV3/71SvI9Aae4EB6SuVg1gWevq6V3dKGQQ0SLCSxM=; b=qPd4worDC27VaaQLl00YJAw9ezypSXWBSJ9IKAPi0N6TI+9G781tK/cXomxbKHge6N iC6tB4FOH0hie35VTp8qGS+5Gr17ws7TXbniUDJb79arNmN6+9bhwnS3U3gjK0Nozv/i yAIX4e9ym3XadxVX+XFoynod/rm+I56HFkTc5SF9HMTjCxTSqQnEv0woRF8gf8bf1P/x ojPMjEzf3k5+W5n3nE+o+5A7QV4w2HcYit9Qd9lkZJf2El6oCfvtKm5yQ8CpkyVuXiVK p/8nDrfzBTRqrxwYlAw8KDu1YfwItN0gQ+ryaPf9MOFxQnqXTSEKrFdiB48GkgSZuGsj 2hBA== X-Gm-Message-State: AOAM530TfHfg/UwthTWHYvhT5GLcExwhux7SYXEosm91bR0BXmF1w8lH Njfk1W22L6FiQtOf68Z56pkb4hLcqRzVXrk3tO0= 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:ad4:58c7:: with SMTP id dh7mr6716071qvb.20.1601416024173; Tue, 29 Sep 2020 14:47:04 -0700 (PDT) Date: Tue, 29 Sep 2020 14:46:16 -0700 In-Reply-To: <20200929214631.3516445-1-samitolvanen@google.com> Message-Id: <20200929214631.3516445-15-samitolvanen@google.com> Mime-Version: 1.0 References: <20200929214631.3516445-1-samitolvanen@google.com> X-Mailer: git-send-email 2.28.0.709.gb0816b6eb0-goog Subject: [PATCH v4 14/29] kbuild: lto: limit inlining From: Sami Tolvanen To: Masahiro Yamada , Will Deacon , Steven Rostedt Cc: 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, x86@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 23cdb475c445..d6510ee99ffc 100644 --- a/Makefile +++ b/Makefile @@ -894,6 +894,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.28.0.709.gb0816b6eb0-goog