linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] xen: avoid module usage in non-modular code
@ 2016-02-22  0:06 Paul Gortmaker
  2016-02-22  0:06 ` [PATCH v2 1/5] xen: audit usages of module.h ; remove unnecessary instances Paul Gortmaker
  2016-03-20  0:23 ` [PATCH v2 0/5] xen: avoid module usage in non-modular code Paul Gortmaker
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Gortmaker @ 2016-02-22  0:06 UTC (permalink / raw)
  To: linux-arm-kernel

This series of commits is a part of a larger project to ensure
people don't reference modular support functions in non-modular
code.  Overall there was roughly 5k lines of dead code in the
kernel due to this.  So far we've fixed several areas, like tty,
x86, net, ... and we continue to work on other areas.

There are several reasons to not use module support for code that
can never be built as a module, but the big ones are:

 (1) it is easy to accidentally write unused module_exit and remove code
 (2) it can be misleading when reading the source, thinking it can be
      modular when the Makefile and/or Kconfig prohibit it
 (3) it requires the include of the module.h header file which in turn
     includes nearly everything else.
 (4) it gets copied/replicated into other code and spreads like weeds.

For the xen subsystem, there are just five commits:

First, we get rid of "include <linux/module.h>" instances that are
completely unnecessary.

Then #2 and #3 and #5 are basically trivial remapping to the
appropriate non-modular counterparts, meaning that there is no
runtime change here either.

The fourth hypervisor commit is similar, but also has removal of
some dead code associated with the module_exit function that will
never be called.  So the runtime should be the same, but the object
file will be different (reduced in size).

Patches created on linux-next and build tested for x86-64 and ARM64
allmodconfig.

---

[v2: manually inline one-liners in #4; update probe vs init fcn names
 in #5 ; both suggestions by Stefano ; add Reviewed tags to #1, #2, #3.
 Redid build testing on x86-64 and ARM64 to test for typos etc.  ]

Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: linux-arm-kernel at lists.infradead.org
Cc: xen-devel at lists.xenproject.org

Paul Gortmaker (5):
  xen: audit usages of module.h ; remove unnecessary instances
  drivers/xen: make [xen-]ballon explicitly non-modular
  drivers/xen: make xenbus_dev_[front/back]end explicitly non-modular
  drivers/xen: make sys-hypervisor.c explicitly non-modular
  drivers/xen: make platform-pci.c explicitly non-modular

 arch/arm/include/asm/xen/hypercall.h     |  2 ++
 drivers/xen/balloon.c                    |  4 ----
 drivers/xen/events/events_2l.c           |  1 -
 drivers/xen/events/events_base.c         |  2 +-
 drivers/xen/events/events_fifo.c         |  1 -
 drivers/xen/features.c                   |  2 +-
 drivers/xen/grant-table.c                |  1 -
 drivers/xen/platform-pci.c               | 16 ++++++----------
 drivers/xen/sys-hypervisor.c             | 31 ++++---------------------------
 drivers/xen/xen-balloon.c                | 14 +++-----------
 drivers/xen/xen-pciback/conf_space.c     |  2 +-
 drivers/xen/xen-pciback/pciback_ops.c    |  2 +-
 drivers/xen/xen-pciback/xenbus.c         |  2 +-
 drivers/xen/xen-selfballoon.c            |  1 -
 drivers/xen/xenbus/xenbus_dev_backend.c  | 13 ++-----------
 drivers/xen/xenbus/xenbus_dev_frontend.c | 13 ++-----------
 drivers/xen/xenbus/xenbus_xs.c           |  1 -
 drivers/xen/xenfs/xensyms.c              |  1 -
 18 files changed, 24 insertions(+), 85 deletions(-)

