From: Zheng Zucheng zhengzucheng@huawei.com
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: Zheng Zucheng zhengzucheng@huawei.com --- kernel/sched/core.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 900637a6ac09..b734d561c43b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -9810,6 +9810,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) { @@ -9876,10 +9878,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