All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/46] gcc-LTO support for the kernel
@ 2022-11-14 11:42 Jiri Slaby (SUSE)
  2022-11-14 11:42 ` [PATCH 01/46] x86/boot: robustify calling startup_{32,64}() from the decompressor code Jiri Slaby (SUSE)
                   ` (47 more replies)
  0 siblings, 48 replies; 87+ messages in thread
From: Jiri Slaby (SUSE) @ 2022-11-14 11:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Slaby (SUSE),
	Alexander Potapenko, Alexander Shishkin, Alexei Starovoitov,
	Alexey Makhalov, Andrew Morton, Andrey Konovalov,
	Andrey Ryabinin, Andrii Nakryiko, Andy Lutomirski,
	Ard Biesheuvel, Arnaldo Carvalho de Melo, Ben Segall,
	Borislav Petkov, Daniel Borkmann, Daniel Bristot de Oliveira,
	Dave Hansen, Dietmar Eggemann, Dmitry Vyukov, Don Zickus,
	Hao Luo, H . J . Lu, H. Peter Anvin, Huang Rui, Ingo Molnar,
	Jan Hubicka, Jason Baron, Jiri Kosina, Jiri Olsa, Joe Lawrence,
	John Fastabend, Josh Poimboeuf, Juergen Gross, Juri Lelli,
	KP Singh, Mark Rutland, Martin KaFai Lau, Martin Liska,
	Masahiro Yamada, Mel Gorman, Miguel Ojeda, Michal Marek,
	Miroslav Benes, Namhyung Kim, Nick Desaulniers,
	Oleksandr Tyshchenko, Peter Zijlstra, Petr Mladek,
	Rafael J. Wysocki, Richard Biener, Sedat Dilek, Song Liu,
	Stanislav Fomichev, Stefano Stabellini, Steven Rostedt,
	Thomas Gleixner, Valentin Schneider, Vincent Guittot,
	Vincenzo Frascino, Viresh Kumar, VMware PV-Drivers Reviewers,
	Yonghong Song

Hi,

this is the first call for comments (and kbuild complaints) for this
support of gcc (full) LTO in the kernel. Most of the patches come from
Andi. Me and Martin rebased them to new kernels and fixed the to-use
known issues. Also I updated most of the commit logs and reordered the
patches to groups of patches with similar intent.

The very first patch comes from Alexander and is pending on some x86
queue already (I believe). I am attaching it only for completeness.
Without that, the kernel does not boot (LTO reorders a lot).

In our measurements, the performance differences are negligible.

The kernel is bigger with gcc LTO due to more inlining. The next step
might be to play with non-static functions as we export everything, so
the compiler cannot actually drop anything (esp. inlined and no longer
needed functions).

Cc: Alexander Potapenko <glider@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Alexey Makhalov <amakhalov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ben Segall <bsegall@google.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Hao Luo <haoluo@google.com>
Cc: H.J. Lu <hjl.tools@gmail.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Huang Rui <ray.huang@amd.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jan Hubicka <jh@suse.de>
Cc: Jason Baron <jbaron@akamai.com>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Joe Lawrence <joe.lawrence@redhat.com>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Juergen Gross <jgross@suse.com>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Martin KaFai Lau <martin.lau@linux.dev>
Cc: Martin Liska <mliska@suse.cz>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Miroslav Benes <mbenes@suse.cz>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Petr Mladek <pmladek@suse.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Richard Biener <RGuenther@suse.com>
Cc: Sedat Dilek <sedat.dilek@gmail.com>
Cc: Song Liu <song@kernel.org>
Cc: Stanislav Fomichev <sdf@google.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: VMware PV-Drivers Reviewers <pv-drivers@vmware.com>
Cc: Yonghong Song <yhs@fb.com>

Alexander Lobakin (1):
  x86/boot: robustify calling startup_{32,64}() from the decompressor
    code