-- 
2.6.1
Paul Gortmaker (5):
  xen: audit usages of module.h ; remove unnecessary instances
  drivers/xen: make [xen-]ballon explicitly non-modular
  drivers/xen: make xenbus_dev_[front/back]end explicitly non-modular
  drivers/xen: make sys-hypervisor.c explicitly non-modular
  drivers/xen: make platform-pci.c explicitly non-modular

 arch/arm/include/asm/xen/hypercall.h     |  2 ++
 drivers/xen/balloon.c                    |  4 ---
 drivers/xen/events/events_2l.c           |  1 -
 drivers/xen/events/events_base.c         |  2 +-
 drivers/xen/events/events_fifo.c         |  1 -
 drivers/xen/features.c                   |  2 +-
 drivers/xen/grant-table.c                |  1 -
 drivers/xen/platform-pci.c               | 22 +++++-------
 drivers/xen/sys-hypervisor.c             | 59 +++++---------------------------
 drivers/xen/xen-balloon.c                | 14 ++------
 drivers/xen/xen-pciback/conf_space.c     |  2 +-
 drivers/xen/xen-pciback/pciback_ops.c    |  2 +-
 drivers/xen/xen-pciback/xenbus.c         |  2 +-
 drivers/xen/xen-selfballoon.c            |  1 -
 drivers/xen/xenbus/xenbus_dev_backend.c  | 13 ++-----
 drivers/xen/xenbus/xenbus_dev_frontend.c | 13 ++-----
 drivers/xen/xenbus/xenbus_xs.c           |  1 -
 drivers/xen/xenfs/xensyms.c              |  1 -
 18 files changed, 31 insertions(+), 112 deletions(-)

-- 
2.6.1

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

* [PATCH v2 1/5] xen: audit usages of module.h ; remove unnecessary instances
  2016-02-22  0:06 [PATCH v2 0/5] xen: avoid module usage in non-modular code Paul Gortmaker
@ 2016-02-22  0:06 ` Paul Gortmaker
  2016-03-20  0:23 ` [PATCH v2 0/5] xen: avoid module usage in non-modular code Paul Gortmaker
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Gortmaker @ 2016-02-22  0:06 UTC (permalink / raw)
  To: linux-arm-kernel

Code that uses no modular facilities whatsoever should not be
sourcing module.h at all, since that header drags in a bunch
of other headers with it.

Similarly, code that is not explicitly using modular facilities
like module_init() but only is declaring module_param setup
variables should be using moduleparam.h and not the larger
module.h file for that.

In making this change, we also uncover an implicit use of BUG()
in inline fcns within arch/arm/include/asm/xen/hypercall.h so
we explicitly source <linux/bug.h> for that file now.

Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: xen-devel at lists.xenproject.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 arch/arm/include/asm/xen/hypercall.h  | 2 ++
 drivers/xen/events/events_2l.c        | 1 -
 drivers/xen/events/events_base.c      | 2 +-
 drivers/xen/events/events_fifo.c      | 1 -
 drivers/xen/features.c                | 2 +-
 drivers/xen/grant-table.c             | 1 -
 drivers/xen/xen-pciback/conf_space.c  | 2 +-
 drivers/xen/xen-pciback/pciback_ops.c | 2 +-
 drivers/xen/xen-pciback/xenbus.c      | 2 +-
 drivers/xen/xen-selfballoon.c         | 1 -
 drivers/xen/xenbus/xenbus_xs.c        | 1 -
 drivers/xen/xenfs/xensyms.c           | 1 -
 12 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/arch/arm/include/asm/xen/hypercall.h b/arch/arm/include/asm/xen/hypercall.h
index d769972db8cb..b6b962d70db9 100644
--- a/arch/arm/include/asm/xen/hypercall.h
+++ b/arch/arm/include/asm/xen/hypercall.h
@@ -33,6 +33,8 @@
 #ifndef _ASM_ARM_XEN_HYPERCALL_H
 #define _ASM_ARM_XEN_HYPERCALL_H
 
+#include <linux/bug.h>
+
 #include <xen/interface/xen.h>
 #include <xen/interface/sched.h>
 #include <xen/interface/platform.h>
