Skip to content

x86: audit and remove needless module.h includes

Paul Gortmaker kvm lkml xen-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 14 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8x86: don't use module.h just for AUTHOR / LICENSE tagsarch/x86/kernel/test_rodata.c arch/x86/mm/dump_pagetables.c+1 -101 reply
2/8x86: mm: audit and remove any unnecessary uses of module.harch/x86/mm/amdtopology.c arch/x86/mm/highmem_32.c arch/x86/mm/init_32.c +16 more+9 -190 replies
3/8x86: kernel: audit and remove any unnecessary uses of module.harch/x86/include/asm/topology.h arch/x86/kernel/acpi/boot.c arch/x86/kernel/acpi/cstate.c +48 more+51 -500 replies
4/8x86: lib: audit and remove any unnecessary uses of module.harch/x86/lib/cache-smp.c arch/x86/lib/cpu.c arch/x86/lib/csum-partial_64.c +11 more+16 -140 replies
5/8x86: platform: audit and remove any unnecessary uses of module.harch/x86/platform/ce4100/ce4100.c arch/x86/platform/efi/efi_64.c arch/x86/platform/intel-mid/intel-mid.c +7 more+13 -120 replies
6/8x86: xen: audit and remove any unnecessary uses of module.harch/x86/xen/debugfs.c arch/x86/xen/enlighten.c arch/x86/xen/mmu.c +3 more+6 -62 replies
7/8x86: kvm: audit and remove any unnecessary uses of module.harch/x86/kvm/cpuid.c arch/x86/kvm/emulate.c arch/x86/kvm/iommu.c +4 more+8 -71 reply
8/8x86: audit and remove any remaining unnecessary uses of module.harch/x86/crypto/glue_helper.c arch/x86/events/amd/ibs.c arch/x86/events/amd/iommu.c +8 more+11 -120 replies

Reviews trailers per patch

3 of 8 patches have a Reviewed-by or Acked-by.

PatchArjan van de VenJuergen GrossPaolo Bonzini
1/8A-b
2/8
3/8
4/8
5/8
6/8A-b A-b
7/8A-b
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 0/8] x86: 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=../x86_64-build/ init/foo.i
   make[1]: Entering directory '/home/paul/git/x86_64-build'
     CPP     init/foo.i
   paul@builder:~/git/linux-head$ ls -lh ../x86_64-build/init/foo.i 
   -rw-rw-r-- 1 paul paul 754K Jul 12 20:04 ../x86_64-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.

In this series we manage to remove about 120 includes of module.h that just simply don't need to exist anymore in arch/x86.

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, since it covers some distinct subsystems like kvm and xen for ease of review for those folks.

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 both 32 bit and 64 bit x86 with these changes on the linux-next from today, which presumably has an up to date copy of tip in it.

Paul.

[1] https://lwn.net/Articles/453517/

---

Cc Arjan van de Ven <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Juergen Gross <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc "Radim Krčmář" <[email protected]>
Cc Thomas Gleixner <[email protected]>

