mshare regions are subject to size and alignment requirement. This alignment boundary can be different on different architectures and userspace needs a way to know what the requirement is. Add a file /proc/sys/vm//mshare_size that can be read by userspace to get the alignment and size requirement. Signed-off-by: Khalid Aziz <khalid.aziz@xxxxxxxxxx> --- v1: - Provide a way for userspace to determine alignment and size retriction (based upon feedback from Dave Hansen) include/linux/mm.h | 1 + kernel/sysctl.c | 7 +++++++ mm/mshare.c | 3 +++ 3 files changed, 11 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 821ed7ee7b41..d9456d424202 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3339,6 +3339,7 @@ unsigned long wp_shared_mapping_range(struct address_space *mapping, #endif extern int sysctl_nr_trim_pages; +extern ulong sysctl_mshare_size; #ifdef CONFIG_PRINTK void mem_dump_obj(void *object); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 730ab56d9e92..66697ba5da88 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2810,6 +2810,13 @@ static struct ctl_table vm_table[] = { .extra2 = SYSCTL_ONE, }, #endif + { + .procname = "mshare_size", + .data = &sysctl_mshare_size, + .maxlen = sizeof(sysctl_mshare_size), + .mode = 0444, + .proc_handler = proc_doulongvec_minmax, + }, { } }; diff --git a/mm/mshare.c b/mm/mshare.c index ec23d1db79b2..88c7cefc933d 100644 --- a/mm/mshare.c +++ b/mm/mshare.c @@ -28,6 +28,8 @@ struct mshare_data { refcount_t refcnt; }; +ulong sysctl_mshare_size; + static struct super_block *msharefs_sb; /* Returns holding the host mm's lock for read. Caller must release. */ @@ -573,6 +575,7 @@ mshare_init(void) if (ret) sysfs_remove_mount_point(fs_kobj, "mshare"); + sysctl_mshare_size = PGDIR_SIZE; return ret; } -- 2.32.0