From patchwork Thu Sep 3 20:30:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 11755037 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 3FE08138E for ; Thu, 3 Sep 2020 20:53:01 +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 0462520709 for ; Thu, 3 Sep 2020 20:53:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="12F3JlXl"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="iyaIyLny"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="d3WTta76" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0462520709 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=2vpvOQrs28Xor8jqDGCkn+Kxp4kf+MIO5bM6I+FL9qc=; b=12F3JlXla8jUG/M2YxZm0D3l3 nCZsbxj2zZN8PQdodVPLQ/tBUJxYg8BObqQIbSVmHzYq9ympMLYDN6WNzlEEEA2ekpTbfMBMbIRLv +Fx42D9Be2Oy5mIf772t++8gZEDLUg7yTYheSiZSX2yM8afsZdH7Mdj5yQMQa9cdsMW1jsFXCx1Ri LsCzRjhs6PcJh93FaxCCU39bJQocD08YeSVkdix8DNNCP2Rzbs4JxYv+5OyfW4oJN+lWfPQbjV87S ifrBpXaRRny9AQCVMeC481IMqnylx9xQTlKlwufcZFzb3Rzuz2XTcvYTD9aph1qYQXDp3or9dpPli HwnA/fpww==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDwDt-0006z8-Db; Thu, 03 Sep 2020 20:52:45 +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 1kDwBl-0005lz-2e for linux-arm-kernel@merlin.infradead.org; Thu, 03 Sep 2020 20:50:33 +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=v4aEDtr6bLZLPmR/ra6D5NVXgPqHTR+q2+p+53rP8YU=; b=iyaIyLnyfsXzfBLNet+1S3QMeP nuUzqOKhBpAKyqHOJFi5Ak+n7gOSSY5XjS3l4Sb1kQFHwLBCCrZWR7NDDVVe87eQsocqJ8ixcNgd3 BpWE9f5Qurzo4vbMA560Ih1TZn7lqCmga3MU4EMXazhaSUCZ7f1PvrXiYDOwT+DJ2i3spdTrI1mvw WNGlunqKykNcSok+kTUB0+ZCVsdoH0W2F9FO1lvzGpvtS7voeAoINPJnj9ma7aHXUIQ1+dfCbTsQL mvxuQ8nzZeYrgVM4r7NTPHxclwZJLt9S6p4QfDD+9MWZpUlSPDA4s6Cne/TIYocvQT/CVdDWlh//a 2bWgQGfQ==; Received: from mail-yb1-f202.google.com ([209.85.219.202]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDvtD-0003mL-EG for linux-arm-kernel@lists.infradead.org; Thu, 03 Sep 2020 20:31:42 +0000 Received: by mail-yb1-f202.google.com with SMTP id b127so3980412ybh.21 for ; Thu, 03 Sep 2020 13:31:21 -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=v4aEDtr6bLZLPmR/ra6D5NVXgPqHTR+q2+p+53rP8YU=; b=d3WTta769MJh+Bo0VzFx1dIubRn1F3/0OsgdvpRIABs/0F8aoQ0QxN6GC6ogiN8YAt 1n2fy7ycG6neE8i4JP6mcoL5+gOWppxCnH2U8kbhGmk3Ke0U/7qP7lute7a6H0uDoYhQ dWVIqp9Xjw2Q1WEklB8eqrGPTTy0VYDaAb7Vj5vkDxGtzwmgFWOj15UwJBAbJ05tl1sN Q4rZl0DzGVRAuAw5PJyrACjWBxr1NbGCE0oN5TR+pUi+Dq3TH5paoF63RYX5l7QEOrpB +a+BflxQgXchm/xsTBNIInkXUZW2NMgvFiHC7w8tScjlytwkaK3yal7TbaDvFzX+VZKt 2LRg== 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=v4aEDtr6bLZLPmR/ra6D5NVXgPqHTR+q2+p+53rP8YU=; b=CBAT4rL9kF933l+WBxV9TduyqnP5qv0WhcKD3SmsZX+q+nn1+Uou+zDRou53EhULRU 5wkyyZ6Q9ZtgVWzg5xIEu5++2nkhs14tdDd/zH18dc/kj2q4F0bWSglnJguRNGtLnamq TGZT3hiqG4kfC3O7TKxpk27w1xHgnlmq05tfBlSXrwBrFHgtesP/F7WUv4CDqZ/iyEZV QUXJ3VNF++kIJdg0aVMOv+x5M0tmFnzgNn1/gwjMr8LFp7RfWZrTuZ70B15bp4cDPhBS n48XZKgykzvMhQr4sUyXM3Oo1H9fe3Il9nADaJJ42xcWkghG++caLsguwlWQ5Z2Hw0a9 J6wQ== X-Gm-Message-State: AOAM531j3qj4qGo5n5pRhTc1MuqtKYFCbEx4TQpp93oLccyvM3TPag/A fdIMLJfHCUV7z1G1UUDfU1Sn7rB6d31FTQKH69c= X-Google-Smtp-Source: ABdhPJxLcteMiXx6yxIAtF7C6LDsd43v+S+v/BljrbTvv0EuuMtNnvGzhvJa2qGTBh5Tw0uOlOWuvZqeImKd2fr7SwI= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) (user=samitolvanen job=sendgmr) by 2002:a25:a366:: with SMTP id d93mr5081717ybi.415.1599165079173; Thu, 03 Sep 2020 13:31:19 -0700 (PDT) Date: Thu, 3 Sep 2020 13:30:37 -0700 In-Reply-To: <20200903203053.3411268-1-samitolvanen@google.com> Message-Id: <20200903203053.3411268-13-samitolvanen@google.com> Mime-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> <20200903203053.3411268-1-samitolvanen@google.com> X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog Subject: [PATCH v2 12/28] 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-20200903_213123_680873_E9B255CD X-CRM114-Status: GOOD ( 12.70 ) X-Spam-Score: -10.1 (----------) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-10.1 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_MSPIKE_H2 RBL: Average reputation (+2) [209.85.219.202 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.219.202 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.5 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 2752be67b460..c69e07bd506a 100644 --- a/Makefile +++ b/Makefile @@ -917,6 +917,10 @@ else CC_FLAGS_LTO_CLANG := -flto endif CC_FLAGS_LTO_CLANG += -fvisibility=default + +# Limit inlining across translation units to reduce binary size +LD_FLAGS_LTO_CLANG := -mllvm -import-instr-limit=5 +KBUILD_LDFLAGS += $(LD_FLAGS_LTO_CLANG) endif ifdef CONFIG_LTO