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

!11955 Fix CVE-2024-44958 5.10

Merge Pull Request from: @ci-robot 
 
PR sync from: Zheng Zucheng <zhengzucheng@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/5NS4TTAZXY3QSYUXC2SDXXQVHOXQLT35/ 
Yang Yingliang (2):
  sched/smt: Introduce sched_smt_present_inc/dec() helper
  sched/smt: 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/11955

 

Reviewed-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parents 85be45b4 fca5d816
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -7965,18 +7965,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);

	if (sched_smp_initialized) {
@@ -8017,13 +8030,12 @@ int sched_cpu_deactivate(unsigned int cpu)
	 */
	synchronize_rcu();

#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);
	sched_smt_present_dec(cpu);

#ifdef CONFIG_SCHED_SMT
	sched_core_cpu_deactivate(cpu);
#endif

@@ -8032,6 +8044,7 @@ int sched_cpu_deactivate(unsigned int cpu)

	ret = cpuset_cpu_inactive(cpu);
	if (ret) {
		sched_smt_present_inc(cpu);
		set_cpu_active(cpu, true);
		return ret;
	}