Commit 7e5ebd0b authored by David S. Miller's avatar David S. Miller

Merge branch 'net-clean-up-needless-use-of-module-infrastructure'

Paul Gortmaker says:

====================
clean up needless use of module infrastructure

People can embed modular includes and modular exit functions into code
that never use any of it, and they won't get any errors or warnings.

Using modular infrastructure in non-modules might seem harmless, but some
of the downfalls this leads to are:

 (1) it is easy to accidentally write unused module_exit removal code
 (2) it can be misleading when reading the source, thinking a driver can
     be modular when the Makefile and/or Kconfig prohibit it
 (3) an unused include of the module.h header file will in turn
     include nearly everything else; adding a lot to CPP overhead.
 (4) it gets copied/replicated into other drivers and spreads quickly.

As a data point for #3 above, an empty C file that just includes the
module.h header generates over 750kB of CPP output.  Repeating the same
experiment with init.h and the result is less than 12kB; with export.h
it is only about 1/2kB; with both it still is less than 12kB.  One driver
in this series gets the module.h ---> init.h+export.h conversion.

Worse, are headers in include/linux that in turn include <linux/module.h>
as they can impact a whole fleet of drivers, or a whole subsystem, so
special care should be used in order to avoid that.  Such headers should
only include what they need to be stand-alone; they should not be trying
to anticipate the various header needs of their possible end users.

In this series, four include/linux headers have module.h removed from
them because they don't strictly need it.  Then three chunks of net
related code have modular infrastructure that isn't used, removed.

There are no runtime changes, so the biggest risk is a genuine consumer
of module.h content relying on implicitly getting it from one of the
include/linux instances removed here - thus resulting in a build fail.

With that in mind, allmodconfig build testing was done on x86-64, arm64,
x86-32, arm. powerpc, and mips on linux-next (and hence net-next).
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 3c618c1d 15253b4a
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
#define __NET_FIB_NOTIFIER_H #define __NET_FIB_NOTIFIER_H
#include <linux/types.h> #include <linux/types.h>
#include <linux/module.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
struct module;
struct fib_notifier_info { struct fib_notifier_info {
struct net *net; struct net *net;
int family; int family;
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/module.h>
#include <uapi/linux/ife.h> #include <uapi/linux/ife.h>
#if IS_ENABLED(CONFIG_NET_IFE) #if IS_ENABLED(CONFIG_NET_IFE)
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#define __NET_PSAMPLE_H #define __NET_PSAMPLE_H
#include <uapi/linux/psample.h> #include <uapi/linux/psample.h>
#include <linux/module.h>
#include <linux/list.h> #include <linux/list.h>
struct psample_group { struct psample_group {
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
#include <net/act_api.h> #include <net/act_api.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/module.h>
struct module;
struct tcf_ife_params { struct tcf_ife_params {
u8 eth_dst[ETH_ALEN]; u8 eth_dst[ETH_ALEN];
......
...@@ -301,6 +301,4 @@ static int __init init_cgroup_netprio(void) ...@@ -301,6 +301,4 @@ static int __init init_cgroup_netprio(void)
register_netdevice_notifier(&netprio_device_notifier); register_netdevice_notifier(&netprio_device_notifier);
return 0; return 0;
} }
subsys_initcall(init_cgroup_netprio); subsys_initcall(init_cgroup_netprio);
MODULE_LICENSE("GPL v2");
...@@ -77,5 +77,4 @@ static int __init bpfilter_sockopt_init(void) ...@@ -77,5 +77,4 @@ static int __init bpfilter_sockopt_init(void)
return 0; return 0;
} }
device_initcall(bpfilter_sockopt_init);
module_init(bpfilter_sockopt_init);
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
#include <linux/file.h> #include <linux/file.h>
#include <linux/in.h> #include <linux/in.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/export.h>
#include <linux/init.h>
#include <linux/net.h> #include <linux/net.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/poll.h> #include <linux/poll.h>
...@@ -545,7 +546,7 @@ void strp_check_rcv(struct strparser *strp) ...@@ -545,7 +546,7 @@ void strp_check_rcv(struct strparser *strp)
} }
EXPORT_SYMBOL_GPL(strp_check_rcv); EXPORT_SYMBOL_GPL(strp_check_rcv);
static int __init strp_mod_init(void) static int __init strp_dev_init(void)
{ {
strp_wq = create_singlethread_workqueue("kstrp"); strp_wq = create_singlethread_workqueue("kstrp");
if (unlikely(!strp_wq)) if (unlikely(!strp_wq))
...@@ -553,11 +554,4 @@ static int __init strp_mod_init(void) ...@@ -553,11 +554,4 @@ static int __init strp_mod_init(void)
return 0; return 0;
} }
device_initcall(strp_dev_init);
static void __exit strp_mod_exit(void)
{
destroy_workqueue(strp_wq);
}
module_init(strp_mod_init);
module_exit(strp_mod_exit);
MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment