Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH 0/4] module: Limit ELF includes in linux/module.h to uapi/linux/elf.h
@ 2026-07-07 15:37 Petr Pavlu
  2026-07-07 15:37 ` [PATCH 1/4] x86: Avoid indirect includes through linux/module.h -> linux/elf.h Petr Pavlu
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Petr Pavlu @ 2026-07-07 15:37 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Peter Huewe,
	Jarkko Sakkinen, Luis Chamberlain, Petr Pavlu, Daniel Gomez,
	Sami Tolvanen
  Cc: Xin Li, H. Peter Anvin, Andy Lutomirski, Christian Borntraeger,
	Sven Schnelle, Janosch Frank, Claudio Imbrenda, David Hildenbrand,
	Jason Gunthorpe, Aaron Tomlin, linux-s390, kvm, linux-integrity,
	linux-modules, linux-kernel

The linux/module.h header is included by every *.mod.c file to provide
`struct module` and other related definitions. This makes it a "hot"
header, so it should avoid pulling in unnecessary definitions.

The header currently includes linux/elf.h but this is largely unnecessary
because it requires only the base ELF structures, such as Elf_Ehdr and
Elf_Sym, which are declared in uapi/linux/elf.h.

Replace the linux/elf.h include with uapi/linux/elf.h. On x86_64_defconfig,
including linux/module.h alone results in 2.2 MB of preprocessed data. This
change reduces that to 1.5 MB.

The first three patches are cleanups to avoid relying on declarations being
indirectly provided through linux/module.h -> linux/elf.h. These patches
are all independent and can go through their respective trees. The final
patch depends on these changes.

It is hard to identify all files that indirectly reference something only
through linux/module.h -> linux/elf.h. The changes were build-tested with
allmodconfig on arm, arm64, m68k, mips, powerpc64, riscv, s390, x86_64.

Petr Pavlu (4):
  x86: Avoid indirect includes through linux/module.h -> linux/elf.h
  s390: Avoid indirect includes through linux/module.h -> linux/elf.h
  tpm_crb_ffa: Include linux/slab.h for kzalloc_obj() and kfree()
  module: Limit ELF includes in linux/module.h to uapi/linux/elf.h

 arch/s390/kernel/nospec-branch.c | 1 +
 arch/x86/entry/entry_fred.c      | 1 +
 arch/x86/entry/syscall_32.c      | 1 +
 arch/x86/kernel/cpu/intel.c      | 1 +
 arch/x86/kernel/fpu/xstate.c     | 2 +-
 arch/x86/kernel/process.c        | 1 +
 arch/x86/kernel/signal.c         | 1 +
 drivers/char/tpm/tpm_crb_ffa.c   | 1 +
 drivers/s390/char/uvdevice.c     | 2 ++
 include/linux/module.h           | 4 ++--
 10 files changed, 12 insertions(+), 3 deletions(-)

-- 
2.54.0


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

end of thread, other threads:[~2026-07-08 10:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 15:37 [PATCH 0/4] module: Limit ELF includes in linux/module.h to uapi/linux/elf.h Petr Pavlu
2026-07-07 15:37 ` [PATCH 1/4] x86: Avoid indirect includes through linux/module.h -> linux/elf.h Petr Pavlu
2026-07-07 15:37 ` [PATCH 2/4] s390: " Petr Pavlu
2026-07-07 15:37 ` [PATCH 3/4] tpm_crb_ffa: Include linux/slab.h for kzalloc_obj() and kfree() Petr Pavlu
2026-07-07 15:43   ` sashiko-bot
2026-07-08 10:10     ` Petr Pavlu
2026-07-07 15:37 ` [PATCH 4/4] module: Limit ELF includes in linux/module.h to uapi/linux/elf.h Petr Pavlu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox