提交 585de8f5 编写于 作者: J Jing Xiangfeng 提交者: Zheng Zengkai

memcg: update the child's qos_level synchronously in memcg_qos_write()

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I3ZN3O
CVE: NA

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

If parent's qos_level is set, iterate over all cgroups (under this tree)
to modify memory.qos_level synchronously. Currently qos_level support 0
and -1.
Signed-off-by: NJing Xiangfeng <jingxiangfeng@huawei.com>
Reviewed-by: NLiu Shixin <liushixin2@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 ce7fa1af
......@@ -3960,6 +3960,23 @@ static int mem_cgroup_move_charge_write(struct cgroup_subsys_state *css,
int sysctl_memcg_qos_stat = DISABLE_MEMCG_QOS;
DEFINE_STATIC_KEY_FALSE(memcg_qos_stat_key);
static void memcg_hierarchy_qos_set(struct mem_cgroup *memcg, int val)
{
struct mem_cgroup *iter;
struct cgroup_subsys_state *css;
if (!memcg)
memcg = root_mem_cgroup;
rcu_read_lock();
css_for_each_descendant_pre(css, &memcg->css) {
iter = mem_cgroup_from_css(css);
iter->memcg_priority = val;
}
rcu_read_unlock();
}
static void memcg_qos_init(struct mem_cgroup *memcg)
{
struct mem_cgroup *parent = parent_mem_cgroup(memcg);
......@@ -3991,10 +4008,15 @@ static int memcg_qos_write(struct cgroup_subsys_state *css,
if (!static_branch_likely(&memcg_qos_stat_key))
return -EACCES;
if (val >= 0)
memcg->memcg_priority = 0;
else
memcg->memcg_priority = -1;
if (mem_cgroup_is_root(memcg))
return -EINVAL;
if (val != 0 && val != -1)
return -EINVAL;
memcg->memcg_priority = val;
if (memcg->use_hierarchy)
memcg_hierarchy_qos_set(memcg, val);
return 0;
}
......@@ -4085,19 +4107,6 @@ void memcg_print_bad_task(void *arg, int ret)
}
}
static void memcg_qos_reset(void)
{
struct mem_cgroup *iter;
struct cgroup_subsys_state *css;
rcu_read_lock();
css_for_each_descendant_pre(css, &root_mem_cgroup->css) {
iter = mem_cgroup_from_css(css);
iter->memcg_priority = 0;
}
rcu_read_unlock();
}
int sysctl_memcg_qos_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *length, loff_t *ppos)
{
......@@ -4112,7 +4121,7 @@ int sysctl_memcg_qos_handler(struct ctl_table *table, int write,
pr_info("enable memcg priority.\n");
} else {
static_branch_disable(&memcg_qos_stat_key);
memcg_qos_reset();
memcg_hierarchy_qos_set(NULL, 0);
pr_info("disable memcg priority.\n");
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册