From: Petr Pavlu <petr.pavlu@suse.com>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Peter Huewe <peterhuewe@gmx.de>,
Jarkko Sakkinen <jarkko@kernel.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>
Cc: Xin Li <xin@zytor.com>, "H. Peter Anvin" <hpa@zytor.com>,
Andy Lutomirski <luto@kernel.org>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
David Hildenbrand <david@kernel.org>,
Jason Gunthorpe <jgg@ziepe.ca>,
Aaron Tomlin <atomlin@atomlin.com>,
linux-s390@vger.kernel.org, kvm@vger.kernel.org,
linux-integrity@vger.kernel.org, linux-modules@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/6] module: Limit ELF includes in linux/module.h to uapi/linux/elf.h
Date: Fri, 11 Sep 2026 16:40:30 +0200 [thread overview]
Message-ID: <20260911-module-include-elf-v2-0-954c732975fb@suse.com> (raw)
linux/module.h appears in roughly 15k #include directives across the
kernel. 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 five patches are cleanups to avoid relying on declarations being
indirectly provided through linux/module.h -> linux/elf.h. These patches
are mostly independent and can go through their respective trees if
preferred, except for the cpufeature patch, which depends on the preceding
s390 cleanup. The final module patch depends on all of 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.
---
Changes in v2:
- Rebase on top of v7.3-rc2.
- Add the missing include of linux/slab.h in
drivers/virt/coco/arm-cca-guest/arm-cca-guest.c.
- Remove the asm/mmu_context.h include from asm/elf.h on s390.
- Add the missing include of linux/elf.h in linux/cpufeature.h, reported by
the kernel test robot.
- Clean up commit descriptions.
- Link to v1: https://patch.msgid.link/20260707153819.4172541-1-petr.pavlu@suse.com
---
Petr Pavlu (6):
x86: Avoid indirect includes through linux/module.h -> linux/elf.h
s390: Avoid indirect includes through linux/module.h -> linux/elf.h
drivers: Include linux/slab.h for kmalloc() functions
s390: Remove the asm/mmu_context.h include from asm/elf.h
cpufeature: Include asm/elf.h for ELF_PLATFORM
module: Limit ELF includes in linux/module.h to uapi/linux/elf.h
arch/s390/include/asm/elf.h | 1 -
arch/s390/kernel/nospec-branch.c | 1 +
arch/s390/kernel/processor.c | 1 +
arch/s390/mm/mmap.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 ++
drivers/virt/coco/arm-cca-guest/arm-cca-guest.c | 1 +
include/linux/cpufeature.h | 1 +
include/linux/module.h | 4 ++--
15 files changed, 16 insertions(+), 4 deletions(-)
---
base-commit: df2908090cda368b01ff43709f51890076c56157
change-id: 20260816-module-include-elf-a9c10c041867
next reply other threads:[~2026-09-11 14:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 14:40 Petr Pavlu [this message]
2026-09-11 14:40 ` [PATCH v2 1/6] x86: Avoid indirect includes through linux/module.h -> linux/elf.h Petr Pavlu
2026-09-11 14:40 ` [PATCH v2 2/6] s390: " Petr Pavlu
2026-09-11 14:40 ` [PATCH v2 3/6] drivers: Include linux/slab.h for kmalloc() functions Petr Pavlu
2026-09-11 14:40 ` [PATCH v2 4/6] s390: Remove the asm/mmu_context.h include from asm/elf.h Petr Pavlu
2026-09-11 14:40 ` [PATCH v2 5/6] cpufeature: Include asm/elf.h for ELF_PLATFORM Petr Pavlu
2026-09-11 14:40 ` [PATCH v2 6/6] module: Limit ELF includes in linux/module.h to uapi/linux/elf.h Petr Pavlu
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=20260911-module-include-elf-v2-0-954c732975fb@suse.com \
--to=petr.pavlu@suse.com \
--cc=agordeev@linux.ibm.com \
--cc=atomlin@atomlin.com \
--cc=borntraeger@linux.ibm.com \
--cc=bp@alien8.de \
--cc=da.gomez@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hpa@zytor.com \
--cc=imbrenda@linux.ibm.com \
--cc=jarkko@kernel.org \
--cc=jgg@ziepe.ca \
--cc=kvm@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mcgrof@kernel.org \
--cc=mingo@redhat.com \
--cc=peterhuewe@gmx.de \
--cc=samitolvanen@google.com \
--cc=svens@linux.ibm.com \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
--cc=xin@zytor.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®