Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1057756pxb; Fri, 26 Feb 2021 01:08:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJybs3CuhFy1YfZvJxCMsC/AsXSZsBLWiR+FifXzOe3FD3sRf9vnMHZsR+n7F4UA3N2/m2Jk X-Received: by 2002:aa7:db88:: with SMTP id u8mr2135419edt.329.1614330496338; Fri, 26 Feb 2021 01:08:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614330496; cv=none; d=google.com; s=arc-20160816; b=P1Pgn01hxbt91X0/cmY7D3OP7yjngbtY0Zfejcv0reN1QYllUvCpQCImvavjBtbtJj dpw47OwV2DWt7OLLAlU1PgehQJEYKq85JfIdqKYDD0QvXNtm1X8yym/pi7Lx1Rtw06pD E0tmkmrMpZHSRigy+l9VD00V5opLG31DOgcE41Q2OYOW5iHQydaNhokKEr6ZuvBGh5kp YJbYDqGVw8giZCxJmtFvf+l7sZVCXpMiUC3fwObAB86qE3dR4pEfBvc29DjaguMqgakD ppaxQLegytIciPY4ridiwxlP2+Ee0cnHBrokASI06xBrlSTr5ud3OwTli91ECd/0LxcP TUZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:reply-to :in-reply-to:references:mime-version:dkim-signature; bh=iJFcEa8Md91qPWXA3MXvjPfvCleZ0GnvsYYC4ySVP+o=; b=sI6Tve1nY1Ynn5nRARKm6FsfFCBMOxkOV/Qh/O7NJHQTUY3QSxBiLWmw1wgMe6bhFm vxhKES1SJ4WFHpfwteSP0zCmELTlVKcbT1rQOQAJaL9/jOsKobY7BDEGVN6D0CNZmloN 1GLe7UqHEvHRJv0GBG88PnxqAQj1jUxYSe9PQ7sKlTd9lrApRXpwpxwK/AibI8kZSvv/ SoXE/p8u3IIsXTkbK8hHLOO3KVNA3UFQC85F/KmZVMpz8YsggGMcGw4zAw6qd3blGqjU 7lbZ+pTkwkUYhu2SoGE9ZHrnebxHUws72xMyJaOqrjKv2TgZ83q74gjYKyXV2NEeqvyV lR3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oA7LpeV2; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb13si5606719edb.538.2021.02.26.01.07.50; Fri, 26 Feb 2021 01:08:16 -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=@gmail.com header.s=20161025 header.b=oA7LpeV2; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229999AbhBZJGh (ORCPT + 99 others); Fri, 26 Feb 2021 04:06:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbhBZJGR (ORCPT ); Fri, 26 Feb 2021 04:06:17 -0500 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AE9FC061574 for ; Fri, 26 Feb 2021 01:05:37 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id h18so7423773ils.2 for ; Fri, 26 Feb 2021 01:05:37 -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=bzIRoKqBIXrMqWUV5MfFssi+RWqzbG1M2IajqkQhIanvIRyu72lAiYmu8NPdhntExw BVccGZ5wb4ggTAjqIKWcFiWG9pOsIOTgcjdOYxTiJRLh5yQAujNi+3ZXimT8vCfMKNVh fgeP20Ql596qEyWa33qnhg/OL0SczmfDeay0DKTKZJd8n+zyONVpdqJhE3S5XNphsqxj WH2LhPHIqwQg4xOtxVIhMetgm2yQg+utiI+BQINbejk8diun0NHOIo3vvN6eFcLCHOn/ er2aLZDIA4yqXh0G8WAObkOhS010nBCKwpbXnpv/YHUpQ/druCiSw5DX/6aavsYv3rQn 0IBw== X-Gm-Message-State: AOAM533NYh9Zix0xRbEv1xNDNdRCaO0jrd1o+LP/5kV+U1jOFflG7DXp fXdcl4js1XgR+hVsyiB/mDQhZ3r5Vr9mqk7Af4Y= 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: Reply-To: sedat.dilek@gmail.com 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 Cc: Catalin Marinas , Will Deacon , Nathan Chancellor , Nick Desaulniers , Arnd Bergmann , Kees Cook , Mark Brown , Vincenzo Frascino , Geert Uytterhoeven , Kristina Martsenko , Ionela Voinescu , Mark Rutland , Andrew Scull , David Brazdil , Marc Zyngier , Ard Biesheuvel , Linux ARM , "linux-kernel@vger.kernel.org" , Clang-Built-Linux ML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 -