public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] mips: audit and remove needless module.h use from core
@ 2016-08-21 19:58 Paul Gortmaker
  2016-08-21 19:58 ` [PATCH 5/5] mips/kvm: Audit and remove any unnecessary uses of module.h Paul Gortmaker
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Gortmaker @ 2016-08-21 19:58 UTC (permalink / raw)
  To: linux-mips
  Cc: Paul Gortmaker, James Hogan, kvm, Paolo Bonzini,
	Radim Krčmář, Ralf Baechle

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.  Presumably the numbers are similar for !x86.

In this series we manage to remove about 40 includes of module.h that
just simply don't need to exist anymore in core MIPS files (kernel, lib,
pci, mm, kvm).

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 will tackle the platform specific files in a subsequent series.
This seemed like a better solution than one giant commit that would not
get easily reviewed.

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 all[mod/no/yes]config, and each mips defconfig
(a couple aren't supported by my toolchain however) with these changes
on a recent linux-next tree.

Paul.

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

---

Cc: James Hogan <james.hogan@imgtec.com>
Cc: kvm@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>

Paul Gortmaker (5):
  mips/kernel: Audit and remove any unnecessary uses of module.h
  mips/mm: Audit and remove any unnecessary uses of module.h
  mips/lib: Audit and remove any unnecessary uses of module.h
  mips/pci: Audit and remove any unnecessary uses of module.h
  mips/kvm: Audit and remove any unnecessary uses of module.h

 arch/mips/kernel/binfmt_elfn32.c      | 8 +-------
 arch/mips/kernel/binfmt_elfo32.c      | 8 +-------
 arch/mips/kernel/branch.c             | 2 +-
 arch/mips/kernel/linux32.c            | 1 -
 arch/mips/kernel/mips-r2-to-r6-emul.c | 1 -
 arch/mips/kernel/smp.c                | 2 +-
 arch/mips/kvm/commpage.c              | 1 -
 arch/mips/kvm/dyntrans.c              | 1 -
 arch/mips/kvm/emulate.c               | 1 -
 arch/mips/kvm/interrupt.c             | 1 -
 arch/mips/kvm/trap_emul.c             | 1 -
 arch/mips/lib/ashldi3.c               | 2 +-
 arch/mips/lib/ashrdi3.c               | 2 +-
 arch/mips/lib/bswapdi.c               | 3 ++-
 arch/mips/lib/bswapsi.c               | 3 ++-
 arch/mips/lib/cmpdi2.c                | 2 +-
 arch/mips/lib/delay.c                 | 2 +-
 arch/mips/lib/iomap-pci.c             | 2 +-
 arch/mips/lib/iomap.c                 | 2 +-
 arch/mips/lib/lshrdi3.c               | 2 +-
 arch/mips/lib/ucmpdi2.c               | 2 +-
 arch/mips/mm/c-r4k.c                  | 2 +-
 arch/mips/mm/cache.c                  | 2 +-
 arch/mips/mm/dma-default.c            | 2 +-
 arch/mips/mm/fault.c                  | 1 -
 arch/mips/mm/highmem.c                | 3 ++-
 arch/mips/mm/init.c                   | 2 +-
 arch/mips/mm/ioremap.c                | 2 +-
 arch/mips/mm/mmap.c                   | 2 +-
 arch/mips/mm/page.c                   | 1 -
 arch/mips/mm/tlb-r4k.c                | 2 +-
 arch/mips/pci/pci-ar71xx.c            | 2 +-
 arch/mips/pci/pci-ar724x.c            | 2 +-
 arch/mips/pci/pci-lantiq.c            | 2 --
 arch/mips/pci/pci-mt7620.c            | 2 --
 arch/mips/pci/pci-rt2880.c            | 2 --
 arch/mips/pci/pci-rt3883.c            | 2 --
 arch/mips/pci/pcie-octeon.c           | 2 +-
 38 files changed, 28 insertions(+), 54 deletions(-)

-- 
2.8.4

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

* [PATCH 5/5] mips/kvm: Audit and remove any unnecessary uses of module.h
  2016-08-21 19:58 [PATCH 0/5] mips: audit and remove needless module.h use from core Paul Gortmaker
@ 2016-08-21 19:58 ` Paul Gortmaker
  2016-08-22 12:14   ` James Hogan
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Gortmaker @ 2016-08-21 19:58 UTC (permalink / raw)
  To: linux-mips
  Cc: Paul Gortmaker, Paolo Bonzini, Radim Krčmář,
	James Hogan, Ralf Baechle, kvm

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.  In the case of
kvm where it is 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.

Since module.h was the source for init.h (for __init) and for
export.h (for EXPORT_SYMBOL) we consider each instance for the
presence of either and replace as needed.  In this case, we did
not need to add either to any files.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: kvm@vger.kernel.org
Cc: linux-mips@linux-mips.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 arch/mips/kvm/commpage.c  | 1 -
 arch/mips/kvm/dyntrans.c  | 1 -
 arch/mips/kvm/emulate.c   | 1 -
 arch/mips/kvm/interrupt.c | 1 -
 arch/mips/kvm/trap_emul.c | 1 -
 5 files changed, 5 deletions(-)

diff --git a/arch/mips/kvm/commpage.c b/arch/mips/kvm/commpage.c
index a36b77e1705c..f43629979a0e 100644
--- a/arch/mips/kvm/commpage.c
+++ b/arch/mips/kvm/commpage.c
@@ -12,7 +12,6 @@
 
 #include <linux/errno.h>
 #include <linux/err.h>
-#include <linux/module.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/bootmem.h>
diff --git a/arch/mips/kvm/dyntrans.c b/arch/mips/kvm/dyntrans.c
index d280894915ed..b36c8ddc03ea 100644
--- a/arch/mips/kvm/dyntrans.c
+++ b/arch/mips/kvm/dyntrans.c
@@ -13,7 +13,6 @@
 #include <linux/err.h>
 #include <linux/highmem.h>
 #include <linux/kvm_host.h>
-#include <linux/module.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/bootmem.h>
diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
index e788515f766b..68fd666f8cb9 100644
--- a/arch/mips/kvm/emulate.c
+++ b/arch/mips/kvm/emulate.c
@@ -13,7 +13,6 @@
 #include <linux/err.h>
 #include <linux/ktime.h>
 #include <linux/kvm_host.h>
-#include <linux/module.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/bootmem.h>
diff --git a/arch/mips/kvm/interrupt.c b/arch/mips/kvm/interrupt.c
index ad28dac6b7e9..e88403b3dcdd 100644
--- a/arch/mips/kvm/interrupt.c
+++ b/arch/mips/kvm/interrupt.c
@@ -11,7 +11,6 @@
 
 #include <linux/errno.h>
 #include <linux/err.h>
-#include <linux/module.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/bootmem.h>
diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c
index 091553942bcb..21d80274ccff 100644
--- a/arch/mips/kvm/trap_emul.c
+++ b/arch/mips/kvm/trap_emul.c
@@ -11,7 +11,6 @@
 
 #include <linux/errno.h>
 #include <linux/err.h>
-#include <linux/module.h>
 #include <linux/vmalloc.h>
 
 #include <linux/kvm_host.h>
-- 
2.8.4


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

* Re: [PATCH 5/5] mips/kvm: Audit and remove any unnecessary uses of module.h
  2016-08-21 19:58 ` [PATCH 5/5] mips/kvm: Audit and remove any unnecessary uses of module.h Paul Gortmaker
