Skip to content

Commit 3cb3596

Browse files
Yang Yinglianggregkh
authored andcommitted
sched/smt: Introduce sched_smt_present_inc/dec() helper
commit 31b164e upstream. 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 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 388f1c9 commit 3cb3596

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

kernel/sched/core.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9654,6 +9654,22 @@ static int cpuset_cpu_inactive(unsigned int cpu)
96549654
return 0;
96559655
}
96569656

9657+
static inline void sched_smt_present_inc(int cpu)
9658+
{
9659+
#ifdef CONFIG_SCHED_SMT
9660+
if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
9661+
static_branch_inc_cpuslocked(&sched_smt_present);
9662+
#endif
9663+
}
9664+
9665+
static inline void sched_smt_present_dec(int cpu)
9666+
{
9667+
#ifdef CONFIG_SCHED_SMT
9668+
if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
9669+
static_branch_dec_cpuslocked(&sched_smt_present);
9670+
#endif
9671+
}
9672+
96579673
int sched_cpu_activate(unsigned int cpu)
96589674
{
96599675
struct rq *rq = cpu_rq(cpu);
@@ -9665,13 +9681,10 @@ int sched_cpu_activate(unsigned int cpu)
96659681
*/
96669682
balance_push_set(cpu, false);
96679683

9668-
#ifdef CONFIG_SCHED_SMT
96699684
/*
96709685
* When going up, increment the number of cores with SMT present.
96719686
*/
9672-
if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
9673-
static_branch_inc_cpuslocked(&sched_smt_present);
9674-
#endif
9687+
sched_smt_present_inc(cpu);
96759688
set_cpu_active(cpu, true);
96769689

96779690
if (sched_smp_initialized) {
@@ -9740,13 +9753,12 @@ int sched_cpu_deactivate(unsigned int cpu)
97409753
}
97419754
rq_unlock_irqrestore(rq, &rf);
97429755

9743-
#ifdef CONFIG_SCHED_SMT
97449756
/*
97459757
* When going down, decrement the number of cores with SMT present.
97469758
*/
9747-
if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
9748-
static_branch_dec_cpuslocked(&sched_smt_present);
9759+
sched_smt_present_dec(cpu);
97499760

9761+
#ifdef CONFIG_SCHED_SMT
97509762
sched_core_cpu_deactivate(cpu);
97519763
#endif
97529764

0 commit comments

Comments
 (0)