s390: audit and remove needless module.h includes
Subsystems (4)
cover s390: audit and remove needless module.h includes
Originally module.h provided support for both what was modular code and what was providing support to modules via EXPORT_SYMBOL and friends.
That changed when we forked out support for the latter into the export.h header; roughly five years ago[1].
We dealt with the immediate fallout of that change back then, but we did not go through and "downgrade" all the non-modular module.h users to export.h, once the merge of that change enabled us to do so.
This means we should be able to reduce the usage of module.h in code that is obj-y Makefile or bool Kconfig. In the case of some of these which are modular, we can extend that to also include files that are building basic support functionality but not related to loading or registering the final module; such files also have no need whatsoever for module.h
The advantage in removing such instances is that module.h itself sources about 15 other headers; adding significantly to what we feed cpp, and it can obscure what headers we are effectively using.
Consider the following pseudo patch to introduce a no-op source that just includes module.h:
diff --git a/init/Makefile b/init/Makefile
--- a/init/Makefile
+++ b/init/Makefile
@@ -2,7 +2,7 @@
-obj-y := main.o version.o mounts.o
+obj-y := main.o version.o mounts.o foo.o
diff --git a/init/foo.c b/init/foo.c
new file mode 100644
--- /dev/null
+++ b/init/foo.c
@@ -0,0 +1 @@
+#include <linux/module.h>With that in place, we then can see the impact with this:
paul@builder:~/git/linux-head$ make O=../build/ init/foo.i
make[1]: Entering directory '/home/paul/git/build'
CPP init/foo.ipaul@builder:~/git/linux-head$ ls -lh ../build/init/foo.i -rw-rw-r-- 1 paul paul 754K Jul 12 20:04 ../build/init/foo.i
So, with every module.h include, we guarantee a minimum of 3/4 of a MB of text output from cpp as the baseline of header preamble to process.
Repeating the same experiment with <linux/init.h> and the result is less than 12kB; with <linux/export.h> it is only about 1/2kB; with both it still is less than 12kB.
Since module.h might be the implicit source for init.h (for __init) and for export.h (for EXPORT_SYMBOL) we consider each instance for the requirement of either and replace as needed. Some additional implicit include issues were also fixed up as they appeared during build coverage.
The series was done on a per directory level for the larger dirs and then we tackle the remainder in the final commit. This seemed like a better solution than one giant commit.
There is no urgency to get this in tree, it can easily wait three weeks. That said, the risk here is entirely on introducing build failures -- there is no changes to generated code, so if build coverage is exhaustive, the risk should be zero.
To that end, I have done allmodconfig, allyesconfig and allnoconfig for s390 with these changes on the linux-next from today. We've already merged the changes from similar audits for x86 and other supported architectures, so this isn't a new issue.
Paul.
[1] https://lwn.net/Articles/453517/
---
Paul Gortmaker (3):
s390: kernel: Audit and remove any unnecessary uses of module.h
s390: mm: Audit and remove any unnecessary uses of module.h
s390: Audit and remove any remaining unnecessary uses of module.h
arch/s390/include/asm/livepatch.h | 2 +- arch/s390/kernel/compat_linux.c | 1 - arch/s390/kernel/cpcmd.c | 2 +- arch/s390/kernel/crash_dump.c | 3 ++- arch/s390/kernel/debug.c | 2 +- arch/s390/kernel/diag.c | 3 ++- arch/s390/kernel/dis.c | 2 +- arch/s390/kernel/ebcdic.c | 4 ++-- arch/s390/kernel/ipl.c | 3 ++- arch/s390/kernel/irq.c | 3 ++- arch/s390/kernel/jump_label.c | 1 - arch/s390/kernel/nmi.c | 2 +- arch/s390/kernel/process.c | 2 +- arch/s390/kernel/smp.c | 2 +- arch/s390/kernel/stacktrace.c | 2 +- arch/s390/kernel/sysinfo.c | 2 +- arch/s390/kernel/time.c | 2 +- arch/s390/kernel/vdso.c | 2 +- arch/s390/kvm/kvm-s390.c | 1 + arch/s390/lib/delay.c | 2 +- arch/s390/lib/spinlock.c | 2 +- arch/s390/lib/string.c | 3 ++- arch/s390/lib/xor.c | 2 +- arch/s390/mm/cmm.c | 1 + arch/s390/mm/dump_pagetables.c | 1 - arch/s390/mm/extmem.c | 2 +- arch/s390/mm/mem_detect.c | 1 - arch/s390/mm/mmap.c | 2 +- arch/s390/mm/pageattr.c | 1 - arch/s390/mm/vmem.c | 2 +- 30 files changed, 31 insertions(+), 29 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/3 s390: kernel: Audit and remove any unnecessary uses of module.h
Historically a lot of these existed because we did not have a distinction between what was modular code and what was providing support to modules via EXPORT_SYMBOL and friends. That changed when we forked out support for the latter into the export.h file.
This means we should be able to reduce the usage of module.h in code that is obj-y Makefile or bool Kconfig. The advantage in doing so is that module.h itself sources about 15 other headers; adding significantly to what we feed cpp, and it can obscure what headers we are effectively using.
Since module.h was the source for init.h (for __init) and for export.h (for EXPORT_SYMBOL) we consider each change instance for the presence of either and replace as needed. Build testing revealed some implicit header usage that was fixed up accordingly.
--- arch/s390/kernel/compat_linux.c | 1 - arch/s390/kernel/cpcmd.c | 2 +- arch/s390/kernel/crash_dump.c | 3 ++- arch/s390/kernel/debug.c | 2 +- arch/s390/kernel/diag.c | 3 ++- arch/s390/kernel/dis.c | 2 +- arch/s390/kernel/ebcdic.c | 4 ++-- arch/s390/kernel/ipl.c | 3 ++- arch/s390/kernel/irq.c | 3 ++- arch/s390/kernel/jump_label.c | 1 - arch/s390/kernel/nmi.c | 2 +- arch/s390/kernel/process.c | 2 +- arch/s390/kernel/smp.c | 2 +- arch/s390/kernel/stacktrace.c | 2 +- arch/s390/kernel/sysinfo.c | 2 +- arch/s390/kernel/time.c | 2 +- arch/s390/kernel/vdso.c | 2 +- 17 files changed, 20 insertions(+), 18 deletions(-)
arch/s390/kernel/compat_linux.c +0 -1
@@ -28,7 +28,6 @@#include <linux/shm.h> #include <linux/uio.h> #include <linux/quota.h> -#include <linux/module.h> #include <linux/poll.h> #include <linux/personality.h> #include <linux/stat.h>
arch/s390/kernel/cpcmd.c +1 -1
@@ -9,7 +9,7 @@#define pr_fmt (fmt) KMSG_COMPONENT ": " fmt#include <linux/kernel.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/stddef.h>
arch/s390/kernel/crash_dump.c +2 -1
@@ -8,7 +8,8 @@#include <linux/crash_dump.h> #include <asm/lowcore.h> #include <linux/kernel.h> -#include <linux/module.h> +#include <linux/init.h> +#include <linux/mm.h> #include <linux/gfp.h> #include <linux/slab.h> #include <linux/bootmem.h>
arch/s390/kernel/debug.c +1 -1
@@ -20,7 +20,7 @@#include <linux/string.h> #include <linux/sysctl.h> #include <linux/uaccess.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/debugfs.h>
arch/s390/kernel/diag.c +2 -1
@@ -5,7 +5,8 @@* Author(s): Michael Holzheu <[email protected]> */ -#include <linux/module.h> +#include <linux/export.h> +#include <linux/init.h> #include <linux/cpu.h> #include <linux/seq_file.h> #include <linux/debugfs.h>
arch/s390/kernel/dis.c +1 -1
@@ -16,7 +16,7 @@#include <linux/init.h> #include <linux/interrupt.h> #include <linux/delay.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/kallsyms.h> #include <linux/reboot.h> #include <linux/kprobes.h>
arch/s390/kernel/ebcdic.c +2 -2
@@ -8,8 +8,8 @@* Martin Peschke <[email protected]> */ -#include <linux/module.h> -#include <asm/types.h> +#include <linux/types.h> +#include <linux/export.h> #include <asm/ebcdic.h> /*
arch/s390/kernel/ipl.c +2 -1
@@ -8,7 +8,8 @@*/ #include <linux/types.h> -#include <linux/module.h> +#include <linux/export.h> +#include <linux/init.h> #include <linux/device.h> #include <linux/delay.h> #include <linux/reboot.h>
arch/s390/kernel/irq.c +2 -1
@@ -12,11 +12,12 @@#include <linux/seq_file.h> #include <linux/proc_fs.h> #include <linux/profile.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/kernel.h> #include <linux/ftrace.h> #include <linux/errno.h> #include <linux/slab.h> +#include <linux/init.h> #include <linux/cpu.h> #include <linux/irq.h> #include <asm/irq_regs.h>
arch/s390/kernel/jump_label.c +0 -1
@@ -4,7 +4,6 @@* Copyright IBM Corp. 2011 * Author(s): Jan Glauber <[email protected]> */ -#include <linux/module.h> #include <linux/uaccess.h> #include <linux/stop_machine.h> #include <linux/jump_label.h>
arch/s390/kernel/nmi.c +1 -1
@@ -13,7 +13,7 @@#include <linux/errno.h> #include <linux/hardirq.h> #include <linux/time.h> -#include <linux/module.h> +#include <linux/export.h> #include <asm/lowcore.h> #include <asm/smp.h> #include <asm/stp.h>
arch/s390/kernel/process.c +1 -1
@@ -23,7 +23,7 @@#include <linux/compat.h> #include <linux/kprobes.h> #include <linux/random.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/init_task.h> #include <asm/io.h> #include <asm/processor.h>
arch/s390/kernel/smp.c +1 -1
@@ -20,7 +20,7 @@#include <linux/workqueue.h> #include <linux/bootmem.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/init.h> #include <linux/mm.h> #include <linux/err.h>
arch/s390/kernel/stacktrace.c +1 -1
@@ -8,7 +8,7 @@#include <linux/sched.h> #include <linux/stacktrace.h> #include <linux/kallsyms.h> -#include <linux/module.h> +#include <linux/export.h> static int __save_address (void *data,unsigned long address,int nosched) {
arch/s390/kernel/sysinfo.c +1 -1
@@ -10,7 +10,7 @@#include <linux/seq_file.h> #include <linux/init.h> #include <linux/delay.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/slab.h> #include <asm/ebcdic.h> #include <asm/sysinfo.h>
arch/s390/kernel/time.c +1 -1
@@ -16,7 +16,7 @@#include <linux/kernel_stat.h> #include <linux/errno.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/sched.h> #include <linux/kernel.h> #include <linux/param.h>
arch/s390/kernel/vdso.c +1 -1
@@ -9,7 +9,7 @@* as published by the Free Software Foundation. */ -#include <linux/module.h> +#include <linux/init.h> #include <linux/errno.h> #include <linux/sched.h> #include <linux/kernel.h>
Signature · 1 line
2.11.0
PATCH 2/3 s390: mm: Audit and remove any unnecessary uses of module.h
In reply to Paul GortmakerHistorically a lot of these existed because we did not have a distinction between what was modular code and what was providing support to modules via EXPORT_SYMBOL and friends. That changed when we forked out support for the latter into the export.h file.
This means we should be able to reduce the usage of module.h in code that is obj-y Makefile or bool Kconfig. The advantage in doing so is that module.h itself sources about 15 other headers; adding significantly to what we feed cpp, and it can obscure what headers we are effectively using.
Since module.h was the source for init.h (for __init) and for export.h (for EXPORT_SYMBOL) we consider each change instance for the presence of either and replace as needed. An instance where module_param was used without moduleparam.h was also fixed, as well as an implict use of asm/elf.h header.
--- arch/s390/mm/cmm.c | 1 + arch/s390/mm/dump_pagetables.c | 1 - arch/s390/mm/extmem.c | 2 +- arch/s390/mm/mem_detect.c | 1 - arch/s390/mm/mmap.c | 2 +- arch/s390/mm/pageattr.c | 1 - arch/s390/mm/vmem.c | 2 +- 7 files changed, 4 insertions(+), 6 deletions(-)
arch/s390/mm/cmm.c +1 -0
@@ -10,6 +10,7 @@#include <linux/fs.h> #include <linux/init.h> #include <linux/module.h> +#include <linux/moduleparam.h> #include <linux/gfp.h> #include <linux/sched.h> #include <linux/sysctl.h>
arch/s390/mm/dump_pagetables.c +0 -1
@@ -1,6 +1,5 @@#include <linux/seq_file.h> #include <linux/debugfs.h> -#include <linux/module.h> #include <linux/mm.h> #include <asm/sections.h> #include <asm/pgtable.h>
arch/s390/mm/extmem.c +1 -1
@@ -14,7 +14,7 @@#include <linux/spinlock.h> #include <linux/list.h> #include <linux/slab.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/bootmem.h> #include <linux/ctype.h> #include <linux/ioport.h>
arch/s390/mm/mem_detect.c +0 -1
@@ -5,7 +5,6 @@*/ #include <linux/kernel.h> -#include <linux/module.h> #include <linux/memblock.h> #include <linux/init.h> #include <linux/debugfs.h>
arch/s390/mm/mmap.c +1 -1
@@ -26,11 +26,11 @@#include <linux/personality.h> #include <linux/mm.h> #include <linux/mman.h> -#include <linux/module.h> #include <linux/random.h> #include <linux/compat.h> #include <linux/security.h> #include <asm/pgalloc.h> +#include <asm/elf.h> static unsigned long stack_maxrandom_size (void ) {
arch/s390/mm/pageattr.c +0 -1
@@ -3,7 +3,6 @@* Author(s): Jan Glauber <[email protected]> */ #include <linux/hugetlb.h> -#include <linux/module.h> #include <linux/mm.h> #include <asm/cacheflush.h> #include <asm/facility.h>
arch/s390/mm/vmem.c +1 -1
@@ -6,7 +6,7 @@#include <linux/bootmem.h> #include <linux/pfn.h> #include <linux/mm.h> -#include <linux/module.h> +#include <linux/init.h> #include <linux/list.h> #include <linux/hugetlb.h> #include <linux/slab.h>
Signature · 1 line
2.11.0
PATCH 3/3 s390: Audit and remove any remaining unnecessary uses of module.h
In reply to Paul GortmakerHistorically a lot of these existed because we did not have a distinction between what was modular code and what was providing support to modules via EXPORT_SYMBOL and friends. That changed when we forked out support for the latter into the export.h file.
This means we should be able to reduce the usage of module.h in code that is obj-y Makefile or bool Kconfig. The advantage in doing so is that module.h itself sources about 15 other headers; adding significantly to what we feed cpp, and it can obscure what headers we are effectively using.
Since module.h was the source for init.h (for __init) and for export.h (for EXPORT_SYMBOL) we consider each change instance for the presence of either and replace as needed. An instance where module_param was used without moduleparam.h was also fixed, as well as implicit use of ptrace.h and string.h headers.
--- arch/s390/include/asm/livepatch.h | 2 +- arch/s390/kvm/kvm-s390.c | 1 + arch/s390/lib/delay.c | 2 +- arch/s390/lib/spinlock.c | 2 +- arch/s390/lib/string.c | 3 ++- arch/s390/lib/xor.c | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-)
arch/s390/include/asm/livepatch.h +1 -1
@@ -17,7 +17,7 @@#ifndef ASM_LIVEPATCH_H #define ASM_LIVEPATCH_H -#include <linux/module.h> +#include <asm/ptrace.h> static inline int klp_check_compiler_support (void ) {
arch/s390/kvm/kvm-s390.c +1 -0
@@ -23,6 +23,7 @@#include <linux/kvm_host.h> #include <linux/mman.h> #include <linux/module.h> +#include <linux/moduleparam.h> #include <linux/random.h> #include <linux/slab.h> #include <linux/timer.h>
arch/s390/lib/delay.c +1 -1
@@ -9,7 +9,7 @@#include <linux/sched.h> #include <linux/delay.h> #include <linux/timex.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/irqflags.h> #include <linux/interrupt.h> #include <linux/irq.h>
arch/s390/lib/spinlock.c +1 -1
@@ -6,7 +6,7 @@*/ #include <linux/types.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/spinlock.h> #include <linux/init.h> #include <linux/smp.h>
arch/s390/lib/string.c +2 -1
@@ -9,7 +9,8 @@#define IN_ARCH_STRING_C 1#include <linux/types.h> -#include <linux/module.h> +#include <linux/string.h> +#include <linux/export.h> /* * Helper functions to find the end of a string
arch/s390/lib/xor.c +1 -1
@@ -6,7 +6,7 @@*/ #include <linux/types.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/raid/xor.h> static void xor_xc_2 (unsigned long bytes,unsigned long *p1,unsigned long *p2)
Signature · 1 line
2.11.0
Heiko Carstens
AppliedQuoted 4 lines · Paul Gortmaker
Paul Gortmaker (3):
s390: kernel: Audit and remove any unnecessary uses ofmodule.h
s390: mm: Audit and remove any unnecessary uses ofmodule.h
s390: Audit and remove any remaining unnecessary uses ofmodule.h
Applied, thanks!