2015-08-24 22:16:45

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 00/10] mm: fix instances of non-modular code using modular fcns

In the previous merge window, we made changes to allow better
delineation between modular and non-modular code in commit
0fd972a7d91d6e15393c449492a04d94c0b89351 ("module: relocate module_init
from init.h to module.h"). This allows us to now ensure module code
looks modular and non-modular code does not accidentally look modular
without suffering build breakage from header entanglement.

Here we target mm code that is, by nature of their Kconfig/Makefile, only
available to be built-in, but implicitly presenting itself as being
possibly modular by way of using modular headers and macros.

The goal here is to remove that illusion of modularity from these
files, but in a way that leaves the actual runtime unchanged.
We also get the side benefit of a reduced CPP overhead, since the
removal of module.h from a file can reduce the number of lines emitted
by 20k.

In all but the hugetlb change, the change is the trivial remapping
of module_init onto device_initcall -- which is what module_init
becomes in the non-modular case. In the hugetlb case, there was also
an unused/orphaned module_exit chunk of code that got removed.

I considered using an alternate level (i.e. earlier) initcall but
since we don't have an mm initcall category, there wasn't a clear
choice. And staying with device initcall reduces this patch series
to zero risk by keeping the status quo on init order processing, which
is I think preferable as we approach the merge window in a week.

Paul.
---

Cc: Andrew Morton <[email protected]>
Cc: Andrey Konovalov <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Hillf Danton <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Mike Kravetz <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Naoya Horiguchi <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Rob Jones <[email protected]>
Cc: Roman Pen <[email protected]>
Cc: Sasha Levin <[email protected]>
Cc: Toshi Kani <[email protected]>
Cc: Vladimir Davydov <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: WANG Chao <[email protected]>
Cc: [email protected]


Paul Gortmaker (10):
mm: make cleancache.c explicitly non-modular
mm: make slab_common.c explicitly non-modular
mm: make hugetlb.c explicitly non-modular
mm: make vmscan.c explicitly non-modular
mm: make page_alloc.c explicitly non-modular
mm: make vmstat.c explicitly non-modular
mm: make workingset.c explicitly non-modular
mm: make vmalloc.c explicitly non-modular
mm: make frontswap.c explicitly non-modular
mm: make kasan.c explicitly non-modular

mm/cleancache.c | 4 ++--
mm/frontswap.c | 5 ++---
mm/hugetlb.c | 39 +--------------------------------------
mm/kasan/kasan.c | 4 +---
mm/page_alloc.c | 2 +-
mm/slab_common.c | 4 ++--
mm/vmalloc.c | 4 ++--
mm/vmscan.c | 4 +---
mm/vmstat.c | 7 +++----
mm/workingset.c | 4 ++--
10 files changed, 17 insertions(+), 60 deletions(-)

--
2.5.0


2015-08-24 22:15:48

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 01/10] mm: make cleancache.c explicitly non-modular

The Kconfig currently controlling compilation of this code is:

config CLEANCACHE
bool "Enable cleancache driver to cache clean pages if tmem is present"

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modularity so that when reading the
driver there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit.

Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
mm/cleancache.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/cleancache.c b/mm/cleancache.c
index 8fc50811119b..ee0646d1c2fa 100644
--- a/mm/cleancache.c
+++ b/mm/cleancache.c
@@ -11,7 +11,7 @@
* This work is licensed under the terms of the GNU GPL, version 2.
*/

-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/fs.h>
#include <linux/exportfs.h>
#include <linux/mm.h>
@@ -316,4 +316,4 @@ static int __init init_cleancache(void)
#endif
return 0;
}
-module_init(init_cleancache)
+device_initcall(init_cleancache)
--
2.5.0

2015-08-24 22:15:53

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 02/10] mm: make slab_common.c explicitly non-modular

The Makefile currently controlling compilation of this code is obj-y
meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modularity so that when reading the
code there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit. However
one could argue that subsys_initcall() might make more sense here.