@ 2016-08-22 12:14   ` James Hogan
  2016-08-29 11:59     ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: James Hogan @ 2016-08-22 12:14 UTC (permalink / raw)
  To: Paul Gortmaker
  Cc: linux-mips, Paolo Bonzini, Radim Krčmář,
	Ralf Baechle, kvm

[-- Attachment #1: Type: text/plain, Size: 3775 bytes --]

On Sun, Aug 21, 2016 at 03:58:17PM -0400, Paul Gortmaker wrote:
> 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.  In the case of
> kvm where it is 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.
> 
> Since module.h was the source for init.h (for __init) and for
> export.h (for EXPORT_SYMBOL) we consider each instance for the
> presence of either and replace as needed.  In this case, we did
> not need to add either to any files.
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Radim Krčmář" <rkrcmar@redhat.com>
> Cc: James Hogan <james.hogan@imgtec.com>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: kvm@vger.kernel.org
> Cc: linux-mips@linux-mips.org
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>

Thanks, looks good and builds fine with KVM enabled for me.

Acked-by: James Hogan <james.hogan@imgtec.com>

Cheers
James

> ---
>  arch/mips/kvm/commpage.c  | 1 -
>  arch/mips/kvm/dyntrans.c  | 1 -
>  arch/mips/kvm/emulate.c   | 1 -
>  arch/mips/kvm/interrupt.c | 1 -
>  arch/mips/kvm/trap_emul.c | 1 -
>  5 files changed, 5 deletions(-)
> 
> diff --git a/arch/mips/kvm/commpage.c b/arch/mips/kvm/commpage.c
> index a36b77e1705c..f43629979a0e 100644
> --- a/arch/mips/kvm/commpage.c
> +++ b/arch/mips/kvm/commpage.c
> @@ -12,7 +12,6 @@
>  
>  #include <linux/errno.h>
>  #include <linux/err.h>
> -#include <linux/module.h>
>  #include <linux/vmalloc.h>
>  #include <linux/fs.h>
>  #include <linux/bootmem.h>
> diff --git a/arch/mips/kvm/dyntrans.c b/arch/mips/kvm/dyntrans.c
> index d280894915ed..b36c8ddc03ea 100644
> --- a/arch/mips/kvm/dyntrans.c
> +++ b/arch/mips/kvm/dyntrans.c
> @@ -13,7 +13,6 @@
>  #include <linux/err.h>
>  #include <linux/highmem.h>
>  #include <linux/kvm_host.h>
> -#include <linux/module.h>
>  #include <linux/vmalloc.h>
>  #include <linux/fs.h>
>  #include <linux/bootmem.h>
> diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
> index e788515f766b..68fd666f8cb9 100644
> --- a/arch/mips/kvm/emulate.c
> +++ b/arch/mips/kvm/emulate.c
> @@ -13,7 +13,6 @@
>  #include <linux/err.h>
>  #include <linux/ktime.h>
>  #include <linux/kvm_host.h>
> -#include <linux/module.h>
>  #include <linux/vmalloc.h>
>  #include <linux/fs.h>
>  #include <linux/bootmem.h>
> diff --git a/arch/mips/kvm/interrupt.c b/arch/mips/kvm/interrupt.c
> index ad28dac6b7e9..e88403b3dcdd 100644
> --- a/arch/mips/kvm/interrupt.c
> +++ b/arch/mips/kvm/interrupt.c
> @@ -11,7 +11,6 @@
>  
>  #include <linux/errno.h>
>  #include <linux/err.h>
> -#include <linux/module.h>
>  #include <linux/vmalloc.h>
>  #include <linux/fs.h>
>  #include <linux/bootmem.h>
> diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c
> index 091553942bcb..21d80274ccff 100644
> --- a/arch/mips/kvm/trap_emul.c
> +++ b/arch/mips/kvm/trap_emul.c
> @@ -11,7 +11,6 @@
>  
>  #include <linux/errno.h>
>  #include <linux/err.h>
> -#include <linux/module.h>
>  #include <linux/vmalloc.h>
>  
>  #include <linux/kvm_host.h>
> -- 
> 2.8.4
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 5/5] mips/kvm: Audit and remove any unnecessary uses of module.h
  2016-08-22 12:14   ` James Hogan
