Commit 995f0e60 authored by zhangwei123171's avatar zhangwei123171
Browse files

sched: add mutex lock to protect qos_level

jingdong inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I80FQN



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

In order to reduce the concurrent operations introduced
by users setting qos_level, we add a mutex lock.

Fixes: bda15404 ("sched: Introduce qos scheduler for co-location")
Signed-off-by: default avatarzhangwei123171 <zhangwei123171@jd.com>
Reviewed-by: default avatarzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
parent f41354b6
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -8569,6 +8569,13 @@ static inline int alloc_qos_sched_group(struct task_group *tg,
#ifdef CONFIG_QOS_SCHED_SMT_EXPELLER
	tg->smt_expell = parent->smt_expell;
#endif
	tg->qos_level_mutex = kzalloc(sizeof(struct mutex), GFP_KERNEL);

	if (!tg->qos_level_mutex)
		return 0;

	mutex_init(tg->qos_level_mutex);

	return 1;
}

@@ -9512,6 +9519,7 @@ static int tg_change_scheduler(struct task_group *tg, void *data)
	s64 qos_level = *(s64 *)data;
	struct cgroup_subsys_state *css = &tg->css;

	mutex_lock(tg->qos_level_mutex);
	tg->qos_level = qos_level;
	if (is_offline_level(qos_level))
		policy = SCHED_IDLE;
@@ -9529,6 +9537,7 @@ static int tg_change_scheduler(struct task_group *tg, void *data)
		sched_setscheduler(tsk, policy, &param);
	}
	css_task_iter_end(&it);
	mutex_unlock(tg->qos_level_mutex);

	return 0;
}
+3 −0
Original line number Diff line number Diff line
@@ -12853,6 +12853,9 @@ void free_fair_sched_group(struct task_group *tg)
			kfree(tg->se[i]);
	}

#ifdef CONFIG_QOS_SCHED
	kfree(tg->qos_level_mutex);
#endif
	kfree(tg->cfs_rq);
	kfree(tg->se);
}
+4 −0
Original line number Diff line number Diff line
@@ -466,7 +466,11 @@ struct task_group {
#else
	KABI_RESERVE(2)
#endif
#ifdef CONFIG_QOS_SCHED
	KABI_USE(3, struct mutex *qos_level_mutex)
#else
	KABI_RESERVE(3)
#endif
	KABI_RESERVE(4)
};