提交 3b3608e0 编写于 作者: L Liu Shixin 提交者: Yang Yingliang

mm/vmscan: setup drop_caches_loop_limit in cmdline

hulk inclusion
category: bugfix
bugzilla: 175105
CVE: NA

-------------------------------------------------

When !CONFIG_SYSCTL, drop_caches_loop_limit is invisible.
Add cmdline "drop_caches_loop_limit=" to set it.
This parameter can limit the number of loops per node.

Fixes: ceb5620e ("mm/vmscan: add drop_caches_loop_limit to break loop in drop_slab_node")
Signed-off-by: NLiu Shixin <liushixin2@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 47caf84f
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
/* A global variable is a bit ugly, but it keeps the code simple */ /* A global variable is a bit ugly, but it keeps the code simple */
int sysctl_drop_caches; int sysctl_drop_caches;
unsigned int sysctl_drop_caches_loop_limit __read_mostly;
static void drop_pagecache_sb(struct super_block *sb, void *unused) static void drop_pagecache_sb(struct super_block *sb, void *unused)
{ {
......
...@@ -2769,7 +2769,7 @@ extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm); ...@@ -2769,7 +2769,7 @@ extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm);
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
extern int sysctl_drop_caches; extern int sysctl_drop_caches;
extern unsigned int sysctl_drop_caches_loop_limit; extern unsigned int drop_caches_loop_limit;
int drop_caches_sysctl_handler(struct ctl_table *, int, int drop_caches_sysctl_handler(struct ctl_table *, int,
void __user *, size_t *, loff_t *); void __user *, size_t *, loff_t *);
#endif #endif
......
...@@ -1479,7 +1479,7 @@ static struct ctl_table vm_table[] = { ...@@ -1479,7 +1479,7 @@ static struct ctl_table vm_table[] = {
}, },
{ {
.procname = "drop_caches_loop_limit", .procname = "drop_caches_loop_limit",
.data = &sysctl_drop_caches_loop_limit, .data = &drop_caches_loop_limit,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(unsigned int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_douintvec, .proc_handler = proc_douintvec,
......
...@@ -723,12 +723,21 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, ...@@ -723,12 +723,21 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
return freed; return freed;
} }
unsigned int drop_caches_loop_limit __read_mostly;
static int __init drop_caches_loop_limit_setup(char *s)
{
int ret = kstrtouint(s, 10, &drop_caches_loop_limit);
if (ret)
pr_info("Parse drop_caches_loop_limit failed: ret: %d\n", ret);
return 1;
}
__setup("drop_caches_loop_limit=", drop_caches_loop_limit_setup);
void drop_slab_node(int nid) void drop_slab_node(int nid)
{ {
unsigned long freed; unsigned long freed;
#ifdef CONFIG_SYSCTL
unsigned int counts = 0; unsigned int counts = 0;
#endif
do { do {
struct mem_cgroup *memcg = NULL; struct mem_cgroup *memcg = NULL;
...@@ -742,17 +751,15 @@ void drop_slab_node(int nid) ...@@ -742,17 +751,15 @@ void drop_slab_node(int nid)
freed += shrink_slab(GFP_KERNEL, nid, memcg, 0); freed += shrink_slab(GFP_KERNEL, nid, memcg, 0);
} while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL);
#ifdef CONFIG_SYSCTL if (unlikely(drop_caches_loop_limit)) {
if (unlikely(sysctl_drop_caches_loop_limit)) {
counts++; counts++;
if (counts >= sysctl_drop_caches_loop_limit) { if (counts >= drop_caches_loop_limit) {
pr_info("%s (%d): drop_caches early break: %u loops\n", pr_info("%s (%d): drop_caches early break: %u loops\n",
current->comm, task_pid_nr(current), current->comm, task_pid_nr(current),
counts); counts);
return; return;
} }
} }
#endif
} while (freed > 10); } while (freed > 10);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册