diff --git a/drivers/xen/events/events_2l.c b/drivers/xen/events/events_2l.c
index 7dd46312c180..51b488f5bfe9 100644
--- a/drivers/xen/events/events_2l.c
+++ b/drivers/xen/events/events_2l.c
@@ -9,7 +9,6 @@
 #include <linux/linkage.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
 
 #include <asm/sync_bitops.h>
 #include <asm/xen/hypercall.h>
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 524c22146429..488017a0806a 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -26,7 +26,7 @@
 #include <linux/linkage.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/string.h>
 #include <linux/bootmem.h>
 #include <linux/slab.h>
diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c
index eff2b88003d9..9289a17712e2 100644
--- a/drivers/xen/events/events_fifo.c
+++ b/drivers/xen/events/events_fifo.c
@@ -36,7 +36,6 @@
 #include <linux/linkage.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
 #include <linux/smp.h>
 #include <linux/percpu.h>
 #include <linux/cpu.h>
diff --git a/drivers/xen/features.c b/drivers/xen/features.c
index 99eda169c779..d7d34fdfc993 100644
--- a/drivers/xen/features.c
+++ b/drivers/xen/features.c
@@ -7,7 +7,7 @@
  */
 #include <linux/types.h>
 #include <linux/cache.h>
-#include <linux/module.h>
+#include <linux/export.h>
 
 #include <asm/xen/hypercall.h>
 
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index effbaf91791f..bb36b1e1dbcc 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -33,7 +33,6 @@
 
 #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
diff --git a/drivers/xen/xen-pciback/conf_space.c b/drivers/xen/xen-pciback/conf_space.c
index 9c234209d8b5..8e67336f8ddd 100644
--- a/drivers/xen/xen-pciback/conf_space.c
+++ b/drivers/xen/xen-pciback/conf_space.c
@@ -10,7 +10,7 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/pci.h>
 #include "pciback.h"
 #include "conf_space.h"
diff --git a/drivers/xen/xen-pciback/pciback_ops.c b/drivers/xen/xen-pciback/pciback_ops.c
index 73dafdc494aa..5ad01f9c24fc 100644
--- a/drivers/xen/xen-pciback/pciback_ops.c
+++ b/drivers/xen/xen-pciback/pciback_ops.c
@@ -6,7 +6,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/wait.h>
 #include <linux/bitops.h>
 #include <xen/events.h>
diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c
index 4843741e703a..c252eb3f0176 100644
--- a/drivers/xen/xen-pciback/xenbus.c
+++ b/drivers/xen/xen-pciback/xenbus.c
@@ -6,7 +6,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/vmalloc.h>
diff --git a/drivers/xen/xen-selfballoon.c b/drivers/xen/xen-selfballoon.c
index 3b2bffde534f..53a085fca00c 100644
--- a/drivers/xen/xen-selfballoon.c
+++ b/drivers/xen/xen-selfballoon.c
@@ -71,7 +71,6 @@
 #include <linux/swap.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
-#include <linux/module.h>
 #include <linux/workqueue.h>
 #include <linux/device.h>
 #include <xen/balloon.h>
diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index ba804f3d8278..374b12af8812 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -44,7 +44,6 @@
 #include <linux/fcntl.h>
 #include <linux/kthread.h>
 #include <linux/rwsem.h>
-#include <linux/module.h>
 #include <linux/mutex.h>
 #include <asm/xen/hypervisor.h>
 #include <xen/xenbus.h>
diff --git a/drivers/xen/xenfs/xensyms.c b/drivers/xen/xenfs/xensyms.c
index a03f261b12d8..c6e2b4a542ea 100644
--- a/drivers/xen/xenfs/xensyms.c
+++ b/drivers/xen/xenfs/xensyms.c
@@ -1,4 +1,3 @@
-#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
 #include <linux/fs.h>
-- 
2.6.1

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

