Skip to content

Commit 31b164e

Browse files
Yang YingliangPeter Zijlstra
authored andcommitted
sched/smt: Introduce sched_smt_present_inc/dec() helper
Introduce sched_smt_present_inc/dec() helper, so it can be called in normal or error path simply. No functional changed. Cc: stable@kernel.org Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20240703031610.587047-2-yangyingliang@huaweicloud.com
1 parent 77baa5b commit 31b164e

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

kernel/sched/core.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7895,6 +7895,22 @@ static int cpuset_cpu_inactive(unsigned int cpu)
78957895
return 0;
78967896
}
78977897

7898+
static inline void sched_smt_present_inc(int cpu)
7899+
{
7900+
#ifdef CONFIG_SCHED_SMT
7901+
if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
7902+
static_branch_inc_cpuslocked(&sched_smt_present);
7903+
#endif
7904+
}
7905+
7906+
static inline void sched_smt_present_dec(int cpu)
7907+
{
7908+
#ifdef CONFIG_SCHED_SMT
7909+
if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
7910+
static_branch_dec_cpuslocked(&sched_smt_present);
7911+
#endif
7912+
}
7913+
78987914
int sched_cpu_activate(unsigned int cpu)
78997915
{
79007916
struct rq *rq = cpu_rq(cpu);
@@ -7906,13 +7922,10 @@ int sched_cpu_activate(unsigned int cpu)
79067922
*/
79077923
balance_push_set(cpu, false);
79087924

7909-
#ifdef CONFIG_SCHED_SMT
79107925
/*
79117926
* When going up, increment the number of cores with SMT present.
79127927
*/
7913-
if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
7914-
static_branch_inc_cpuslocked(&sched_smt_present);
7915-
#endif
7928+
sched_smt_present_inc(cpu);
79167929
set_cpu_active(cpu, true);
79177930

79187931
if (sched_smp_initialized) {
@@ -7981,13 +7994,12 @@ int sched_cpu_deactivate(unsigned int cpu)
79817994
}
79827995
rq_unlock_irqrestore(rq, &rf);
79837996

7984-
#ifdef CONFIG_SCHED_SMT
79857997
/*
79867998
* When going down, decrement the number of cores with SMT present.
79877999
*/
7988-
if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
7989-
static_branch_dec_cpuslocked(&sched_smt_present);
8000+
sched_smt_present_dec(cpu);
79908001

8002+
#ifdef CONFIG_SCHED_SMT
79918003
sched_core_cpu_deactivate(cpu);
79928004
#endif
79938005

0 commit comments

Comments
 (0)