Commit f7b390cd authored by Zheng Zucheng's avatar Zheng Zucheng Committed by Yang Yingliang
Browse files

sched: Change cgroup task scheduler policy

hulk inclusion
category: feature
bugzilla: 51828, https://gitee.com/openeuler/kernel/issues/I4K96G


CVE: NA

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

Added restrictions on modifying task scheduling policies:
1. task cannot be changed from offline to online.
2. When the scheduling policy of parent task is modified, the scheduling policy
   of all child node tasks is changed to be the same as that of the parent node.

Signed-off-by: default avatarZheng Zucheng <zhengzucheng@huawei.com>
Reviewed-by: default avatarChen Hui <judy.chenhui@huawei.com>
Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent 863fbf96
Loading
Loading
Loading
Loading
+29 −17
Original line number Diff line number Diff line
@@ -6925,25 +6925,16 @@ static u64 cpu_rt_period_read_uint(struct cgroup_subsys_state *css,
#endif /* CONFIG_RT_GROUP_SCHED */

#ifdef CONFIG_QOS_SCHED
static int cpu_qos_write(struct cgroup_subsys_state *css,
			struct cftype *cftype, s64 qos_level)
static int tg_change_scheduler(struct task_group *tg, void *data)
{
	int pid, policy;
	struct css_task_iter it;
	struct task_struct *tsk;
	struct task_group *tg;
	struct sched_param param;
	int pid, policy;
	tg = css_tg(css);

	if (!tg->se[0])
		return -EINVAL;

	if (qos_level != -1 && qos_level != 0)
		return -EINVAL;

	if (tg->qos_level == qos_level)
		goto done;
	struct task_struct *tsk;
	s64 qos_level = *(s64 *)data;
	struct cgroup_subsys_state *css = &tg->css;

	tg->qos_level = qos_level;
	if (qos_level == -1) {
		policy = SCHED_IDLE;
		cfs_bandwidth_usage_inc();
@@ -6952,8 +6943,6 @@ static int cpu_qos_write(struct cgroup_subsys_state *css,
		cfs_bandwidth_usage_dec();
	}

	tg->qos_level = qos_level;

	param.sched_priority = 0;
	css_task_iter_start(css, 0, &it);
	while ((tsk = css_task_iter_next(&it))) {
@@ -6964,6 +6953,29 @@ static int cpu_qos_write(struct cgroup_subsys_state *css,
	}
	css_task_iter_end(&it);

	return 0;
}

static int cpu_qos_write(struct cgroup_subsys_state *css,
			 struct cftype *cftype, s64 qos_level)
{
	struct task_group *tg = css_tg(css);

	if (!tg->se[0])
		return -EINVAL;

	if (qos_level != -1 && qos_level != 0)
		return -EINVAL;

	if (tg->qos_level == qos_level)
		goto done;

	if (tg->qos_level == -1 && qos_level == 0)
		return -EINVAL;

	rcu_read_lock();
	walk_tg_tree_from(tg, tg_change_scheduler, tg_nop, (void *)(&qos_level));
	rcu_read_unlock();
done:
	return 0;
}