Re: [PATCH 09/10] fs: make hugetlbfs/inode.c explicitly non-modular

From: Paul Gortmaker
Date: Mon Dec 14 2015 - 11:14:11 EST


[[PATCH 09/10] fs: make hugetlbfs/inode.c explicitly non-modular] On 12/12/2015 (Sat 16:30) 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 driver there is no doubt it is builtin-only.
>
> Since module_init translates to device_initcall in the non-modular
> case, the init ordering gets bumped to one level earlier when we
> use the more appropriate fs_initcall here. However we've made similar
> changes before without any fallout and none is expected here either.

Famous last words. Turns out the 0-day builder found some fallout from
what is presumably the initlevel change in one of its qemu boot tests,
as per the snippet below that didn't show up in my testing.

So we can't use this one as-is. Currently investigating the implicit
initlevel dependency here to understand why it happens...

Paul.
--

BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
IP: [<ffffffff928af8d3>] __lock_acquire+0x160/0x1a3f
PGD 1b6a7067 PUD 1b711067 PMD 0
Oops: 0000 [#1] PREEMPT DEBUG_PAGEALLOC
Modules linked in:
CPU: 0 PID: 139 Comm: mount Not tainted 4.4.0-rc4-00009-g2e9d30b #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Debian-1.8.2-1 04/01/2014
task: ffff88001bcc0000 ti: ffff88001b720000 task.ti: ffff88001b720000
RIP: 0010:[<ffffffff928af8d3>] [<ffffffff928af8d3>] __lock_acquire+0x160/0x1a3f
RSP: 0018:ffff88001b723890 EFLAGS: 00010002
RAX: 0000000000000046 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000018
RBP: ffff88001b723960 R08: 0000000000000001 R09: 0000000000000001
R10: ffff88001b723980 R11: 0000000000001e27 R12: 0000000000000000
R13: ffff88001bcc0000 R14: 0000000000000018 R15: 0000000000000001
FS: 00007f77a46bb840(0000) GS:ffffffff93220000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000018 CR3: 000000001b703000 CR4: 00000000000006f0
Stack:
0000000000000400 0000000000000002 ffff88001bcc0000 0000000000000002
ffffffff9297f5b7 0000000100000000 ffff880000000000 0000000000000000
ffff88001bcc0000 ffff880000000000 ffffffff928ae160 ffff88001bcc0000
Call Trace:
[<ffffffff9297f5b7>] ? deactivate_slab+0x41c/0x919
[<ffffffff928ae160>] ? mark_held_locks+0x5e/0x74
[<ffffffff9293b230>] ? get_page_from_freelist+0x819/0xd4f
[<ffffffff928b16f8>] lock_acquire+0x121/0x1c2
[<ffffffff928b16f8>] ? lock_acquire+0x121/0x1c2
[<ffffffff9297f5b7>] ? deactivate_slab+0x41c/0x919
[<ffffffff92de0cf2>] _raw_spin_lock+0x32/0x41
[<ffffffff9297f5b7>] ? deactivate_slab+0x41c/0x919
[<ffffffff9297f5b7>] deactivate_slab+0x41c/0x919
[<ffffffff92806479>] ? print_context_stack+0x6a/0xb6
[<ffffffff928a1b5e>] ? preempt_count_sub+0x34/0x3f
[<ffffffff92805e94>] ? dump_trace+0x28a/0x2a2
[<ffffffff929ffe1f>] ? hugetlbfs_alloc_inode+0x99/0xcc

>
> We delete the MODULE_LICENSE tag and capture that information at the
> top of the file alongside author comments, etc.
>
> We don't replace module.h with init.h since the file already has that.
> Also note that MODULE_ALIAS is a no-op for non-modular code.
>
> Cc: Nadia Yvette Chambers <nyc@xxxxxxxxxxxxxx>
> Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
> Cc: linux-fsdevel@xxxxxxxxxxxxxxx
> Signed-off-by: Paul Gortmaker <paul.gortmaker@xxxxxxxxxxxxx>
> ---
> fs/hugetlbfs/inode.c | 27 ++-------------------------
> 1 file changed, 2 insertions(+), 25 deletions(-)
>
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index a1cb8fd2289b..47789292a582 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -4,11 +4,11 @@
> * Nadia Yvette Chambers, 2002
> *
> * Copyright (C) 2002 Linus Torvalds.
> + * License: GPL
> */
>
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> -#include <linux/module.h>
> #include <linux/thread_info.h>
> #include <asm/current.h>
> #include <linux/sched.h> /* remove ASAP */
> @@ -1202,7 +1202,6 @@ static struct file_system_type hugetlbfs_fs_type = {
> .mount = hugetlbfs_mount,
> .kill_sb = kill_litter_super,
> };
> -MODULE_ALIAS_FS("hugetlbfs");
>
> static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
>
> @@ -1356,26 +1355,4 @@ static int __init init_hugetlbfs_fs(void)
> out2:
> return error;
> }
> -
> -static void __exit exit_hugetlbfs_fs(void)
> -{
> - struct hstate *h;
> - int i;
> -
> -
> - /*
> - * Make sure all delayed rcu free inodes are flushed before we
> - * destroy cache.
> - */
> - rcu_barrier();
> - kmem_cache_destroy(hugetlbfs_inode_cachep);
> - i = 0;
> - for_each_hstate(h)
> - kern_unmount(hugetlbfs_vfsmount[i++]);
> - unregister_filesystem(&hugetlbfs_fs_type);
> -}
> -
> -module_init(init_hugetlbfs_fs)
> -module_exit(exit_hugetlbfs_fs)
> -
> -MODULE_LICENSE("GPL");
> +fs_initcall(init_hugetlbfs_fs)
> --
> 2.6.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/