Commit 80cefd92 authored by Zhang Qiao's avatar Zhang Qiao Committed by Zheng Zengkai
Browse files

sched: Fix sleeping in atomic context at cpu_qos_write()

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4WKMY


CVE: NA

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

cfs_bandwidth_usage_inc() need hold jump_label_mutex and
might sleep, so we can not call it in atomic context.
Fix this by moving cfs_bandwidth_usage_{inc,dec}() out of
rcu read critical section.

Signed-off-by: default avatarZhang Qiao <zhangqiao22@huawei.com>
Reviewed-by: default avatarChen Hui <judy.chenhui@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent b9c82a09
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -8507,13 +8507,10 @@ static int tg_change_scheduler(struct task_group *tg, void *data)
	struct cgroup_subsys_state *css = &tg->css;

	tg->qos_level = qos_level;
	if (qos_level == -1) {
	if (qos_level == -1)
		policy = SCHED_IDLE;
		cfs_bandwidth_usage_inc();
	} else {
	else
		policy = SCHED_NORMAL;
		cfs_bandwidth_usage_dec();
	}

	param.sched_priority = 0;
	css_task_iter_start(css, 0, &it);
@@ -8541,6 +8538,13 @@ static int cpu_qos_write(struct cgroup_subsys_state *css,
	if (tg->qos_level == -1 && qos_level == 0)
		return -EINVAL;

	cpus_read_lock();
	if (qos_level == -1)
		cfs_bandwidth_usage_inc();
	else
		cfs_bandwidth_usage_dec();
	cpus_read_unlock();

	rcu_read_lock();
	walk_tg_tree_from(tg, tg_change_scheduler, tg_nop, (void *)(&qos_level));
	rcu_read_unlock();