Commit 9c8a6883 authored by Zheng Zucheng's avatar Zheng Zucheng Committed by Cheng Yu
Browse files

sched/core: Add mutex lock to protect steal_task

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IAQWPQ



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

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

Signed-off-by: default avatarZheng Zucheng <zhengzucheng@huawei.com>
parent 1f9456c8
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -9813,6 +9813,8 @@ static inline s64 cpu_qos_read(struct cgroup_subsys_state *css,
#endif

#ifdef CONFIG_SCHED_STEAL
static DEFINE_MUTEX(steal_mutex);

static inline s64 cpu_steal_task_read(struct cgroup_subsys_state *css,
				      struct cftype *cft)
{
@@ -9879,10 +9881,14 @@ static int cpu_steal_task_write(struct cgroup_subsys_state *css,
	if (steal_task < TG_STEAL_NO || steal_task > TG_STEAL)
		return -EINVAL;

	mutex_lock(&steal_mutex);

	rcu_read_lock();
	walk_tg_tree_from(tg, tg_change_steal, tg_nop, (void *)(&steal_task));
	rcu_read_unlock();

	mutex_unlock(&steal_mutex);

	return 0;
}
#endif