Skip to contentSkip to conversation

mm: fix instances of non-modular code using modular fcns

PATCH In review Paul Gortmaker 4 participants 19 messages Aug 24, 2015 – Sep 22, 2015

Subsystems (9)
lore
Share & tools
lore
#1 lore raw

PATCH 1/10 mm: make cleancache.c explicitly non-modular

In reply to Paul Gortmaker

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.

---
 mm/cleancache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/cleancache.c +2 -2
index 8fc50811119b..ee0646d1c2fa 100644
@@ -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)
Signature · 7 lines
2.5.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#6 lore raw

PATCH 2/10 mm: make slab_common.c explicitly non-modular

In reply to Paul Gortmaker

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]>
---
 mm/slab_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/slab_common.c +2 -2
index 5ce4faeb16fb..a27aff8d7cdc 100644
@@ -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,
Signature · 7 lines
2.5.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#11 lore raw

PATCH 4/10 mm: make vmscan.c explicitly non-modular

In reply to Paul Gortmaker

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]>
---
 mm/vmscan.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/vmscan.c +1 -3
index 110733a715f6..dd0b58ff3938 100644
@@ -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
 /*
Signature · 7 lines
2.5.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#14 lore raw

PATCH 7/10 mm: make workingset.c explicitly non-modular

In reply to Paul Gortmaker

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.

---
 mm/workingset.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/workingset.c +2 -2
index aa017133744b..c2c59f599610 100644
@@ -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);
Signature · 7 lines
2.5.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#12 lore raw

PATCH 5/10 mm: make page_alloc.c explicitly non-modular

In reply to Paul Gortmaker

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]>
---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
index c1024db4ac5f..b02c511320fa 100644
@@ -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
Signature · 7 lines
2.5.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#9 lore raw

PATCH 3/10 mm: make hugetlb.c explicitly non-modular

In reply to Paul Gortmaker

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]>
---
 mm/hugetlb.c | 39 +--------------------------------------
 1 file changed, 1 insertion(+), 38 deletions(-)
mm/hugetlb.c +1 -38
index 586aa69df900..1154152c8b99 100644
@@ -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)
Signature · 1 line
2.5.0
#13 lore raw

PATCH 6/10 mm: make vmstat.c explicitly non-modular

In reply to Paul Gortmaker

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]>
---
 mm/vmstat.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
mm/vmstat.c +3 -4
index 1fd0886a389f..e6cd18cc4d75 100644
@@ -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
Signature · 7 lines
2.5.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#16 lore raw

PATCH 9/10 mm: make frontswap.c explicitly non-modular

In reply to Paul Gortmaker

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]>
---
 mm/frontswap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
mm/frontswap.c +2 -3
index 27a9924caf61..b36409766831 100644
@@ -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);
Signature · 7 lines
2.5.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#18 lore raw

PATCH 10/10 mm: make kasan.c explicitly non-modular

In reply to Paul Gortmaker

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]>
---
 mm/kasan/kasan.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/kasan/kasan.c +1 -3
index 7b28e9cdf1c7..19786018f172 100644
@@ -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
Signature · 7 lines
2.5.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#15 lore raw

PATCH 8/10 mm: make vmalloc.c explicitly non-modular

In reply to Paul Gortmaker

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]>
---
 mm/vmalloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/vmalloc.c +2 -2
index 2faaa2976447..a27e6b3d58f4 100644
@@ -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)
 {
Signature · 7 lines
2.5.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#0 lore raw

cover 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]>

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(-)
Signature · 7 lines
2.5.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw

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

In reply to Paul Gortmaker
Quoted 6 lines · Paul Gortmaker

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?

Quoted 28 lines

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.

---
mm/cleancache.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
mm/cleancache.c +1 -1
index 8fc50811119b..ee0646d1c2fa 100644
@@ -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>

mm/cleancache.c static int __init init_cleancache(void) · line 319

Quoted 5 lines
mm/cleancache.c +1 -1
@@ -316,4 +316,4 @@ static int __init init_cleancache(void)
 #endif
 	return 0;
 }
-module_init(init_cleancache)
+device_initcall(init_cleancache)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw

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

Quoted 9 lines · [Re: [PATCH 01/10] mm: make cleancache.c explicitly non-modular] On 24/08/2015…
Quoted 6 lines · Paul Gortmaker

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.
--

Quoted 24 lines
Quoted 24 lines

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.

---
mm/cleancache.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
mm/cleancache.c +0 -0
index 8fc50811119b..ee0646d1c2fa 100644
@@ -11,7 +11,7 @@
 * This work is licensed under the terms of the GNU GPL, version 2.
 */
 
Quoted 13 lines

mm/cleancache.c static int __init init_cleancache(void) · line 319