Cc: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
mm/slab_common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/slab_common.c b/mm/slab_common.c
index 5ce4faeb16fb..a27aff8d7cdc 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -10,7 +10,7 @@
#include <linux/interrupt.h>
#include <linux/memory.h>
#include <linux/compiler.h>
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/cpu.h>
#include <linux/uaccess.h>
#include <linux/seq_file.h>
@@ -1113,7 +1113,7 @@ static int __init slab_proc_init(void)
&proc_slabinfo_operations);
return 0;
}
-module_init(slab_proc_init);
+device_initcall(slab_proc_init);
#endif /* CONFIG_SLABINFO */

static __always_inline void *__do_krealloc(const void *p, size_t new_size,
--
2.5.0

2015-08-24 22:15:57

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 03/10] mm: make hugetlb.c explicitly non-modular

The Kconfig currently controlling compilation of this code is:

config HUGETLBFS
bool "HugeTLB file system support"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that
when reading the file there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit. However
one could argue that fs_initcall() would make more sense here.

Cc: Andrew Morton <[email protected]>
Cc: Naoya Horiguchi <[email protected]>
Cc: Mike Kravetz <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Hillf Danton <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
mm/hugetlb.c | 39 +--------------------------------------
1 file changed, 1 insertion(+), 38 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 586aa69df900..1154152c8b99 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4,7 +4,6 @@
*/
#include <linux/list.h>
#include <linux/init.h>
-#include <linux/module.h>
#include <linux/mm.h>
#include <linux/seq_file.h>
#include <linux/sysctl.h>
@@ -2439,25 +2438,6 @@ static void hugetlb_unregister_node(struct node *node)
nhs->hugepages_kobj = NULL;
}

-/*
- * hugetlb module exit: unregister hstate attributes from node devices
- * that have them.
- */
-static void hugetlb_unregister_all_nodes(void)
-{
- int nid;
-
- /*
- * disable node device registrations.
- */
- register_hugetlbfs_with_node(NULL, NULL);
-
- /*
- * remove hstate attributes from any nodes that have them.
- */
- for (nid = 0; nid < nr_node_ids; nid++)
- hugetlb_unregister_node(node_devices[nid]);
-}

/*
* Register hstate attributes for a single node device.
@@ -2522,27 +2502,10 @@ static struct hstate *kobj_to_node_hstate(struct kobject *kobj, int *nidp)
return NULL;
}

-static void hugetlb_unregister_all_nodes(void) { }
-
static void hugetlb_register_all_nodes(void) { }

#endif

-static void __exit hugetlb_exit(void)
-{
- struct hstate *h;
-
- hugetlb_unregister_all_nodes();
-
- for_each_hstate(h) {
- kobject_put(hstate_kobjs[hstate_index(h)]);
- }
-
- kobject_put(hugepages_kobj);
- kfree(hugetlb_fault_mutex_table);
-}
-module_exit(hugetlb_exit);
-
static int __init hugetlb_init(void)
{
int i;
@@ -2580,7 +2543,7 @@ static int __init hugetlb_init(void)
mutex_init(&hugetlb_fault_mutex_table[i]);
return 0;
}
-module_init(hugetlb_init);
+device_initcall(hugetlb_init);

/* Should be called on processing a hugepagesz=... option */
void __init hugetlb_add_hstate(unsigned order)
--
2.5.0

2015-08-24 22:16:04

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 04/10] mm: make vmscan.c explicitly non-modular

The Makefile currently controlling compilation of this code is obj-y
meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modularity so that when reading the
code there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit. However
one could argue that subsys_initcall() might make more sense.

We don't replace module.h with init.h since the file already has that.

Cc: Andrew Morton <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Vladimir Davydov <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
mm/vmscan.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 110733a715f6..dd0b58ff3938 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -14,7 +14,6 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/mm.h>
-#include <linux/module.h>
#include <linux/gfp.h>
#include <linux/kernel_stat.h>
#include <linux/swap.h>
@@ -3687,8 +3686,7 @@ static int __init kswapd_init(void)
hotcpu_notifier(cpu_callback, 0);
return 0;
}
-
-module_init(kswapd_init)
+device_initcall(kswapd_init)

#ifdef CONFIG_NUMA
/*
--
2.5.0

2015-08-24 22:16:21

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 05/10] mm: make page_alloc.c explicitly non-modular

The Makefile currently controlling compilation of this code is obj-y
meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modularity so that when reading the
driver there is no doubt it is builtin-only. We have to leave the
module.h include though, as the file uses print_modules().

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit. However
one could argue that subsys_initcall() would make more sense.

Cc: Andrew Morton <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Sasha Levin <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
mm/page_alloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c1024db4ac5f..b02c511320fa 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6327,7 +6327,7 @@ int __meminit init_per_zone_wmark_min(void)
setup_per_zone_inactive_ratio();
return 0;
}
-module_init(init_per_zone_wmark_min)
+device_initcall(init_per_zone_wmark_min)

/*
* min_free_kbytes_sysctl_handler - just a wrapper around proc_dointvec() so
--
2.5.0

2015-08-24 22:16:20

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 06/10] mm: make vmstat.c explicitly non-modular

The Makefile currently controlling compilation of this code is obj-y
meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modularity so that when reading the
code there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit. However
one could argue that subsys_initcall might make more sense here.

Cc: Andrew Morton <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
mm/vmstat.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index 1fd0886a389f..e6cd18cc4d75 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -12,7 +12,7 @@
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/err.h>
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/slab.h>
#include <linux/cpu.h>
#include <linux/cpumask.h>
@@ -1536,7 +1536,7 @@ static int __init setup_vmstat(void)
#endif
return 0;
}
-module_init(setup_vmstat)
+device_initcall(setup_vmstat)

#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION)

@@ -1695,6 +1695,5 @@ fail:
debugfs_remove_recursive(extfrag_debug_root);
return -ENOMEM;
}
-
-module_init(extfrag_debug_init);
+device_initcall(extfrag_debug_init);
#endif
--
2.5.0

2015-08-24 22:17:51

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 07/10] mm: make workingset.c explicitly non-modular

The Makefile currently controlling compilation of this code is obj-y
meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modularity so that when reading the
code there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit. However
one could argue that subsys_initcall might make more sense here.

Cc: Vladimir Davydov <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
mm/workingset.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/workingset.c b/mm/workingset.c
index aa017133744b..c2c59f599610 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -8,7 +8,7 @@
#include <linux/writeback.h>
#include <linux/pagemap.h>
#include <linux/atomic.h>
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/swap.h>
#include <linux/fs.h>
#include <linux/mm.h>
@@ -412,4 +412,4 @@ err_list_lru:
err:
return ret;
}
-module_init(workingset_init);
+device_initcall(workingset_init);
--
2.5.0

2015-08-24 22:16:23

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 08/10] mm: make vmalloc.c explicitly non-modular

The Kconfig currently controlling compilation of this code is CONFIG_MMU
which is per arch, but in all cases it is bool or def_bool meaning that
it currently is not being built as a module by anyone.

Lets remove the couple traces of modularity so that when reading the
code there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit. However
one could argue that subsys_initcall might make more sense here.

Cc: Andrew Morton <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Roman Pen <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: Toshi Kani <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Rob Jones <[email protected]>
Cc: WANG Chao <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
mm/vmalloc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 2faaa2976447..a27e6b3d58f4 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -10,7 +10,7 @@

#include <linux/vmalloc.h>
#include <linux/mm.h>
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/highmem.h>
#include <linux/sched.h>
#include <linux/slab.h>
@@ -2686,7 +2686,7 @@ static int __init proc_vmalloc_init(void)
proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations);
return 0;
}
-module_init(proc_vmalloc_init);
+device_initcall(proc_vmalloc_init);

void get_vmalloc_info(struct vmalloc_info *vmi)
{
--
2.5.0

2015-08-24 22:16:00

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 09/10] mm: make frontswap.c explicitly non-modular

The Kconfig currently controlling compilation of this code is:

config FRONTSWAP
bool "Enable frontswap to cache swap pages if tmem is present"

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modularity so that when reading the
driver there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit. However
one could argue that subsys_initcall might make more sense here.

Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
mm/frontswap.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/frontswap.c b/mm/frontswap.c
index 27a9924caf61..b36409766831 100644
--- a/mm/frontswap.c
+++ b/mm/frontswap.c
@@ -15,7 +15,7 @@
#include <linux/swap.h>
#include <linux/swapops.h>
#include <linux/security.h>
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/debugfs.h>
#include <linux/frontswap.h>
#include <linux/swapfile.h>
@@ -500,5 +500,4 @@ static int __init init_frontswap(void)
#endif
return 0;
}
-
-module_init(init_frontswap);
+device_initcall(init_frontswap);
--
2.5.0

2015-08-24 22:18:03

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 10/10] mm: make kasan.c explicitly non-modular

The Makefile currently controlling compilation of this code is obj-y
meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modularity so that when reading the
code there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit. However
one could argue that subsys_initcall might make more sense here.

We don't replace module.h with init.h since the file already has that.

Cc: Andrey Ryabinin <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andrey Konovalov <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
mm/kasan/kasan.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 7b28e9cdf1c7..19786018f172 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -22,7 +22,6 @@
#include <linux/memblock.h>
#include <linux/memory.h>
#include <linux/mm.h>
-#include <linux/module.h>
#include <linux/printk.h>
#include <linux/sched.h>
#include <linux/slab.h>
@@ -532,6 +531,5 @@ static int __init kasan_memhotplug_init(void)

return 0;
}
-
-module_init(kasan_memhotplug_init);
+device_initcall(kasan_memhotplug_init);
#endif
--
2.5.0

2015-08-25 00:10:20

by Konrad Rzeszutek Wilk

[permalink] [raw]
Subject: Re: [PATCH 01/10] mm: make cleancache.c explicitly non-modular

On August 24, 2015 6:14:33 PM EDT, Paul Gortmaker <[email protected]> wrote:
>The Kconfig currently controlling compilation of this code is:
>
>config CLEANCACHE
>bool "Enable cleancache driver to cache clean pages if tmem is present"
>
>...meaning that it currently is not being built as a module by anyone.

Why not make it a tristate?


>
>Lets remove the couple traces of modularity so that when reading the
>driver there is no doubt it is builtin-only.
>
>Since module_init translates to device_initcall in the non-modular
>case, the init ordering remains unchanged with this commit.
>
>Cc: Konrad Rzeszutek Wilk <[email protected]>
>Cc: [email protected]
>Signed-off-by: Paul Gortmaker <[email protected]>
>---
> mm/cleancache.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/mm/cleancache.c b/mm/cleancache.c
>index 8fc50811119b..ee0646d1c2fa 100644
>--- a/mm/cleancache.c
>+++ b/mm/cleancache.c
>@@ -11,7 +11,7 @@
> * This work is licensed under the terms of the GNU GPL, version 2.
> */
>
>-#include <linux/module.h>
>+#include <linux/init.h>
> #include <linux/fs.h>
> #include <linux/exportfs.h>
> #include <linux/mm.h>
>@@ -316,4 +316,4 @@ static int __init init_cleancache(void)
> #endif
> return 0;
> }
>-module_init(init_cleancache)
>+device_initcall(init_cleancache)

