[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <08ff7e40806a2342720835b95f9be24d5778c703.1607332046.git.yuleixzhang@tencent.com>
Date: Mon, 7 Dec 2020 19:31:03 +0800
From: yulei.kernel@...il.com
To: linux-mm@...ck.org, akpm@...ux-foundation.org,
linux-fsdevel@...r.kernel.org, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, naoya.horiguchi@....com,
viro@...iv.linux.org.uk, pbonzini@...hat.com
Cc: joao.m.martins@...cle.com, rdunlap@...radead.org,
sean.j.christopherson@...el.com, xiaoguangrong.eric@...il.com,
kernellwp@...il.com, lihaiwei.kernel@...il.com,
Yulei Zhang <yuleixzhang@...cent.com>,
Xiao Guangrong <gloryxiao@...cent.com>
Subject: [RFC V2 10/37] dmemfs: introduce max_alloc_try_dpages parameter
From: Yulei Zhang <yuleixzhang@...cent.com>
It specifies the dmem page number allocated at one time, then
multiple radix entries can be created. That will relief the
allocation pressure and make page fault more fast.
However that could cause no dmem page mmapped to userspace
even if there are some free dmem pages.
Set it to 1 to completely disable this behavior.
Signed-off-by: Xiao Guangrong <gloryxiao@...cent.com>
Signed-off-by: Yulei Zhang <yuleixzhang@...cent.com>
---
fs/dmemfs/inode.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/fs/dmemfs/inode.c b/fs/dmemfs/inode.c
index 3192f31..443f2e1 100644
--- a/fs/dmemfs/inode.c
+++ b/fs/dmemfs/inode.c
@@ -34,6 +34,8 @@
#define CREATE_TRACE_POINTS
#include "trace.h"
+static uint __read_mostly max_alloc_try_dpages = 1;
+
struct dmemfs_mount_opts {
unsigned long dpage_size;
};
@@ -46,6 +48,44 @@ enum dmemfs_param {
Opt_dpagesize,
};
+static int
+max_alloc_try_dpages_set(const char *val, const struct kernel_param *kp)
+{
+ uint sval;
+ int ret;
+
+ ret = kstrtouint(val, 0, &sval);
+ if (ret)
+ return ret;
+
+ /* should be 1 at least */
+ if (!sval)
+ return -EINVAL;
+
+ max_alloc_try_dpages = sval;
+ return 0;
+}
+
+static struct kernel_param_ops alloc_max_try_dpages_ops = {
+ .set = max_alloc_try_dpages_set,
+ .get = param_get_uint,
+};
+
+/*
+ * it specifies the dmem page number allocated at one time, then
+ * multiple radix entries can be created. That will relief the
+ * allocation pressure and make page fault more fast.
+ *
+ * however that could cause no dmem page mmapped to userspace
+ * even if there are some free dmem pages
+ *
+ * set it to 1 to completely disable this behavior
+ */
+fs_param_cb(max_alloc_try_dpages, &alloc_max_try_dpages_ops,
+ &max_alloc_try_dpages, 0644);
+__MODULE_PARM_TYPE(max_alloc_try_dpages, "uint");
+MODULE_PARM_DESC(max_alloc_try_dpages, "Set the dmem page number allocated at one time, should be 1 at least");
+
const struct fs_parameter_spec dmemfs_fs_parameters[] = {
fsparam_string("pagesize", Opt_dpagesize),
{}
@@ -314,6 +354,7 @@ static void *find_radix_entry_or_next(struct address_space *mapping,
}
rcu_read_unlock();
+ try_dpages = min(try_dpages, max_alloc_try_dpages);
/* entry does not exist, create it */
addr = dmem_alloc_pages_vma(vma, fault_addr, try_dpages, &dpages);
if (!addr) {
--
1.8.3.1
Powered by blists - more mailing lists