From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84F2EC433E0 for ; Fri, 26 Feb 2021 09:07:11 +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 1F4A264ED5 for ; Fri, 26 Feb 2021 09:07:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F4A264ED5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.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:Reply-To:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ojuW9lgCQcYsp8pWKKGAHCOyC4szIV6SyezUg7r9DSw=; b=zcrl6xVqsIW1F0att/cRLy3Y3 SPdKMTtSti8QGDq7JbPBFBZQ1ivhV4vibx7zwoyXVzy2yGm23T3VEHOemh4nYAh3w7/JOvxRGqWHZ uDE/eghIxoIEI9gl54hfhER7RcdTGkc34W9rKln+MuOaPQnMh2B5MdjmAlCdCrKbUaO4rr1Wqi7Ro xbSwIISG2KtRlqQTvXYS4fXmYmg4T+yDGk69U7DlskQ18IV6mUzFWtKDCuwcmG+3kDZdYh/1Wj8gR J1gUhNGpCAcfy/eoaa+Ub4Ghm+iiF0oXG/ph4qjnXPl6BTxPzxL6oPWDi+a3bwLOoFQ5VDnGIlpyV 1g73qaV9Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFZ49-0001BY-Rl; Fri, 26 Feb 2021 09:05:41 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFZ46-0001Al-ME for linux-arm-kernel@lists.infradead.org; Fri, 26 Feb 2021 09:05:40 +0000 Received: by mail-il1-x135.google.com with SMTP id z18so7413386ile.9 for ; Fri, 26 Feb 2021 01:05:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=iJFcEa8Md91qPWXA3MXvjPfvCleZ0GnvsYYC4ySVP+o=; b=oA7LpeV2NWTkmefvnjytWUbuioCKdL76JXwpDCmEBWRl5Dxzxtv98QZcdVGF+bqRoY LU8FrgQVh0PYoofW1nI5TjZhcw9KMId048a81IMI787u4wdw3vFkzgHo3ClNkN3seChs XUfehXx3FDHvRmsWLBYZv6L0C9zZh+TzmK3IPJAherycNB7+QCmyknEGf2m9yPnvzT+Z YvjchNOYArIhbHg+EmLTSd53D0fa3HPHLdGV9AbtjoncJ6dKo/ymJonp6rLanQn3Mmy7 zLvQuq7l7gCW3ejophB6kLamZ3rw0fa8/5fcBzwj/RkegcleIyHxx9lvJ9fCL8l/daqO jQ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=iJFcEa8Md91qPWXA3MXvjPfvCleZ0GnvsYYC4ySVP+o=; b=McDbNLGiZKzA/y7FDMkpeb03w0tKEgqaENI8N3xhWIFL5K9mL/XYzr5B+Gpr5w4MOk uGFq62eBy/SULJLauyUOTZKYSktcjREnhrXg+jcm9rLUAzKFUx9ELTpZnP8nGaK257cb 2zAVcpuOhhsfkvbP98fnKb2IC7PRR2UP+1hYc+qoz5/oaNyjhAZLHFd7kiAbGnMsKduB 7D1HczhdcI3ofTKtBDtm9oyzReipFMtGvxTj0b9gPHVx4XKmqaOEx97zfnSAPk+ErzD9 dnwVRx5aQp1ghlMMUQi7sLvJu79K+J/8oN6coqLsLIMoL1Vqt2aYXpfqY1YW9Ix6E/3m kT6Q== X-Gm-Message-State: AOAM531rK4CYBOe9645BJsIDHnJYHMi2qi3ZRI8ApsXhq2O6Ts2u6bys xs8bMtToTwXmHel1CR31SYFTD37TvtmaF4R9Hq4= X-Google-Smtp-Source: ABdhPJxJdT4evrWcbSdoiw3WukuOy3FxkfxhS41IQTGQfZXs8eoE86pLFeaDm5G7ZJzEgbv+Fd9brpgE9VVYgw/ciH8= X-Received: by 2002:a92:c145:: with SMTP id b5mr1599185ilh.186.1614330336411; Fri, 26 Feb 2021 01:05:36 -0800 (PST) MIME-Version: 1.0 References: <20210225112122.2198845-1-arnd@kernel.org> In-Reply-To: From: Sedat Dilek Date: Fri, 26 Feb 2021 10:05:25 +0100 Message-ID: Subject: Re: [PATCH] [RFC] arm64: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION To: Arnd Bergmann X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210226_040538_882880_D4318872 X-CRM114-Status: GOOD ( 28.71 ) 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: , Reply-To: sedat.dilek@gmail.com Cc: Mark Rutland , Ionela Voinescu , Kees Cook , Arnd Bergmann , Catalin Marinas , Nick Desaulniers , "linux-kernel@vger.kernel.org" , Kristina Martsenko , Ard Biesheuvel , Nathan Chancellor , Clang-Built-Linux ML , Mark Brown , Andrew Scull , Marc Zyngier , Geert Uytterhoeven , Vincenzo Frascino , Will Deacon , David Brazdil , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Feb 26, 2021 at 9:14 AM Arnd Bergmann wrote: > > On Fri, Feb 26, 2021 at 1:36 AM Sedat Dilek wrote: > > > > On Thu, Feb 25, 2021 at 12:21 PM Arnd Bergmann wrote: > > > > > > From: Arnd Bergmann > > > > > > When looking at kernel size optimizations, I found that arm64 > > > does not currently support HAVE_LD_DEAD_CODE_DATA_ELIMINATION, > > > which enables the --gc-sections flag to the linker. > > > > > > I see that for a defconfig build with llvm, there are some > > > notable improvements from enabling this, in particular when > > > combined with the recently added CONFIG_LTO_CLANG_THIN > > > and CONFIG_TRIM_UNUSED_KSYMS: > > > > > > text data bss dec hex filename > > > 16570322 10998617 506468 28075407 1ac658f defconfig/vmlinux > > > 16318793 10569913 506468 27395174 1a20466 trim_defconfig/vmlinux > > > 16281234 10984848 504291 27770373 1a7be05 gc_defconfig/vmlinux > > > 16029705 10556880 504355 27090940 19d5ffc gc+trim_defconfig/vmlinux > > > 17040142 11102945 504196 28647283 1b51f73 thinlto_defconfig/vmlinux > > > 16788613 10663201 504196 27956010 1aa932a thinlto+trim_defconfig/vmlinux > > > 16347062 11043384 502499 27892945 1a99cd1 gc+thinlto_defconfig/vmlinux > > > 15759453 10532792 502395 26794640 198da90 gc+thinlto+trim_defconfig/vmlinux > > > > > > > Thanks for the numbers. > > Does CONFIG_TRIM_UNUSED_KSYMS=y have an impact to the build-time (and > > disc-usage - negative way means longer/bigger)? > > Do you have any build-time for the above numbers? > > They are in the mailing list archive I linked to: > > ==== defconfig ==== > 332.001786355 seconds time elapsed > 8599.464163000 seconds user > 676.919635000 seconds sys > ==== trim_defconfig ==== > 448.378576012 seconds time elapsed > 10735.489271000 seconds user > 964.006504000 seconds sys > ==== gc_defconfig ==== > 324.347492236 seconds time elapsed > 8465.785800000 seconds user > 614.899797000 seconds sys > ==== gc+trim_defconfig ==== > 429.188875620 seconds time elapsed > 10203.759658000 seconds user > 871.307973000 seconds sys > ==== thinlto_defconfig ==== > 389.793540200 seconds time elapsed > 9491.665320000 seconds user > 664.858109000 seconds sys > ==== thinlto+trim_defconfig ==== > 580.431820561 seconds time elapsed > 11429.515538000 seconds user > 1056.985745000 seconds sys > ==== gc+thinlto_defconfig ==== > 389.484364525 seconds time elapsed > 9473.831980000 seconds user > 675.057675000 seconds sys > ==== gc+thinlto+trim_defconfig ==== > 580.824912807 seconds time elapsed > 11433.650337000 seconds user > 1049.845569000 seconds sys > Thanks for the numbers Arnd. > So HAVE_LD_DEAD_CODE_DATA_ELIMINATION is a small improvement > on build time (since it can spend less time linking), while > CONFIG_TRIM_UNUSED_KSYMS slows it down quite a bit. Combining > CONFIG_TRIM_UNUSED_KSYMS with CONFIG_THINLTO is really > slow because here most of the time is spent in the final link (especially > when you have many CPU cores to do the earlier bits quickly), but then > it does the link twice. > My first pre-v5.12-rc1 kernel-build was with Clang-ThinLTO enabled. But with the next ones I jumped to Sami's Clang-CFI. > > BTW, is CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y setable for x86 (64bit)? > > ( Did not look or check for it. ) > > No, in mainline, HAVE_LD_DEAD_CODE_DATA_ELIMINATION is currently > only selected on MIPS and PowerPC. I only sent experimental patches to > enable it on arm64 and m68k, but have not tried booting them. If you > select the symbol on x86, you should see similar results. > OK, i see: $ git grep HAVE_LD_DEAD_CODE_DATA_ELIMINATION arch/mips/ arch/mips/Kconfig: select HAVE_LD_DEAD_CODE_DATA_ELIMINATION $ git grep HAVE_LD_DEAD_CODE_DATA_ELIMINATION arch/powerpc/ arch/powerpc/Kconfig: select HAVE_LD_DEAD_CODE_DATA_ELIMINATION So, I need to add this to arch/x86/Kconfig. You happen to know if changes to arch/x86/kernel/vmlinux.lds.S (sections) are needed? Last question: The last days I see a lot of fixes touching inlining with LLVM/Clang v13-git. What git tag are you using? What are your experiences? Pending patches (kernel-side)? I use: $ /opt/llvm-toolchain/bin/clang --version dileks clang version 13.0.0 (https://github.com/llvm/llvm-project.git c465429f286f50e52a8d2b3b39f38344f3381cce) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /opt/llvm-toolchain/bin My LLVM toolchain is ThinLTO+PGO optimized for Linux-kernel builds. - Sedat - _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel