All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Pitre <nico@fluxnic.net>
To: Sedat Dilek <sedat.dilek@gmail.com>
Cc: Arnd Bergmann <arnd@kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Nicholas Piggin <npiggin@gmail.com>,
	Fangrui Song <maskray@google.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	Andrew Scull <ascull@google.com>, Mark Brown <broonie@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	David Brazdil <dbrazdil@google.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Ionela Voinescu <ionela.voinescu@arm.com>,
	Kees Cook <keescook@chromium.org>,
	Kristina Martsenko <kristina.martsenko@arm.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Marc Zyngier <maz@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	Will Deacon <will@kernel.org>
Subject: Re: [PATCH] [RFC] arm64: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION
Date: Wed, 10 Mar 2021 16:47:49 -0500 (EST)	[thread overview]
Message-ID: <ros2o1p7-r65q-n4p-3o38-oo36rr58q041@syhkavp.arg> (raw)
In-Reply-To: <CA+icZUWk-9i8BSf70qE_9f=mekscQ063q+aUKzSNBymNLAbcTA@mail.gmail.com>

On Wed, 10 Mar 2021, Sedat Dilek wrote:

> The best results on size-reduction of vmlinux I got with Clang-CFI on x86-64.
> 
> Clang-LTO and Clang-CFI:
> I was able to build with CONFIG_TRIM_UNUSED_KSYMS=y which needs to add
> a whitelist file or add a whitelist to scripts/gen_autoksyms.sh.
> And boot on bare metal.
> Furthermore, I was able to compile
> CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y with and without
> CONFIG_TRIM_UNUSED_KSYMS=y.
> Every kernel I had CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y does not boot.
> Yes, there is a size reduction with both enabled but not that good as
> with Clang-CFI.
> All testings with several iterations of LLVM/Clang v13-git.
> With CONFIG_TRIM_UNUSED_KSYMS=y I see a 3x-loops of building .version
> and folowing steps - got no answer if this is intended.

Yes it is intended. I explained it here:

https://lkml.org/lkml/2021/3/9/1099

With CONFIG_TRIM_UNUSED_KSYMS some EXPORT_SYMBOL() are removed, which 
allows for optimizing away the corresponding code, which in turn opens 
the possibility for more EXPORT_SYMBOL() to be removed, etc. The process 
eventually converge to a stable build. Normally only 2 passes are needed 
to converge, but LTO opens the possibilities for extra passes.

> Means longer build-time.

Oh, absolutely.  LTO (at least when I played with it) is slow. Add the 
multi-pass from CONFIG_TRIM_UNUSED_KSYMS on top of that and your kernel 
build becomes agonizingly slow. This is not something you want when 
doing kernel development.

> I did not follow this anymore as both Kconfigs with Clang-LTO consume
> more build-time and the resulting vmlinux is some MiB bigger than with
> Clang-CFI.

That's rather strange. At least with gcc LTO I always obtained smaller 
kernels.


Nicolas

WARNING: multiple messages have this Message-ID (diff)
From: Nicolas Pitre <nico@fluxnic.net>
To: Sedat Dilek <sedat.dilek@gmail.com>
Cc: Arnd Bergmann <arnd@kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	 Nicholas Piggin <npiggin@gmail.com>,
	Fangrui Song <maskray@google.com>,
	 Ard Biesheuvel <ardb@kernel.org>,
	Andrew Scull <ascull@google.com>,
	 Mark Brown <broonie@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	 clang-built-linux <clang-built-linux@googlegroups.com>,
	 David Brazdil <dbrazdil@google.com>,
	 Geert Uytterhoeven <geert+renesas@glider.be>,
	 Ionela Voinescu <ionela.voinescu@arm.com>,
	 Kees Cook <keescook@chromium.org>,
	 Kristina Martsenko <kristina.martsenko@arm.com>,
	 Linux ARM <linux-arm-kernel@lists.infradead.org>,
	 "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	 Mark Rutland <mark.rutland@arm.com>,
	Marc Zyngier <maz@kernel.org>,
	 Nathan Chancellor <nathan@kernel.org>,
	 Nick Desaulniers <ndesaulniers@google.com>,
	 Vincenzo Frascino <vincenzo.frascino@arm.com>,
	 Will Deacon <will@kernel.org>
Subject: Re: [PATCH] [RFC] arm64: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION
Date: Wed, 10 Mar 2021 16:47:49 -0500 (EST)	[thread overview]
Message-ID: <ros2o1p7-r65q-n4p-3o38-oo36rr58q041@syhkavp.arg> (raw)
In-Reply-To: <CA+icZUWk-9i8BSf70qE_9f=mekscQ063q+aUKzSNBymNLAbcTA@mail.gmail.com>

On Wed, 10 Mar 2021, Sedat Dilek wrote:

