From: Weilong Chen <chenweilong@huawei.com>
To: <viro@zeniv.linux.org.uk>, <keescook@chromium.org>,
<gregkh@linuxfoundation.org>
Cc: <samitolvanen@google.com>, <ojeda@kernel.org>, <johan@kernel.org>,
<akpm@linux-foundation.org>, <masahiroy@kernel.org>,
<elver@google.com>, <joe@perches.com>, <hare@suse.de>,
<linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [linux-next v2] rootfs: rootflags take effect when mount rootfs
Date: Wed, 30 Jun 2021 09:47:44 +0800 [thread overview]
Message-ID: <20210630014744.88735-1-chenweilong@huawei.com> (raw)
The kernel root filesystem may use the rootflags parameters
when mount, especially for tmpfs, to setup a variety of features.
For example:
1. Add 'rootflags=huge=always' to boot args.
2. When the OS bootup:
rootfs on / type rootfs (..., huge=always)
Then we can get the hugepage performance improvement of tmpfs.
Usage:
Relevant documents (Documentation/admin-guide/kernel-parameters.txt)
description:
rootflags= [KNL] Set root filesystem mount option string
Signed-off-by: Weilong Chen <chenweilong@huawei.com>
---
fs/namespace.c | 5 +++--
include/linux/init.h | 2 +-
init/do_mounts.c | 4 +++-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index c3f1a78ba369..318ad4fbc20b 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -4184,6 +4184,7 @@ SYSCALL_DEFINE5(mount_setattr, int, dfd, const char __user *, path,
return err;
}
+static char * __initdata rootfs_flags;
static void __init init_mount_tree(void)
{
struct vfsmount *mnt;
@@ -4191,7 +4192,7 @@ static void __init init_mount_tree(void)
struct mnt_namespace *ns;
struct path root;
- mnt = vfs_kern_mount(&rootfs_fs_type, 0, "rootfs", NULL);
+ mnt = vfs_kern_mount(&rootfs_fs_type, 0, "rootfs", rootfs_flags);
if (IS_ERR(mnt))
panic("Can't create rootfs");
@@ -4245,7 +4246,7 @@ void __init mnt_init(void)
if (!fs_kobj)
printk(KERN_WARNING "%s: kobj create error\n", __func__);
shmem_init();
- init_rootfs();
+ init_rootfs(&rootfs_flags);
init_mount_tree();
}
diff --git a/include/linux/init.h b/include/linux/init.h
index d82b4b2e1d25..d8d46d3c73fb 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -148,7 +148,7 @@ extern unsigned int reset_devices;
/* used by init/main.c */
void setup_arch(char **);
void prepare_namespace(void);
-void __init init_rootfs(void);
+void __init init_rootfs(char **rootfs_flags);
extern struct file_system_type rootfs_fs_type;
#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX)
diff --git a/init/do_mounts.c b/init/do_mounts.c
index a78e44ee6adb..42019b5fbf45 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -632,9 +632,11 @@ struct file_system_type rootfs_fs_type = {
.kill_sb = kill_litter_super,
};
-void __init init_rootfs(void)
+void __init init_rootfs(char **rootfs_flags)
{
if (IS_ENABLED(CONFIG_TMPFS) && !saved_root_name[0] &&
(!root_fs_names || strstr(root_fs_names, "tmpfs")))
is_tmpfs = true;
+
+ *rootfs_flags = root_mount_data;
}
--
2.31.GIT
reply other threads:[~2021-06-30 1:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210630014744.88735-1-chenweilong@huawei.com \
--to=chenweilong@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=elver@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=hare@suse.de \
--cc=joe@perches.com \
--cc=johan@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=ojeda@kernel.org \
--cc=samitolvanen@google.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).