@ 2016-08-29 11:59     ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2016-08-29 11:59 UTC (permalink / raw)
  To: James Hogan, Paul Gortmaker
  Cc: linux-mips, Radim Krčmář, Ralf Baechle, kvm



On 22/08/2016 14:14, James Hogan wrote:
> On Sun, Aug 21, 2016 at 03:58:17PM -0400, Paul Gortmaker wrote:
>> 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.  In the case of
>> kvm where it is 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.
>>
>> Since module.h was the source for init.h (for __init) and for
>> export.h (for EXPORT_SYMBOL) we consider each instance for the
>> presence of either and replace as needed.  In this case, we did
>> not need to add either to any files.
>>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: "Radim Krčmář" <rkrcmar@redhat.com>
>> Cc: James Hogan <james.hogan@imgtec.com>
>> Cc: Ralf Baechle <ralf@linux-mips.org>
>> Cc: kvm@vger.kernel.org
>> Cc: linux-mips@linux-mips.org
>> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> 
> Thanks, looks good and builds fine with KVM enabled for me.
> 
> Acked-by: James Hogan <james.hogan@imgtec.com>

Please merge through the MIPS tree.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

> Cheers
> James
> 
>> ---
>>  arch/mips/kvm/commpage.c  | 1 -
>>  arch/mips/kvm/dyntrans.c  | 1 -
>>  arch/mips/kvm/emulate.c   | 1 -
>>  arch/mips/kvm/interrupt.c | 1 -
>>  arch/mips/kvm/trap_emul.c | 1 -
>>  5 files changed, 5 deletions(-)
>>
>> diff --git a/arch/mips/kvm/commpage.c b/arch/mips/kvm/commpage.c
>> index a36b77e1705c..f43629979a0e 100644
>> --- a/arch/mips/kvm/commpage.c
>> +++ b/arch/mips/kvm/commpage.c
>> @@ -12,7 +12,6 @@
>>  
>>  #include <linux/errno.h>
>>  #include <linux/err.h>
>> -#include <linux/module.h>
>>  #include <linux/vmalloc.h>
>>  #include <linux/fs.h>
>>  #include <linux/bootmem.h>
>> diff --git a/arch/mips/kvm/dyntrans.c b/arch/mips/kvm/dyntrans.c
>> index d280894915ed..b36c8ddc03ea 100644
>> --- a/arch/mips/kvm/dyntrans.c
>> +++ b/arch/mips/kvm/dyntrans.c
>> @@ -13,7 +13,6 @@
>>  #include <linux/err.h>
>>  #include <linux/highmem.h>
>>  #include <linux/kvm_host.h>
>> -#include <linux/module.h>
>>  #include <linux/vmalloc.h>
>>  #include <linux/fs.h>
>>  #include <linux/bootmem.h>
>> diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
>> index e788515f766b..68fd666f8cb9 100644
>> --- a/arch/mips/kvm/emulate.c
>> +++ b/arch/mips/kvm/emulate.c
>> @@ -13,7 +13,6 @@
>>  #include <linux/err.h>
>>  #include <linux/ktime.h>
>>  #include <linux/kvm_host.h>
>> -#include <linux/module.h>
>>  #include <linux/vmalloc.h>
>>  #include <linux/fs.h>
>>  #include <linux/bootmem.h>
>> diff --git a/arch/mips/kvm/interrupt.c b/arch/mips/kvm/interrupt.c
>> index ad28dac6b7e9..e88403b3dcdd 100644
>> --- a/arch/mips/kvm/interrupt.c
>> +++ b/arch/mips/kvm/interrupt.c
>> @@ -11,7 +11,6 @@
>>  
>>  #include <linux/errno.h>
>>  #include <linux/err.h>
>> -#include <linux/module.h>
>>  #include <linux/vmalloc.h>
>>  #include <linux/fs.h>
>>  #include <linux/bootmem.h>
>> diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c
>> index 091553942bcb..21d80274ccff 100644
>> --- a/arch/mips/kvm/trap_emul.c
>> +++ b/arch/mips/kvm/trap_emul.c
>> @@ -11,7 +11,6 @@
>>  
>>  #include <linux/errno.h>
>>  #include <linux/err.h>
>> -#include <linux/module.h>
>>  #include <linux/vmalloc.h>
>>  
>>  #include <linux/kvm_host.h>
>> -- 
>> 2.8.4
>>

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

end of thread, other threads:[~2016-08-29 11:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-21 19:58 [PATCH 0/5] mips: audit and remove needless module.h use from core Paul Gortmaker
2016-08-21 19:58 ` [PATCH 5/5] mips/kvm: Audit and remove any unnecessary uses of module.h Paul Gortmaker
2016-08-22 12:14   ` James Hogan
2016-08-29 11:59     ` Paolo Bonzini

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