> The best results on size-reduction of vmlinux I got with Clang-CFI on x86-64.
> 
> Clang-LTO and Clang-CFI:
> I was able to build with CONFIG_TRIM_UNUSED_KSYMS=y which needs to add
> a whitelist file or add a whitelist to scripts/gen_autoksyms.sh.
> And boot on bare metal.
> Furthermore, I was able to compile
> CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y with and without
> CONFIG_TRIM_UNUSED_KSYMS=y.
> Every kernel I had CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y does not boot.
> Yes, there is a size reduction with both enabled but not that good as
> with Clang-CFI.
> All testings with several iterations of LLVM/Clang v13-git.
> With CONFIG_TRIM_UNUSED_KSYMS=y I see a 3x-loops of building .version
> and folowing steps - got no answer if this is intended.

Yes it is intended. I explained it here:

https://lkml.org/lkml/2021/3/9/1099

With CONFIG_TRIM_UNUSED_KSYMS some EXPORT_SYMBOL() are removed, which 
allows for optimizing away the corresponding code, which in turn opens 
the possibility for more EXPORT_SYMBOL() to be removed, etc. The process 
eventually converge to a stable build. Normally only 2 passes are needed 
to converge, but LTO opens the possibilities for extra passes.

> Means longer build-time.

Oh, absolutely.  LTO (at least when I played with it) is slow. Add the 
multi-pass from CONFIG_TRIM_UNUSED_KSYMS on top of that and your kernel 
build becomes agonizingly slow. This is not something you want when 
doing kernel development.

> I did not follow this anymore as both Kconfigs with Clang-LTO consume
> more build-time and the resulting vmlinux is some MiB bigger than with
> Clang-CFI.

That's rather strange. At least with gcc LTO I always obtained smaller 
kernels.


Nicolas

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-03-10 21:57 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25 11:20 [PATCH] [RFC] arm64: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION Arnd Bergmann
2021-02-25 11:20 ` Arnd Bergmann
2021-02-25 20:16 ` Kees Cook
2021-02-25 20:16   ` Kees Cook
2021-02-26  0:36 ` Sedat Dilek
2021-02-26  0:36   ` Sedat Dilek
2021-02-26  8:14   ` Arnd Bergmann
2021-02-26  8:14     ` Arnd Bergmann
2021-02-26  9:05     ` Sedat Dilek
2021-02-26  9:05       ` Sedat Dilek
2021-02-26  9:51       ` Arnd Bergmann
2021-02-26  9:51         ` Arnd Bergmann
2021-02-26 10:02         ` Sedat Dilek
2021-02-26 10:02           ` Sedat Dilek
2021-02-27 20:13           ` Sedat Dilek
2021-02-26 21:13 ` Fangrui Song
2021-02-26 21:13   ` Fangrui Song
2021-02-27  9:49   ` Arnd Bergmann
2021-02-27  9:49     ` Arnd Bergmann
2021-03-01  1:11     ` Nicholas Piggin
2021-03-01  1:11       ` Nicholas Piggin
2021-03-10 20:49       ` Masahiro Yamada
2021-03-10 20:49         ` Masahiro Yamada
2021-03-10 21:08         ` Arnd Bergmann
2021-03-10 21:08           ` Arnd Bergmann
2021-03-10 21:24           ` Sedat Dilek
2021-03-10 21:24             ` Sedat Dilek
2021-03-10 21:47             ` Nicolas Pitre [this message]
2021-03-10 21:47               ` Nicolas Pitre
2021-03-10 21:57               ` Sedat Dilek
2021-03-10 21:57                 ` Sedat Dilek
2021-03-10 22:02           ` Nick Desaulniers
2021-03-10 22:02             ` Nick Desaulniers
2021-03-10 22:08             ` Nicolas Pitre
2021-03-10 22:08               ` Nicolas Pitre
2021-03-10 22:29           ` Fangrui Song
2021-03-10 22:29             ` Fangrui Song
2021-03-10 21:45         ` Rasmus Villemoes
2021-03-10 21:45           ` Rasmus Villemoes
2021-03-10 21:19       ` Nicolas Pitre
2021-03-10 21:19         ` Nicolas Pitre
2021-03-10 22:42         ` Fangrui Song
2021-03-10 22:42           ` Fangrui Song
2021-03-17 14:37 ` Catalin Marinas
2021-03-17 14:37   ` Catalin Marinas
2021-03-17 16:18   ` Catalin Marinas
2021-03-17 16:18     ` Catalin Marinas
2021-03-18  8:41     ` Arnd Bergmann
2021-03-18  8:41       ` Arnd Bergmann
2021-03-19 12:25       ` Catalin Marinas
2021-03-19 12:25         ` Catalin Marinas
2021-03-19 14:01         ` Arnd Bergmann
2021-03-19 14:01           ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ros2o1p7-r65q-n4p-3o38-oo36rr58q041@syhkavp.arg \
    --to=nico@fluxnic.net \
    --cc=ardb@kernel.org \
    --cc=arnd@kernel.org \
    --cc=ascull@google.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=dbrazdil@google.com \
    --cc=geert+renesas@glider.be \
    --cc=ionela.voinescu@arm.com \
    --cc=keescook@chromium.org \
    --cc=kristina.martsenko@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=masahiroy@kernel.org \
    --cc=maskray@google.com \
    --cc=maz@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=npiggin@gmail.com \
    --cc=sedat.dilek@gmail.com \
    --cc=vincenzo.frascino@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.