Andi Kleen (36):
  Compiler Attributes, lto: introduce __noreorder
  tracepoint, lto: Mark static call functions as __visible
  static_call, lto: Mark static keys as __visible
  static_call, lto: Mark static_call_return0() as __visible
  static_call, lto: Mark func_a() as __visible_on_lto
  x86/alternative, lto: Mark int3_*() as global and __visible
  x86/paravirt, lto: Mark native_steal_clock() as __visible_on_lto
  x86/preempt, lto: Mark preempt_schedule_*thunk() as __visible
  x86/xen, lto: Mark xen_vcpu_stolen() as __visible
  x86, lto: Mark gdt_page and native_sched_clock() as __visible
  amd, lto: Mark amd pmu and pstate functions as __visible_on_lto
  entry, lto: Mark raw_irqentry_exit_cond_resched() as __visible
  export, lto: Mark __kstrtab* in EXPORT_SYMBOL() as global and
    __visible
  softirq, lto: Mark irq_enter/exit_rcu() as __visible
  btf, lto: Make all BTF IDs global on LTO
  init.h, lto: mark initcalls as __noreorder
  bpf, lto: mark interpreter jump table as __noreorder
  sched, lto: mark sched classes as __noreorder
  linkage, lto: use C version for SYSCALL_ALIAS() / cond_syscall()
  scripts, lto: re-add gcc-ld
  scripts, lto: use CONFIG_LTO for many LTO specific actions
  Kbuild, lto: Add Link Time Optimization support
  x86/purgatory, lto: Disable gcc LTO for purgatory
  x86/realmode, lto: Disable gcc LTO for real mode code
  x86/vdso, lto: Disable gcc LTO for the vdso
  scripts, lto: disable gcc LTO for some mod sources
  Kbuild, lto: disable gcc LTO for bounds+asm-offsets
  lib/string, lto: disable gcc LTO for string.o
  Compiler attributes, lto: disable __flatten with LTO
  Kbuild, lto: don't include weak source file symbols in System.map
  x86, lto: Disable relative init pointers with gcc LTO
  x86/livepatch, lto: Disable live patching with gcc LTO
  x86/lib, lto: Mark 32bit mem{cpy,move,set} as __used
  scripts, lto: check C symbols for modversions
  scripts/bloat-o-meter, lto: handle gcc LTO
  x86, lto: Finally enable gcc LTO for x86

Jiri Slaby (5):
  kbuild: pass jobserver to cmd_ld_vmlinux.o
  compiler.h: introduce __visible_on_lto
  compiler.h: introduce __global_on_lto
  btf, lto: pass scope as strings
  x86/apic, lto: Mark apic_driver*() as __noreorder

Martin Liska (4):
  kbuild: lto: preserve MAKEFLAGS for module linking
  x86/sev, lto: Mark cpuid_table_copy as __visible_on_lto
  mm/kasan, lto: Mark kasan mem{cpy,move,set} as __used
  kasan, lto: remove extra BUILD_BUG() in memory_is_poisoned

 Documentation/kbuild/index.rst      |  2 +
 Documentation/kbuild/lto-build.rst  | 76 +++++++++++++++++++++++++++++
 Kbuild                              |  3 ++
 Makefile                            |  6 ++-
 arch/Kconfig                        | 52 ++++++++++++++++++++
 arch/x86/Kconfig                    |  5 +-
 arch/x86/boot/compressed/head_32.S  |  2 +-
 arch/x86/boot/compressed/head_64.S  |  2 +-
 arch/x86/boot/compressed/misc.c     | 16 +++---
 arch/x86/entry/vdso/Makefile        |  2 +
 arch/x86/events/amd/core.c          |  2 +-
 arch/x86/include/asm/apic.h         |  4 +-
 arch/x86/include/asm/preempt.h      |  4 +-
 arch/x86/kernel/alternative.c       |  5 +-
 arch/x86/kernel/cpu/common.c        |  2 +-
 arch/x86/kernel/paravirt.c          |  2 +-
 arch/x86/kernel/sev-shared.c        |  2 +-
 arch/x86/kernel/tsc.c               |  2 +-
 arch/x86/lib/memcpy_32.c            |  6 +--
 arch/x86/purgatory/Makefile         |  2 +
 arch/x86/realmode/Makefile          |  1 +
 drivers/cpufreq/amd-pstate.c        | 15 +++---
 drivers/xen/time.c                  |  2 +-
 include/asm-generic/vmlinux.lds.h   |  2 +-
 include/linux/btf_ids.h             | 24 ++++-----
 include/linux/compiler.h            |  8 +++
 include/linux/compiler_attributes.h | 15 ++++++
 include/linux/export.h              |  6 ++-
 include/linux/init.h                |  2 +-
 include/linux/linkage.h             | 16 +++---
 include/linux/static_call.h         | 12 ++---
 include/linux/tracepoint.h          |  4 +-
 kernel/bpf/core.c                   |  2 +-
 kernel/entry/common.c               |  2 +-
 kernel/kallsyms.c                   |  2 +-
 kernel/livepatch/Kconfig            |  1 +
 kernel/sched/sched.h                |  1 +
 kernel/softirq.c                    |  4 +-
 kernel/static_call.c                |  2 +-
 kernel/static_call_inline.c         |  6 +--
 kernel/time/posix-stubs.c           | 19 +++++++-
 lib/Makefile                        |  2 +
 mm/kasan/generic.c                  |  2 +-
 mm/kasan/shadow.c                   |  6 +--
 scripts/Makefile.build              | 17 ++++---
 scripts/Makefile.lib                |  2 +-
 scripts/Makefile.lto                | 43 ++++++++++++++++
 scripts/Makefile.modfinal           |  2 +-
 scripts/Makefile.vmlinux            |  3 +-
 scripts/Makefile.vmlinux_o          |  6 +--
 scripts/bloat-o-meter               |  2 +-
 scripts/gcc-ld                      | 40 +++++++++++++++
 scripts/link-vmlinux.sh             |  9 ++--
 scripts/mksysmap                    |  2 +
 scripts/mod/Makefile                |  3 ++
 scripts/module.lds.S                |  2 +-
 56 files changed, 384 insertions(+), 100 deletions(-)
 create mode 100644 Documentation/kbuild/lto-build.rst
 create mode 100644 scripts/Makefile.lto
 create mode 100755 scripts/gcc-ld

