[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250124235454.84587-3-anthony.yznaga@oracle.com>
Date: Fri, 24 Jan 2025 15:54:36 -0800
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, jthoughton@...gle.com, corbet@....net,
dave.hansen@...el.com, kirill@...temov.name, luto@...nel.org,
brauner@...nel.org, arnd@...db.de, ebiederm@...ssion.com,
catalin.marinas@....com, mingo@...hat.com, peterz@...radead.org,
liam.howlett@...cle.com, lorenzo.stoakes@...cle.com, vbabka@...e.cz,
jannh@...gle.com, hannes@...xchg.org, mhocko@...nel.org,
roman.gushchin@...ux.dev, shakeel.butt@...ux.dev,
muchun.song@...ux.dev, tglx@...utronix.de, cgroups@...r.kernel.org,
x86@...nel.org, linux-doc@...r.kernel.org, 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: [PATCH 02/20] mm/mshare: pre-populate msharefs with information file
From: Khalid Aziz <khalid@...nel.org>
Users of mshare need to know the size and alignment requirement
for shared regions. Pre-populate msharefs with a file, mshare_info,
that provides this information. For now, pagetable sharing is
hardcoded to be at the PUD level.
Signed-off-by: Khalid Aziz <khalid@...nel.org>
Signed-off-by: Anthony Yznaga <anthony.yznaga@...cle.com>
---
mm/mshare.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 75 insertions(+), 2 deletions(-)
diff --git a/mm/mshare.c b/mm/mshare.c
index 49d32e0c20d2..6d3760d1af8e 100644
--- a/mm/mshare.c
+++ b/mm/mshare.c
@@ -17,18 +17,74 @@
#include <linux/fs_context.h>
#include <uapi/linux/magic.h>
+const unsigned long mshare_align = P4D_SIZE;
+
static const struct file_operations msharefs_file_operations = {
.open = simple_open,
};
+struct msharefs_info {
+ struct dentry *info_dentry;
+};
+
+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", mshare_align);
+ 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;
@@ -36,6 +92,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;
@@ -51,7 +113,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
@@ -71,10 +135,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