Unverified Commit e7454d7c authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12007 Fix CVE-2024-44958 for 4.19

Merge Pull Request from: @ci-robot 
 
PR sync from: Zheng Zucheng <zhengzucheng@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/F3DYVR47K6ZMEJH6HNT64WX5SXXHKBNS/ 
Yang Yingliang (2):
  sched/smt: Introduce sched_smt_present_inc/dec() helper
  sched/smt: Fix unbalance sched_smt_present dec/inc

Zheng Zucheng (1):
  sched: Revert fix unbalance sched_smt_present dec/inc


-- 
2.34.1
 
https://gitee.com/src-openeuler/kernel/issues/IAOXYI 
 
Link:https://gitee.com/openeuler/kernel/pulls/12007

 

Reviewed-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
parents 14558c56 7d01838c
Loading
Loading
Loading
Loading
+19 −12
Original line number Diff line number Diff line
@@ -5831,18 +5831,31 @@ static int cpuset_cpu_inactive(unsigned int cpu)
	return 0;
}

static inline void sched_smt_present_inc(int cpu)
{
#ifdef CONFIG_SCHED_SMT
	if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
		static_branch_inc_cpuslocked(&sched_smt_present);
#endif
}

static inline void sched_smt_present_dec(int cpu)
{
#ifdef CONFIG_SCHED_SMT
	if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
		static_branch_dec_cpuslocked(&sched_smt_present);
#endif
}

int sched_cpu_activate(unsigned int cpu)
{
	struct rq *rq = cpu_rq(cpu);
	struct rq_flags rf;

#ifdef CONFIG_SCHED_SMT
	/*
	 * When going up, increment the number of cores with SMT present.
	 */
	if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
		static_branch_inc_cpuslocked(&sched_smt_present);
#endif
	sched_smt_present_inc(cpu);
	set_cpu_active(cpu, true);
	tg_update_affinity_domains(cpu, 1);

@@ -5886,23 +5899,17 @@ int sched_cpu_deactivate(unsigned int cpu)
	 */
	synchronize_rcu_mult(call_rcu, call_rcu_sched);

#ifdef CONFIG_SCHED_SMT
	/*
	 * When going down, decrement the number of cores with SMT present.
	 */
	if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
		static_branch_dec_cpuslocked(&sched_smt_present);
#endif
	sched_smt_present_dec(cpu);

	if (!sched_smp_initialized)
		return 0;

	ret = cpuset_cpu_inactive(cpu);
	if (ret) {
#ifdef CONFIG_SCHED_SMT
		if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
			static_branch_inc_cpuslocked(&sched_smt_present);
#endif
		sched_smt_present_inc(cpu);
		set_cpu_active(cpu, true);
		return ret;
	}