-- 
2.38.1


^ permalink raw reply	[flat|nested] 87+ messages in thread

end of thread, other threads:[~2022-11-26 17:08 UTC | newest]

Thread overview: 87+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 11:42 [PATCH 00/46] gcc-LTO support for the kernel Jiri Slaby (SUSE)
2022-11-14 11:42 ` [PATCH 01/46] x86/boot: robustify calling startup_{32,64}() from the decompressor code Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 02/46] kbuild: pass jobserver to cmd_ld_vmlinux.o Jiri Slaby (SUSE)
2022-11-14 17:57   ` Masahiro Yamada
2022-11-15  6:36     ` Jiri Slaby
2022-11-14 11:43 ` [PATCH 03/46] kbuild: lto: preserve MAKEFLAGS for module linking Jiri Slaby (SUSE)
2022-11-14 18:02   ` Masahiro Yamada
2022-11-14 11:43 ` [PATCH 04/46] compiler.h: introduce __visible_on_lto Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 05/46] compiler.h: introduce __global_on_lto Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 06/46] Compiler Attributes, lto: introduce __noreorder Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 07/46] tracepoint, lto: Mark static call functions as __visible Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 08/46] static_call, lto: Mark static keys " Jiri Slaby (SUSE)
2022-11-14 15:51   ` Peter Zijlstra
2022-11-14 18:52     ` Josh Poimboeuf
2022-11-14 20:34     ` Andi Kleen
2022-11-17  8:24       ` Peter Zijlstra
2022-11-14 18:57   ` Josh Poimboeuf
2022-11-14 11:43 ` [PATCH 09/46] static_call, lto: Mark static_call_return0() " Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 10/46] static_call, lto: Mark func_a() as __visible_on_lto Jiri Slaby (SUSE)
2022-11-14 15:54   ` Peter Zijlstra
2022-11-14 20:29     ` Andi Kleen
2022-11-14 11:43 ` [PATCH 11/46] x86/alternative, lto: Mark int3_*() as global and __visible Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 12/46] x86/paravirt, lto: Mark native_steal_clock() as __visible_on_lto Jiri Slaby (SUSE)
2022-11-14 15:58   ` Peter Zijlstra
2022-11-14 11:43 ` [PATCH 13/46] x86/preempt, lto: Mark preempt_schedule_*thunk() as __visible Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 14/46] x86/sev, lto: Mark cpuid_table_copy as __visible_on_lto Jiri Slaby (SUSE)
2022-11-14 16:02   ` Peter Zijlstra
2022-11-14 11:43 ` [PATCH 15/46] x86/xen, lto: Mark xen_vcpu_stolen() as __visible Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 16/46] x86, lto: Mark gdt_page and native_sched_clock() " Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 17/46] amd, lto: Mark amd pmu and pstate functions as __visible_on_lto Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 18/46] entry, lto: Mark raw_irqentry_exit_cond_resched() as __visible Jiri Slaby (SUSE)
2022-11-16 23:30   ` Thomas Gleixner
2022-11-17  8:40     ` Peter Zijlstra
2022-11-17 22:07       ` Andi Kleen
2022-11-18  1:28         ` Thomas Gleixner
2022-11-19  0:50           ` Andi Kleen
2022-11-19  8:50             ` Thomas Gleixner
2022-11-22  9:32     ` Jiri Slaby
2022-11-14 11:43 ` [PATCH 19/46] export, lto: Mark __kstrtab* in EXPORT_SYMBOL() as global and __visible Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 20/46] softirq, lto: Mark irq_enter/exit_rcu() as __visible Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 21/46] btf, lto: pass scope as strings Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 22/46] btf, lto: Make all BTF IDs global on LTO Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 23/46] init.h, lto: mark initcalls as __noreorder Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 24/46] bpf, lto: mark interpreter jump table " Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 25/46] sched, lto: mark sched classes " Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 26/46] x86/apic, lto: Mark apic_driver*() " Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 27/46] linkage, lto: use C version for SYSCALL_ALIAS() / cond_syscall() Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 28/46] scripts, lto: re-add gcc-ld Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 29/46] scripts, lto: use CONFIG_LTO for many LTO specific actions Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 30/46] Kbuild, lto: Add Link Time Optimization support Jiri Slaby (SUSE)
2022-11-14 18:55   ` Josh Poimboeuf
2022-11-15 13:31     ` Martin Liška
2022-11-14 11:43 ` [PATCH 31/46] x86/purgatory, lto: Disable gcc LTO for purgatory Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 32/46] x86/realmode, lto: Disable gcc LTO for real mode code Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 33/46] x86/vdso, lto: Disable gcc LTO for the vdso Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 34/46] scripts, lto: disable gcc LTO for some mod sources Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 35/46] Kbuild, lto: disable gcc LTO for bounds+asm-offsets Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 36/46] lib/string, lto: disable gcc LTO for string.o Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 37/46] Compiler attributes, lto: disable __flatten with LTO Jiri Slaby (SUSE)
2022-11-14 17:01   ` Miguel Ojeda
2022-11-14 11:43 ` [PATCH 38/46] Kbuild, lto: don't include weak source file symbols in System.map Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 39/46] x86, lto: Disable relative init pointers with gcc LTO Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 40/46] x86/livepatch, lto: Disable live patching " Jiri Slaby (SUSE)
2022-11-14 19:07   ` Josh Poimboeuf
2022-11-14 20:28     ` Andi Kleen
2022-11-14 22:00       ` Josh Poimboeuf
2022-11-15 13:32         ` Martin Liška
2022-11-17 20:00   ` Song Liu
2022-11-14 11:43 ` [PATCH 41/46] x86/lib, lto: Mark 32bit mem{cpy,move,set} as __used Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 42/46] mm/kasan, lto: Mark kasan " Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 43/46] scripts, lto: check C symbols for modversions Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 44/46] scripts/bloat-o-meter, lto: handle gcc LTO Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 45/46] kasan, lto: remove extra BUILD_BUG() in memory_is_poisoned Jiri Slaby (SUSE)
2022-11-26 17:07   ` Andrey Konovalov
2022-11-14 11:43 ` [PATCH 46/46] x86, lto: Finally enable gcc LTO for x86 Jiri Slaby (SUSE)
2022-11-14 11:56 ` [PATCH 00/46] gcc-LTO support for the kernel Ard Biesheuvel
2022-11-14 12:04   ` Jiri Slaby
2022-11-14 19:40 ` Ard Biesheuvel
2022-11-17  8:28   ` Peter Zijlstra
2022-11-17  8:50     ` Richard Biener
2022-11-17 11:42       ` Peter Zijlstra
2022-11-17 11:49         ` Ard Biesheuvel
2022-11-17 13:55           ` Richard Biener
2022-11-17 14:32             ` Peter Zijlstra
2022-11-17 14:40               ` Richard Biener
2022-11-17 15:15             ` Ard Biesheuvel
2022-11-17 11:48       ` Thomas Gleixner

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.