Paul Gortmaker (8):
x86: don't use module.h just for AUTHOR / LICENSE tags
x86: mm: audit and remove any unnecessary uses of module.h
x86: kernel: audit and remove any unnecessary uses of module.h
x86: lib: audit and remove any unnecessary uses of module.h
x86: platform: audit and remove any unnecessary uses of module.h
x86: xen: audit and remove any unnecessary uses of module.h
x86: kvm: audit and remove any unnecessary uses of module.h
x86: audit and remove any remaining unnecessary uses of module.h

 arch/x86/crypto/glue_helper.c           | 4 +---
 arch/x86/events/amd/ibs.c               | 3 ++-
 arch/x86/events/amd/iommu.c             | 2 +-
 arch/x86/events/core.c                  | 3 ++-
 arch/x86/events/intel/uncore.c          | 2 ++
 arch/x86/events/intel/uncore.h          | 1 -
 arch/x86/include/asm/livepatch.h        | 1 -
 arch/x86/include/asm/topology.h         | 1 +
 arch/x86/kernel/acpi/boot.c             | 2 +-
 arch/x86/kernel/acpi/cstate.c           | 2 +-
 arch/x86/kernel/amd_gart_64.c           | 1 -
 arch/x86/kernel/amd_nb.c                | 2 +-
 arch/x86/kernel/apic/apic.c             | 2 +-
 arch/x86/kernel/apic/apic_flat_64.c     | 2 +-
 arch/x86/kernel/apic/apic_noop.c        | 1 -
 arch/x86/kernel/apic/hw_nmi.c           | 2 +-
 arch/x86/kernel/apic/io_apic.c          | 2 +-
 arch/x86/kernel/apic/ipi.c              | 1 -
 arch/x86/kernel/apic/probe_32.c         | 2 +-
 arch/x86/kernel/apic/probe_64.c         | 2 +-
 arch/x86/kernel/apic/x2apic_uv_x.c      | 2 +-
 arch/x86/kernel/cpu/common.c            | 2 +-
 arch/x86/kernel/cpu/hypervisor.c        | 3 ++-
 arch/x86/kernel/cpu/intel.c             | 2 +-
 arch/x86/kernel/cpu/match.c             | 2 +-
 arch/x86/kernel/cpu/mshyperv.c          | 3 ++-
 arch/x86/kernel/cpu/mtrr/cleanup.c      | 1 -
 arch/x86/kernel/cpu/mtrr/generic.c      | 2 +-
 arch/x86/kernel/cpu/mtrr/if.c           | 1 -
 arch/x86/kernel/cpu/mtrr/main.c         | 2 +-
 arch/x86/kernel/cpu/perfctr-watchdog.c  | 2 +-
 arch/x86/kernel/cpu/vmware.c            | 3 ++-
 arch/x86/kernel/crash.c                 | 2 +-
 arch/x86/kernel/dumpstack.c             | 3 ++-
 arch/x86/kernel/dumpstack_32.c          | 2 +-
 arch/x86/kernel/dumpstack_64.c          | 2 +-
 arch/x86/kernel/hw_breakpoint.c         | 3 ++-
 arch/x86/kernel/i386_ksyms_32.c         | 2 +-
 arch/x86/kernel/i8253.c                 | 2 +-
 arch/x86/kernel/io_delay.c              | 2 +-
 arch/x86/kernel/irq_32.c                | 1 -
 arch/x86/kernel/irq_64.c                | 1 -
 arch/x86/kernel/kdebugfs.c              | 2 +-
 arch/x86/kernel/kvm.c                   | 2 +-
 arch/x86/kernel/mpparse.c               | 1 -
 arch/x86/kernel/paravirt-spinlocks.c    | 2 +-
 arch/x86/kernel/paravirt.c              | 3 ++-
 arch/x86/kernel/pci-swiotlb.c           | 2 +-
 arch/x86/kernel/pmem.c                  | 2 +-
 arch/x86/kernel/process.c               | 3 ++-
 arch/x86/kernel/process_32.c            | 2 +-
 arch/x86/kernel/process_64.c            | 2 +-
 arch/x86/kernel/reboot.c                | 2 +-
 arch/x86/kernel/setup.c                 | 2 +-
 arch/x86/kernel/setup_percpu.c          | 2 +-
 arch/x86/kernel/smpboot.c               | 2 +-
 arch/x86/kernel/stacktrace.c            | 2 +-
 arch/x86/kernel/test_rodata.c           | 5 -----
 arch/x86/kernel/traps.c                 | 2 +-
 arch/x86/kernel/tsc.c                   | 2 +-
 arch/x86/kernel/x8664_ksyms_64.c        | 2 +-
 arch/x86/kernel/x86_init.c              | 2 +-
 arch/x86/kvm/cpuid.c                    | 2 +-
 arch/x86/kvm/emulate.c                  | 1 -
 arch/x86/kvm/iommu.c                    | 2 +-
 arch/x86/kvm/irq.c                      | 2 +-
 arch/x86/kvm/lapic.c                    | 2 +-
 arch/x86/kvm/mmu.c                      | 3 ++-
 arch/x86/kvm/x86.c                      | 3 ++-
 arch/x86/lib/cache-smp.c                | 2 +-
 arch/x86/lib/cpu.c                      | 3 ++-
 arch/x86/lib/csum-partial_64.c          | 2 +-
 arch/x86/lib/csum-wrappers_64.c         | 2 +-
 arch/x86/lib/delay.c                    | 2 +-
 arch/x86/lib/memcpy_32.c                | 2 +-
 arch/x86/lib/mmx_32.c                   | 2 +-
 arch/x86/lib/msr-reg-export.c           | 2 +-
 arch/x86/lib/msr-smp.c                  | 2 +-
 arch/x86/lib/msr.c                      | 2 +-
 arch/x86/lib/string_32.c                | 2 +-
 arch/x86/lib/usercopy.c                 | 2 +-
 arch/x86/lib/usercopy_32.c              | 2 +-
 arch/x86/lib/usercopy_64.c              | 2 +-
 arch/x86/mm/amdtopology.c               | 1 -
 arch/x86/mm/dump_pagetables.c           | 6 +-----
 arch/x86/mm/highmem_32.c                | 2 +-
 arch/x86/mm/init_32.c                   | 1 -
 arch/x86/mm/init_64.c                   | 1 -
 arch/x86/mm/iomap_32.c                  | 2 +-
 arch/x86/mm/ioremap.c                   | 1 -
 arch/x86/mm/kmemcheck/kmemcheck.c       | 1 -
 arch/x86/mm/kmemcheck/shadow.c          | 2 +-
 arch/x86/mm/kmmio.c                     | 2 +-
 arch/x86/mm/mmio-mod.c                  | 2 +-
 arch/x86/mm/numa.c                      | 1 -
 arch/x86/mm/numa_32.c                   | 2 +-
 arch/x86/mm/pat.c                       | 1 -
 arch/x86/mm/pat_rbtree.c                | 1 -
 arch/x86/mm/pf_in.c                     | 1 -
 arch/x86/mm/pgtable_32.c                | 1 -
 arch/x86/mm/physaddr.c                  | 2 +-
 arch/x86/mm/srat.c                      | 2 +-
 arch/x86/mm/tlb.c                       | 2 +-
 arch/x86/pci/xen.c                      | 2 +-
 arch/x86/platform/ce4100/ce4100.c       | 2 +-
 arch/x86/platform/efi/efi_64.c          | 2 +-
 arch/x86/platform/intel-mid/intel-mid.c | 2 +-
 arch/x86/platform/intel-mid/pwr.c       | 4 +---
 arch/x86/platform/intel-mid/sfi.c       | 2 +-
 arch/x86/platform/olpc/olpc.c           | 2 +-
 arch/x86/platform/olpc/olpc_ofw.c       | 2 +-
 arch/x86/platform/ts5500/ts5500.c       | 2 +-
 arch/x86/platform/uv/uv_irq.c           | 2 +-
 arch/x86/platform/uv/uv_nmi.c           | 2 +-
 arch/x86/um/delay.c                     | 2 +-
 arch/x86/xen/debugfs.c                  | 1 -
 arch/x86/xen/enlighten.c                | 2 +-
 arch/x86/xen/mmu.c                      | 3 ++-
 arch/x86/xen/p2m.c                      | 2 +-
 arch/x86/xen/platform-pci-unplug.c      | 2 +-
 arch/x86/xen/setup.c                    | 2 +-
 121 files changed, 112 insertions(+), 131 deletions(-)
