Several x86 files use ELF-related declarations and currently rely on them being provided indirectly through linux/module.h -> linux/elf.h: * arch/x86/entry/entry_fred.c: ia32_enabled() -> asm/ia32.h, * arch/x86/entry/syscall_32.c: vdso32_image -> asm/vdso.h, * arch/x86/kernel/cpu/intel.c: ELF_HWCAP2 -> asm/elf.h, * arch/x86/kernel/fpu/xstate.c: elf_coredump_extra_notes_write(), elf_coredump_extra_notes_size(), NT_X86_XSAVE_LAYOUT, elf_note -> linux/elf.h, * arch/x86/kernel/process.c: mmap_is_ia32() -> asm/elf.h, * arch/x86/kernel/signal.c: get_sigframe_size() -> asm/elf.h. Add the missing includes to these files in preparation for removing the linux/elf.h include from linux/module.h. Signed-off-by: Petr Pavlu --- 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 + 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/entry_fred.c b/arch/x86/entry/entry_fred.c index fb3594ddf731..ea3bb4298065 100644 --- a/arch/x86/entry/entry_fred.c +++ b/arch/x86/entry/entry_fred.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include diff --git a/arch/x86/entry/syscall_32.c b/arch/x86/entry/syscall_32.c index 31b9492fe851..12fceffc99ef 100644 --- a/arch/x86/entry/syscall_32.c +++ b/arch/x86/entry/syscall_32.c @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef CONFIG_IA32_EMULATION #define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, compat) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index abb3984336eb..18cf40f08557 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index a7b6524a9dea..8b90bf86a742 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -26,7 +27,6 @@ #include #include #include -#include #include diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 85435044e33c..e40f7f3d3489 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -54,6 +54,7 @@ #include #include #include +#include #include "process.h" diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index 2404233336ab..0fe2d7a6b1af 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include -- 2.54.0 Several s390 files use declarations that are provided indirectly through linux/module.h -> linux/elf.h: * arch/s390/kernel/nospec-branch.c: s390_kernel_write() -> linux/uaccess.h, * drivers/s390/char/uvdevice.c: copy_to_user(), copy_from_user(), put_user(), get_user() -> linux/uaccess.h; file_operations -> linux/fs.h. Add the missing includes to these files in preparation for removing the linux/elf.h include from linux/module.h. Signed-off-by: Petr Pavlu --- arch/s390/kernel/nospec-branch.c | 1 + drivers/s390/char/uvdevice.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/s390/kernel/nospec-branch.c b/arch/s390/kernel/nospec-branch.c index e11ec15960a1..b62da9e81e79 100644 --- a/arch/s390/kernel/nospec-branch.c +++ b/arch/s390/kernel/nospec-branch.c @@ -2,6 +2,7 @@ #include #include #include +#include #include int nobp = IS_ENABLED(CONFIG_KERNEL_NOBP); diff --git a/drivers/s390/char/uvdevice.c b/drivers/s390/char/uvdevice.c index e6a264c996ce..4fe3ead4a091 100644 --- a/drivers/s390/char/uvdevice.c +++ b/drivers/s390/char/uvdevice.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include -- 2.54.0 The drivers/char/tpm/tpm_crb_ffa.c file uses kzalloc_obj() and kfree(), which are declared in linux/slab.h. It currently relies on this header being included indirectly through linux/module.h -> linux/elf.h. Add the missing include in preparation for removing the linux/elf.h include from linux/module.h. Signed-off-by: Petr Pavlu --- drivers/char/tpm/tpm_crb_ffa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/char/tpm/tpm_crb_ffa.c b/drivers/char/tpm/tpm_crb_ffa.c index 025c4d4b17ca..af4466cdc297 100644 --- a/drivers/char/tpm/tpm_crb_ffa.c +++ b/drivers/char/tpm/tpm_crb_ffa.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "tpm_crb_ffa.h" static unsigned int busy_timeout_ms = 2000; -- 2.54.0 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. Signed-off-by: Petr Pavlu --- include/linux/module.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 7566815fabbe..7661faadbedd 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -29,8 +28,9 @@ #include #include #include - #include + +#include #include #define MODULE_NAME_LEN __MODULE_NAME_LEN -- 2.54.0