
These two interface have the same meaning and almost the same value except the initial value. By default, high_async_ratio return 100, wmark_ratio return 0, but the meaning is the same, all means the async-reclaim is disabeld. Signed-off-by: Liu Shixin <liushixin2@huawei.com> --- mm/memcontrol.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 44caef983b6f..ffc75baeacd4 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6056,6 +6056,44 @@ static ssize_t memcg_high_async_ratio_write(struct kernfs_open_file *of, return nbytes; } + +static int memcg_wmark_ratio_show(struct seq_file *m, void *v) +{ + int ratio = READ_ONCE(mem_cgroup_from_seq(m)->high_async_ratio); + + if (ratio == HIGH_ASYNC_RATIO_BASE) + ratio = 0; + + seq_printf(m, "%d\n", ratio); + + return 0; +} + +static ssize_t memcg_wmark_ratio_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); + int ret, high_async_ratio; + + buf = strstrip(buf); + if (!buf) + return -EINVAL; + + ret = kstrtoint(buf, 0, &high_async_ratio); + if (ret) + return ret; + + if (high_async_ratio > HIGH_ASYNC_RATIO_BASE || + high_async_ratio < 0) + return -EINVAL; + + if (high_async_ratio == 0) + high_async_ratio = HIGH_ASYNC_RATIO_BASE; + + WRITE_ONCE(memcg->high_async_ratio, high_async_ratio); + + return nbytes; +} #endif #ifdef CONFIG_CGROUP_V1_WRITEBACK @@ -6314,6 +6352,12 @@ static struct cftype mem_cgroup_legacy_files[] = { .seq_show = memcg_high_async_ratio_show, .write = memcg_high_async_ratio_write, }, + { + .name = "wmark_ratio", + .flags = CFTYPE_NOT_ON_ROOT, + .seq_show = memcg_wmark_ratio_show, + .write = memcg_wmark_ratio_write, + }, { .name = "reclaim", .write = memory_reclaim, -- 2.34.1