Quoted 11 lines
mm/cleancache.c +2 -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)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#7 lore raw

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

In reply to Paul Gortmaker

mm/slab_common.c static int __init slab_proc_init(void) · line 1119

Quoted 9 lines · Paul Gortmaker
mm/slab_common.c +1 -1
@@ -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.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw

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

Quoted 10 lines · Christoph Lameter
Quoted 8 lines · Paul Gortmaker
mm/slab_common.c +1 -1
@@ -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 */
 
Quoted 3 lines

mm/slab_common.c static int __init slab_proc_init(void) · line 1119

Quoted 1 line
mm/slab_common.c +0 -0
 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.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#10 lore raw

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

In reply to Paul Gortmaker
Quoted 5 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config HUGETLBFS
bool "HugeTLB file system support"

Quoted 8 lines

...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.

Quoted 79 lines
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]>
---
 mm/hugetlb.c | 39 +--------------------------------------
 1 file changed, 1 insertion(+), 38 deletions(-)
mm/hugetlb.c +0 -37
index 586aa69df900..1154152c8b99 100644
@@ -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;

mm/hugetlb.c static int __init hugetlb_init(void) · line 2545

Quoted 3 lines
mm/hugetlb.c +0 -0
@@ -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.

mm/hugetlb.c static int __init hugetlb_init(void) · line 2546

Quoted 2 lines
mm/hugetlb.c +1 -1
-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.

Signature · 1 line
Mike Kravetz
Quoted 4 lines
mm/hugetlb.c +0 -0
 /* Should be called on processing a hugepagesz=... option */
 void __init hugetlb_add_hstate(unsigned order)
 
#4 lore raw

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

In reply to Paul Gortmaker
Quoted 22 lines · Paul Gortmaker
Quoted 9 lines · [Re: [PATCH 01/10] mm: make cleancache.c explicitly non-modular] On 24/08/2015…
Quoted 6 lines · Paul Gortmaker

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.

Quoted 8 lines

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?

Sorry for taking so long. It really cannot be tri-state (I tried making it an module) as the cleancache hooks are tied in the mm/filemap.c.

Quoted 41 lines

Paul.
--

Quoted 37 lines
Quoted 35 lines

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.

---
mm/cleancache.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
mm/cleancache.c +2 -2
index 8fc50811119b..ee0646d1c2fa 100644
@@ -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)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Reviewed-by on v1 9/10
#17 lore raw

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

In reply to Paul Gortmaker
Quoted 7 lines · Paul Gortmaker

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.

Quoted 8 lines

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]>

I would add to the commit:

Frontswap depends on CONFIG_SWAP and there is currently no way to make swap dynamically loaded.

Quoted 30 lines
---
 mm/frontswap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
mm/frontswap.c +2 -3
index 27a9924caf61..b36409766831 100644
@@ -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);
Signature · 1 line
2.5.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw

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

In reply to Konrad Rzeszutek Wilk
Quoted 32 lines · [Re: [PATCH 01/10] mm: make cleancache.c explicitly non-modular] On 22/09/2015…
Quoted 22 lines · Paul Gortmaker
Quoted 9 lines · [Re: [PATCH 01/10] mm: make cleancache.c explicitly non-modular] On 24/08/2015…
Quoted 6 lines · Paul Gortmaker

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.

Quoted 8 lines

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?

Quoted 4 lines

Sorry for taking so long. It really cannot be tri-state (I tried making it an module) as the cleancache hooks are tied in the mm/filemap.c.

No problem, AFAIK these aren't queued anywhere and after having done a wider sweep, there are some 300+ of them (that give a net removal of ~5k lines of dead code) with some in maintainer-less code; so it looks like I'll inevitably have residuals that I'll have to ask Linus to pull directly.

Anyway, thanks for trying to modularize it. I'll add the reviewed tags and update the commit log on the other one to add your comment.

Paul.
--

Quoted 29 lines
Quoted 29 lines

Paul.
--

Quoted 24 lines
Quoted 24 lines

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.

---
mm/cleancache.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
mm/cleancache.c +0 -0
index 8fc50811119b..ee0646d1c2fa 100644
@@ -11,7 +11,7 @@
 * This work is licensed under the terms of the GNU GPL, version 2.
 */
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
mm/cleancache.c +1 -1
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/fs.h>
 #include <linux/exportfs.h>
 #include <linux/mm.h>
Quoted 8 lines
Quoted 8 lines

mm/cleancache.c static int __init init_cleancache(void) · line 319

Quoted 6 lines
mm/cleancache.c +1 -1
@@ -316,4 +316,4 @@ static int __init init_cleancache(void)
 #endif
 	return 0;
 }
-module_init(init_cleancache)
+device_initcall(init_cleancache)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>