2015-08-25 01:10:49

by Paul Gortmaker

[permalink] [raw]
Subject: Re: [PATCH 01/10] mm: make cleancache.c explicitly non-modular

[Re: [PATCH 01/10] mm: make cleancache.c explicitly non-modular] On 24/08/2015 (Mon 20:10) Konrad Rzeszutek Wilk wrote:

> On August 24, 2015 6:14:33 PM EDT, Paul Gortmaker <[email protected]> wrote:
> >The Kconfig currently controlling compilation of this code is:
> >
> >config CLEANCACHE
> >bool "Enable cleancache driver to cache clean pages if tmem is present"
> >
> >...meaning that it currently is not being built as a module by anyone.
>
> Why not make it a tristate?

Simple. I'm making the code consistent with its current behaviour.
I'm not looking to extend functionality in code that I don't know
intimately. I can't do that and do it reliably and guarantee it
works as a module when it has never been used as such before.

I've got about 130 of these and counting. Some of them have been bool
since before git history ; before the turn of the century. If there was
demand for them to be tristate, then it would have happened by now. So
clearly there is no point in looking at making _those_ tristate.

I did have one uart driver author indicate that he _meant_ his code to
be tristate, and he tested it as such, and asked if I would convert it
to tristate on his behalf. And that was fine and I did exactly that.