Signature · 136 lines
2.8.4

Paul Gortmaker (8):
  x86: don't use module.h just for AUTHOR / LICENSE tags
  x86: mm: audit and remove any unnecessary uses of module.h
  x86: kernel: audit and remove any unnecessary uses of module.h
  x86: lib: audit and remove any unnecessary uses of module.h
  x86: platform: audit and remove any unnecessary uses of module.h
  x86: xen: audit and remove any unnecessary uses of module.h
  x86: kvm: audit and remove any unnecessary uses of module.h
  x86: audit and remove any remaining unnecessary uses of module.h

 arch/x86/crypto/glue_helper.c           | 4 +---
 arch/x86/events/amd/ibs.c               | 3 ++-
 arch/x86/events/amd/iommu.c             | 2 +-
 arch/x86/events/core.c                  | 3 ++-
 arch/x86/events/intel/uncore.c          | 2 ++
 arch/x86/events/intel/uncore.h          | 1 -
 arch/x86/include/asm/livepatch.h        | 1 -
 arch/x86/include/asm/topology.h         | 1 +
 arch/x86/kernel/acpi/boot.c             | 2 +-
 arch/x86/kernel/acpi/cstate.c           | 2 +-
 arch/x86/kernel/amd_gart_64.c           | 1 -
 arch/x86/kernel/amd_nb.c                | 2 +-
 arch/x86/kernel/apic/apic.c             | 2 +-
 arch/x86/kernel/apic/apic_flat_64.c     | 2 +-
 arch/x86/kernel/apic/apic_noop.c        | 1 -
 arch/x86/kernel/apic/hw_nmi.c           | 2 +-
 arch/x86/kernel/apic/io_apic.c          | 2 +-
 arch/x86/kernel/apic/ipi.c              | 1 -
 arch/x86/kernel/apic/probe_32.c         | 2 +-
 arch/x86/kernel/apic/probe_64.c         | 2 +-
 arch/x86/kernel/apic/x2apic_uv_x.c      | 2 +-
 arch/x86/kernel/cpu/common.c            | 2 +-
 arch/x86/kernel/cpu/hypervisor.c        | 3 ++-
 arch/x86/kernel/cpu/intel.c             | 2 +-
 arch/x86/kernel/cpu/match.c             | 2 +-
 arch/x86/kernel/cpu/mshyperv.c          | 3 ++-
 arch/x86/kernel/cpu/mtrr/cleanup.c      | 1 -
 arch/x86/kernel/cpu/mtrr/generic.c      | 2 +-
 arch/x86/kernel/cpu/mtrr/if.c           | 1 -
 arch/x86/kernel/cpu/mtrr/main.c         | 2 +-
 arch/x86/kernel/cpu/perfctr-watchdog.c  | 2 +-
 arch/x86/kernel/cpu/vmware.c            | 3 ++-
 arch/x86/kernel/crash.c                 | 2 +-
 arch/x86/kernel/dumpstack_32.c          | 2 +-
 arch/x86/kernel/dumpstack_64.c          | 2 +-
 arch/x86/kernel/hw_breakpoint.c         | 3 ++-
 arch/x86/kernel/i386_ksyms_32.c         | 3 ++-
 arch/x86/kernel/i8253.c                 | 2 +-
 arch/x86/kernel/io_delay.c              | 2 +-
 arch/x86/kernel/irq_32.c                | 1 -
 arch/x86/kernel/irq_64.c                | 1 -
 arch/x86/kernel/kdebugfs.c              | 2 +-
 arch/x86/kernel/kvm.c                   | 2 +-
 arch/x86/kernel/mpparse.c               | 1 -
 arch/x86/kernel/paravirt-spinlocks.c    | 2 +-
 arch/x86/kernel/paravirt.c              | 3 ++-
 arch/x86/kernel/pci-swiotlb.c           | 2 +-
 arch/x86/kernel/pmem.c                  | 2 +-
 arch/x86/kernel/process.c               | 3 ++-
 arch/x86/kernel/process_32.c            | 2 +-
 arch/x86/kernel/process_64.c            | 2 +-
 arch/x86/kernel/reboot.c                | 2 +-
 arch/x86/kernel/setup.c                 | 2 +-
 arch/x86/kernel/setup_percpu.c          | 2 +-
 arch/x86/kernel/smpboot.c               | 2 +-
 arch/x86/kernel/stacktrace.c            | 2 +-
 arch/x86/kernel/test_rodata.c           | 5 -----
 arch/x86/kernel/traps.c                 | 2 +-
 arch/x86/kernel/tsc.c                   | 2 +-
 arch/x86/kernel/x8664_ksyms_64.c        | 2 +-
 arch/x86/kernel/x86_init.c              | 2 +-
 arch/x86/kvm/cpuid.c                    | 2 +-
 arch/x86/kvm/emulate.c                  | 1 -
 arch/x86/kvm/iommu.c                    | 2 +-
 arch/x86/kvm/irq.c                      | 2 +-
 arch/x86/kvm/lapic.c                    | 2 +-
 arch/x86/kvm/mmu.c                      | 3 ++-
 arch/x86/kvm/x86.c                      | 3 ++-
 arch/x86/lib/cache-smp.c                | 2 +-
 arch/x86/lib/cpu.c                      | 3 ++-
 arch/x86/lib/csum-partial_64.c          | 2 +-
 arch/x86/lib/csum-wrappers_64.c         | 2 +-
 arch/x86/lib/delay.c                    | 2 +-
 arch/x86/lib/memcpy_32.c                | 2 +-
 arch/x86/lib/mmx_32.c                   | 2 +-
 arch/x86/lib/msr-reg-export.c           | 2 +-
 arch/x86/lib/msr-smp.c                  | 2 +-
 arch/x86/lib/msr.c                      | 3 ++-
 arch/x86/lib/string_32.c                | 2 +-
 arch/x86/lib/usercopy.c                 | 2 +-
 arch/x86/lib/usercopy_32.c              | 2 +-
 arch/x86/lib/usercopy_64.c              | 2 +-
 arch/x86/mm/amdtopology.c               | 1 -
 arch/x86/mm/dump_pagetables.c           | 6 +-----
 arch/x86/mm/highmem_32.c                | 2 +-
 arch/x86/mm/init_32.c                   | 1 -
 arch/x86/mm/init_64.c                   | 1 -
 arch/x86/mm/iomap_32.c                  | 2 +-
 arch/x86/mm/ioremap.c                   | 1 -
 arch/x86/mm/kmemcheck/kmemcheck.c       | 1 -
 arch/x86/mm/kmemcheck/shadow.c          | 2 +-
 arch/x86/mm/kmmio.c                     | 2 +-
 arch/x86/mm/mmio-mod.c                  | 2 +-
 arch/x86/mm/numa.c                      | 1 -
 arch/x86/mm/numa_32.c                   | 2 +-
 arch/x86/mm/pat.c                       | 1 -
 arch/x86/mm/pat_rbtree.c                | 1 -
 arch/x86/mm/pf_in.c                     | 1 -
 arch/x86/mm/pgtable_32.c                | 1 -
 arch/x86/mm/physaddr.c                  | 2 +-
 arch/x86/mm/srat.c                      | 2 +-
 arch/x86/mm/tlb.c                       | 2 +-
 arch/x86/pci/xen.c                      | 2 +-
 arch/x86/platform/ce4100/ce4100.c       | 2 +-
 arch/x86/platform/efi/efi_64.c          | 2 +-
 arch/x86/platform/intel-mid/intel-mid.c | 2 +-
 arch/x86/platform/intel-mid/pwr.c       | 4 +---
 arch/x86/platform/intel-mid/sfi.c       | 2 +-
 arch/x86/platform/olpc/olpc.c           | 2 +-
 arch/x86/platform/olpc/olpc_ofw.c       | 5 ++++-
 arch/x86/platform/ts5500/ts5500.c       | 2 +-
 arch/x86/platform/uv/uv_irq.c           | 2 +-
 arch/x86/platform/uv/uv_nmi.c           | 2 +-
 arch/x86/um/delay.c                     | 2 +-
 arch/x86/xen/debugfs.c                  | 1 -
 arch/x86/xen/enlighten.c                | 2 +-
 arch/x86/xen/mmu.c                      | 3 ++-
 arch/x86/xen/p2m.c                      | 2 +-
 arch/x86/xen/platform-pci-unplug.c      | 2 +-
 arch/x86/xen/setup.c                    | 2 +-
 120 files changed, 115 insertions(+), 130 deletions(-)

-- 
2.8.4