* [PATCH v2 0/5] xen: avoid module usage in non-modular code
  2016-02-22  0:06 [PATCH v2 0/5] xen: avoid module usage in non-modular code Paul Gortmaker
  2016-02-22  0:06 ` [PATCH v2 1/5] xen: audit usages of module.h ; remove unnecessary instances Paul Gortmaker
@ 2016-03-20  0:23 ` Paul Gortmaker
  2016-03-21 15:17   ` [Xen-devel] " David Vrabel
  1 sibling, 1 reply; 4+ messages in thread
From: Paul Gortmaker @ 2016-03-20  0:23 UTC (permalink / raw)
  To: linux-arm-kernel

[[PATCH v2 0/5] xen: avoid module usage in non-modular code] On 21/02/2016 (Sun 19:06) Paul Gortmaker wrote:

> This series of commits is a part of a larger project to ensure
> people don't reference modular support functions in non-modular
> code.  Overall there was roughly 5k lines of dead code in the
> kernel due to this.  So far we've fixed several areas, like tty,
> x86, net, ... and we continue to work on other areas.

Just wondering if this is still pending for this merge window; Stefano
had reviewed the two commits he wanted changed vs. v1 and this v2 was
sent approximately a month ago w/o any further change requests.

Thanks,
Paul.
--

> 
> There are several reasons to not use module support for code that
> can never be built as a module, but the big ones are:
> 
>  (1) it is easy to accidentally write unused module_exit and remove code
>  (2) it can be misleading when reading the source, thinking it can be
>       modular when the Makefile and/or Kconfig prohibit it
>  (3) it requires the include of the module.h header file which in turn
>      includes nearly everything else.
>  (4) it gets copied/replicated into other code and spreads like weeds.
> 
> For the xen subsystem, there are just five commits:
> 
> First, we get rid of "include <linux/module.h>" instances that are
> completely unnecessary.
> 
> Then #2 and #3 and #5 are basically trivial remapping to the
> appropriate non-modular counterparts, meaning that there is no
> runtime change here either.
> 
> The fourth hypervisor commit is similar, but also has removal of
> some dead code associated with the module_exit function that will
> never be called.  So the runtime should be the same, but the object
> file will be different (reduced in size).
> 
> Patches created on linux-next and build tested for x86-64 and ARM64
> allmodconfig.
> 
> ---
> 
> [v2: manually inline one-liners in #4; update probe vs init fcn names
>  in #5 ; both suggestions by Stefano ; add Reviewed tags to #1, #2, #3.
>  Redid build testing on x86-64 and ARM64 to test for typos etc.  ]
> 
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: David Vrabel <david.vrabel@citrix.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: xen-devel at lists.xenproject.org
> 
> Paul Gortmaker (5):
>   xen: audit usages of module.h ; remove unnecessary instances
>   drivers/xen: make [xen-]ballon explicitly non-modular
>   drivers/xen: make xenbus_dev_[front/back]end explicitly non-modular
>   drivers/xen: make sys-hypervisor.c explicitly non-modular
>   drivers/xen: make platform-pci.c explicitly non-modular
> 
>  arch/arm/include/asm/xen/hypercall.h     |  2 ++
>  drivers/xen/balloon.c                    |  4 ----
>  drivers/xen/events/events_2l.c           |  1 -
>  drivers/xen/events/events_base.c         |  2 +-
>  drivers/xen/events/events_fifo.c         |  1 -
>  drivers/xen/features.c                   |  2 +-
>  drivers/xen/grant-table.c                |  1 -
>  drivers/xen/platform-pci.c               | 16 ++++++----------
>  drivers/xen/sys-hypervisor.c             | 31 ++++---------------------------
>  drivers/xen/xen-balloon.c                | 14 +++-----------
>  drivers/xen/xen-pciback/conf_space.c     |  2 +-
>  drivers/xen/xen-pciback/pciback_ops.c    |  2 +-
>  drivers/xen/xen-pciback/xenbus.c         |  2 +-
>  drivers/xen/xen-selfballoon.c            |  1 -
>  drivers/xen/xenbus/xenbus_dev_backend.c  | 13 ++-----------
>  drivers/xen/xenbus/xenbus_dev_frontend.c | 13 ++-----------
>  drivers/xen/xenbus/xenbus_xs.c           |  1 -
>  drivers/xen/xenfs/xensyms.c              |  1 -
>  18 files changed, 24 insertions(+), 85 deletions(-)
> 
> -- 
> 2.6.1
> Paul Gortmaker (5):
>   xen: audit usages of module.h ; remove unnecessary instances
>   drivers/xen: make [xen-]ballon explicitly non-modular
>   drivers/xen: make xenbus_dev_[front/back]end explicitly non-modular
>   drivers/xen: make sys-hypervisor.c explicitly non-modular
>   drivers/xen: make platform-pci.c explicitly non-modular
> 
>  arch/arm/include/asm/xen/hypercall.h     |  2 ++
>  drivers/xen/balloon.c                    |  4 ---
>  drivers/xen/events/events_2l.c           |  1 -
>  drivers/xen/events/events_base.c         |  2 +-
>  drivers/xen/events/events_fifo.c         |  1 -
>  drivers/xen/features.c                   |  2 +-
>  drivers/xen/grant-table.c                |  1 -
>  drivers/xen/platform-pci.c               | 22 +++++-------
>  drivers/xen/sys-hypervisor.c             | 59 +++++---------------------------
>  drivers/xen/xen-balloon.c                | 14 ++------
>  drivers/xen/xen-pciback/conf_space.c     |  2 +-
>  drivers/xen/xen-pciback/pciback_ops.c    |  2 +-
>  drivers/xen/xen-pciback/xenbus.c         |  2 +-
>  drivers/xen/xen-selfballoon.c            |  1 -
>  drivers/xen/xenbus/xenbus_dev_backend.c  | 13 ++-----
>  drivers/xen/xenbus/xenbus_dev_frontend.c | 13 ++-----
>  drivers/xen/xenbus/xenbus_xs.c           |  1 -
>  drivers/xen/xenfs/xensyms.c              |  1 -
>  18 files changed, 31 insertions(+), 112 deletions(-)
> 
> -- 
> 2.6.1
> 

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

* [Xen-devel] [PATCH v2 0/5] xen: avoid module usage in non-modular code
  2016-03-20  0:23 ` [PATCH v2 0/5] xen: avoid module usage in non-modular code Paul Gortmaker
@ 2016-03-21 15:17   ` David Vrabel
  0 siblings, 0 replies; 4+ messages in thread
From: David Vrabel @ 2016-03-21 15:17 UTC (permalink / raw)
  To: linux-arm-kernel

On 20/03/16 00:23, Paul Gortmaker wrote:
> [[PATCH v2 0/5] xen: avoid module usage in non-modular code] On 21/02/2016 (Sun 19:06) Paul Gortmaker wrote:
> 
>> This series of commits is a part of a larger project to ensure
>> people don't reference modular support functions in non-modular
>> code.  Overall there was roughly 5k lines of dead code in the
>> kernel due to this.  So far we've fixed several areas, like tty,
>> x86, net, ... and we continue to work on other areas.
> 
> Just wondering if this is still pending for this merge window; Stefano
> had reviewed the two commits he wanted changed vs. v1 and this v2 was
> sent approximately a month ago w/o any further change requests.

Sorry. While I was checking for pending series for 4.6 I accidentally
looked at v1 and saw outstanding comments and skipped it.

I've now applied this series, thanks.

David

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

end of thread, other threads:[~2016-03-21 15:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-22  0:06 [PATCH v2 0/5] xen: avoid module usage in non-modular code Paul Gortmaker
2016-02-22  0:06 ` [PATCH v2 1/5] xen: audit usages of module.h ; remove unnecessary instances Paul Gortmaker
2016-03-20  0:23 ` [PATCH v2 0/5] xen: avoid module usage in non-modular code Paul Gortmaker
2016-03-21 15:17   ` [Xen-devel] " David Vrabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).