But unless there are interested users who want their code tristate and
can vouch that their code works OK as such, I can only make the code
consistent with the implicit non-modular behaviour that the Kconfig and
Makefiles have dictated up to now. Are there such users for CLEANCACHE?

Paul.
--

>
>
> >
> >Lets remove the couple traces of modularity so that when reading the
> >driver there is no doubt it is builtin-only.
> >
> >Since module_init translates to device_initcall in the non-modular
> >case, the init ordering remains unchanged with this commit.
> >
> >Cc: Konrad Rzeszutek Wilk <[email protected]>
> >Cc: [email protected]
> >Signed-off-by: Paul Gortmaker <[email protected]>
> >---
> > mm/cleancache.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> >diff --git a/mm/cleancache.c b/mm/cleancache.c
> >index 8fc50811119b..ee0646d1c2fa 100644
> >--- a/mm/cleancache.c
> >+++ b/mm/cleancache.c
> >@@ -11,7 +11,7 @@
> > * This work is licensed under the terms of the GNU GPL, version 2.
> > */
> >
> >-#include <linux/module.h>
> >+#include <linux/init.h>
> > #include <linux/fs.h>
> > #include <linux/exportfs.h>
> > #include <linux/mm.h>
> >@@ -316,4 +316,4 @@ static int __init init_cleancache(void)
> > #endif
> > return 0;
> > }
> >-module_init(init_cleancache)
> >+device_initcall(init_cleancache)
>
>

Subject: Re: [PATCH 02/10] mm: make slab_common.c explicitly non-modular

On Mon, 24 Aug 2015, Paul Gortmaker wrote:

