[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240903232241.43995-3-anthony.yznaga@oracle.com>
Date: Tue, 3 Sep 2024 16:22:33 -0700
From: Anthony Yznaga <anthony.yznaga@...cle.com>
To: akpm@...ux-foundation.org, willy@...radead.org, markhemm@...glemail.com,
viro@...iv.linux.org.uk, david@...hat.com, khalid@...nel.org
Cc: anthony.yznaga@...cle.com, andreyknvl@...il.com, dave.hansen@...el.com,
luto@...nel.org, brauner@...nel.org, arnd@...db.de,
ebiederm@...ssion.com, catalin.marinas@....com,
linux-arch@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, mhiramat@...nel.org, rostedt@...dmis.org,
vasily.averin@...ux.dev, xhao@...ux.alibaba.com, pcc@...gle.com,
neilb@...e.de, maz@...nel.org
Subject: [RFC PATCH v3 02/10] mm/mshare: pre-populate msharefs with information file
From: Khalid Aziz <khalid@...nel.org>
Users of mshare feature to share page tables need to know the size
and alignment requirement for shared regions. Pre-populate msharefs
with a file, mshare_info, that provides this information.
Signed-off-by: Khalid Aziz <khalid@...nel.org>
Signed-off-by: Anthony Yznaga <anthony.yznaga@...cle.com>
---
mm/mshare.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 73 insertions(+), 2 deletions(-)
diff --git a/mm/mshare.c b/mm/mshare.c
index d5d8e2530e5a..6562000545e1 100644
--- a/mm/mshare.c
+++ b/mm/mshare.c
@@ -17,19 +17,73 @@
#include <linux/fs_context.h>
#include <uapi/linux/magic.h>
+struct msharefs_info {
+ struct dentry *info_dentry;
+};
+
static const struct file_operations msharefs_file_operations = {
.open = simple_open,
.llseek = no_llseek,
};
+static ssize_t
+mshare_info_read(struct file *file, char __user *buf, size_t nbytes,
+ loff_t *ppos)
+{
+ char s[80];
+
+ sprintf(s, "%ld\n", PGDIR_SIZE);
+ return simple_read_from_buffer(buf, nbytes, ppos, s, strlen(s));
+}
+
+static const struct file_operations mshare_info_ops = {
+ .read = mshare_info_read,
+ .llseek = noop_llseek,
+};
+
static const struct super_operations mshare_s_ops = {
.statfs = simple_statfs,
};
+static int
+msharefs_create_mshare_info(struct super_block *sb)
+{
+ struct msharefs_info *info = sb->s_fs_info;
+ struct dentry *root = sb->s_root;
+ struct dentry *dentry;
+ struct inode *inode;
+ int ret;
+
+ ret = -ENOMEM;
+ inode = new_inode(sb);
+ if (!inode)
+ goto out;
+
+ inode->i_ino = 2;
+ simple_inode_init_ts(inode);
+ inode_init_owner(&nop_mnt_idmap, inode, NULL, S_IFREG | 0444);
+ inode->i_fop = &mshare_info_ops;
+
+ dentry = d_alloc_name(root, "mshare_info");
+ if (!dentry)
+ goto out;
+
+ info->info_dentry = dentry;
+ d_add(dentry, inode);
+
+ return 0;
+out:
+ iput(inode);
+
+ return ret;
+}
+
static int
msharefs_fill_super(struct super_block *sb, struct fs_context *fc)
{
+ struct msharefs_info *info;
struct inode *inode;
+ int ret;
sb->s_blocksize = PAGE_SIZE;
sb->s_blocksize_bits = PAGE_SHIFT;
@@ -37,6 +91,12 @@ msharefs_fill_super(struct super_block *sb, struct fs_context *fc)
sb->s_op = &mshare_s_ops;
sb->s_time_gran = 1;
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+
+ sb->s_fs_info = info;
+
inode = new_inode(sb);
if (!inode)
return -ENOMEM;
@@ -52,7 +112,9 @@ msharefs_fill_super(struct super_block *sb, struct fs_context *fc)
if (!sb->s_root)
return -ENOMEM;
- return 0;
+ ret = msharefs_create_mshare_info(sb);
+
+ return ret;
}
static int
@@ -72,10 +134,19 @@ mshare_init_fs_context(struct fs_context *fc)
return 0;
}
+static void
+msharefs_kill_super(struct super_block *sb)
+{
+ struct msharefs_info *info = sb->s_fs_info;
+
+ kfree(info);
+ kill_litter_super(sb);
+}
+
static struct file_system_type mshare_fs = {
.name = "msharefs",
.init_fs_context = mshare_init_fs_context,
- .kill_sb = kill_litter_super,
+ .kill_sb = msharefs_kill_super,
};
static int __init
--
2.43.5
Powered by blists - more mailing lists