From: Hui Tang tanghui20@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7F7KV CVE: NA
-------------------------------
Delete redundant updates to p->prefer_cpus when smart grid used. Add missed check for p->prefer_cpus when !CONFIG_QOS_SCHED_SMART_GRID.
Fixes: 21e5d85e205f ("sched: Fix possible deadlock in tg_set_dynamic_affinity_mode") Signed-off-by: Hui Tang tanghui20@huawei.com Reviewed-by: Zhang Qiao zhangqiao22@huawei.com Signed-off-by: Zhang Changzhong zhangchangzhong@huawei.com --- kernel/sched/core.c | 11 ----------- kernel/sched/fair.c | 8 ++++++-- 2 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index c7016a4..67bda87 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6534,9 +6534,6 @@ void sched_move_task(struct task_struct *tsk) DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK; struct rq_flags rf; struct rq *rq; -#ifdef CONFIG_QOS_SCHED_SMART_GRID - struct affinity_domain *ad; -#endif
rq = task_rq_lock(tsk, &rf); update_rq_clock(rq); @@ -6557,14 +6554,6 @@ void sched_move_task(struct task_struct *tsk) set_curr_task(rq, tsk);
task_rq_unlock(rq, tsk, &rf); - -#ifdef CONFIG_QOS_SCHED_SMART_GRID - if (smart_grid_used()) { - ad = &task_group(tsk)->auto_affinity->ad; - set_prefer_cpus_ptr(tsk, ad->domains[ad->curr_level]); - } -#endif - }
static inline struct task_group *css_tg(struct cgroup_subsys_state *css) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2115d79..a7401df 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5714,17 +5714,21 @@ static void destroy_auto_affinity(struct task_group *tg) static void destroy_auto_affinity(struct task_group *tg) {}
#ifdef CONFIG_QOS_SCHED_DYNAMIC_AFFINITY +static inline bool prefer_cpus_valid(struct task_struct *p); + static inline struct cpumask *task_prefer_cpus(struct task_struct *p) { return p->prefer_cpus; } -#endif
static inline int dynamic_affinity_mode(struct task_struct *p) { + if (!prefer_cpus_valid(p)) + return -1; + return 0; } - +#endif #endif
/**************************************************