> @@ -1113,7 +1113,7 @@ static int __init slab_proc_init(void)
> &proc_slabinfo_operations);
> return 0;
> }
> -module_init(slab_proc_init);
> +device_initcall(slab_proc_init);
> #endif /* CONFIG_SLABINFO */
>
> static __always_inline void *__do_krealloc(const void *p, size_t new_size,

True memory management is not a module. But its also not a device.

2015-08-25 15:35:43

by Paul Gortmaker

[permalink] [raw]
Subject: Re: [PATCH 02/10] mm: make slab_common.c explicitly non-modular

On 2015-08-25 10:59 AM, Christoph Lameter wrote:
> On Mon, 24 Aug 2015, Paul Gortmaker wrote:
>
>> @@ -1113,7 +1113,7 @@ static int __init slab_proc_init(void)
>> &proc_slabinfo_operations);
>> return 0;
>> }
>> -module_init(slab_proc_init);
>> +device_initcall(slab_proc_init);
>> #endif /* CONFIG_SLABINFO */
>>
>> static __always_inline void *__do_krealloc(const void *p, size_t new_size,
>
> True memory management is not a module. But its also not a device.

Per the 0/N I'd rather make it equivalent to what it was already
at this point in time and then consider making it a core_initcall
or post_core early in the next dev cycle if we want to give it
a more appropriately matching category, so we can then watch for
init reordering fallout with more time on our hands.

2015-08-26 16:47:30

by Mike Kravetz

[permalink] [raw]
Subject: Re: [PATCH 03/10] mm: make hugetlb.c explicitly non-modular

On 08/24/2015 03:14 PM, Paul Gortmaker wrote:
> The Kconfig currently controlling compilation of this code is:
>
> config HUGETLBFS
> bool "HugeTLB file system support"
>
> ...meaning that it currently is not being built as a module by anyone.
>
> Lets remove the modular code that is essentially orphaned, so that
> when reading the file there is no doubt it is builtin-only.
>
> Since module_init translates to device_initcall in the non-modular
> case, the init ordering remains unchanged with this commit. However
> one could argue that fs_initcall() would make more sense here.

I would prefer that it NOT be changed to fs_initcall() as this is more
about generic mm code than fs code. If this was in a hugetlbfs specific
file, fs_initcall() might make more sense.

More about changing initcall below.

> Cc: Andrew Morton <[email protected]>
> Cc: Naoya Horiguchi <[email protected]>
> Cc: Mike Kravetz <[email protected]>
> Cc: David Rientjes <[email protected]>
> Cc: Hillf Danton <[email protected]>
> Cc: Davidlohr Bueso <[email protected]>
> Cc: [email protected]
> Signed-off-by: Paul Gortmaker <[email protected]>
> ---
> mm/hugetlb.c | 39 +--------------------------------------
> 1 file changed, 1 insertion(+), 38 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 586aa69df900..1154152c8b99 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -4,7 +4,6 @@
> */
> #include <linux/list.h>
> #include <linux/init.h>
> -#include <linux/module.h>
> #include <linux/mm.h>
> #include <linux/seq_file.h>
> #include <linux/sysctl.h>
> @@ -2439,25 +2438,6 @@ static void hugetlb_unregister_node(struct node *node)
> nhs->hugepages_kobj = NULL;
> }
>
> -/*
> - * hugetlb module exit: unregister hstate attributes from node devices
> - * that have them.
> - */
> -static void hugetlb_unregister_all_nodes(void)
> -{
> - int nid;
> -
> - /*
> - * disable node device registrations.
> - */
> - register_hugetlbfs_with_node(NULL, NULL);
> -
> - /*
> - * remove hstate attributes from any nodes that have them.
> - */
> - for (nid = 0; nid < nr_node_ids; nid++)
> - hugetlb_unregister_node(node_devices[nid]);
> -}
>
> /*
> * Register hstate attributes for a single node device.
> @@ -2522,27 +2502,10 @@ static struct hstate *kobj_to_node_hstate(struct kobject *kobj, int *nidp)
> return NULL;
> }
>
> -static void hugetlb_unregister_all_nodes(void) { }
> -
> static void hugetlb_register_all_nodes(void) { }
>
> #endif
>
> -static void __exit hugetlb_exit(void)
> -{
> - struct hstate *h;
> -
> - hugetlb_unregister_all_nodes();
> -
> - for_each_hstate(h) {
> - kobject_put(hstate_kobjs[hstate_index(h)]);
> - }
> -
> - kobject_put(hugepages_kobj);
> - kfree(hugetlb_fault_mutex_table);
> -}
> -module_exit(hugetlb_exit);
> -
> static int __init hugetlb_init(void)
> {
> int i;
> @@ -2580,7 +2543,7 @@ static int __init hugetlb_init(void)
> mutex_init(&hugetlb_fault_mutex_table[i]);
> return 0;
> }

I am all for removal of the module_exit and associated code. It is
dead and is not used today. It would be a good idea to remove this
in any case.

> -module_init(hugetlb_init);
> +device_initcall(hugetlb_init);

Other more experienced people have opinions on your staged approach
to changing these init calls. If the consensus is to take this
approach, I would have no objections.

--
Mike Kravetz

>
> /* Should be called on processing a hugepagesz=... option */
> void __init hugetlb_add_hstate(unsigned order)
>