Commit b46d56b1 authored by Hui Tang's avatar Hui Tang Committed by Yipeng Zou
Browse files

sched: Delete redundant updates to p->prefer_cpus

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: 21e5d85e ("sched: Fix possible deadlock in tg_set_dynamic_affinity_mode")
Signed-off-by: default avatarHui Tang <tanghui20@huawei.com>
Reviewed-by: default avatarZhang Qiao <zhangqiao22@huawei.com>
Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
Signed-off-by: default avatarYipeng Zou <zouyipeng@huawei.com>
parent a7ebb58e
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -8790,9 +8790,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);
@@ -8820,13 +8817,6 @@ void sched_move_task(struct task_struct *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)
+6 −2
Original line number Diff line number Diff line
@@ -6242,17 +6242,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

/**************************************************