From: Shrikanth Hegde Date: Fri, 15 May 2026 17:24:56 +0000 (+0530) Subject: sched: Unify SMT active check via sched_smt_active() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acbdbab75ff4b1b87ab3c3d2b6ca86948f472189;p=thirdparty%2Fkernel%2Flinux.git sched: Unify SMT active check via sched_smt_active() There is a use of sched_smt_active() and explicit use of sched_smt_present. Remove the explicit usage for better code maintenance and readability. Note that this differs slightly for update_idle_core. It used to call static_branch_unlikely earlier and now it will call static_branch_likely. Signed-off-by: Shrikanth Hegde Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Valentin Schneider Link: https://patch.msgid.link/20260515172456.542799-5-sshegde@linux.ibm.com --- diff --git a/kernel/sched/core_sched.c b/kernel/sched/core_sched.c index 73b6b24269119..43e0bde3038e9 100644 --- a/kernel/sched/core_sched.c +++ b/kernel/sched/core_sched.c @@ -136,7 +136,7 @@ int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type, struct pid *grp; int err = 0; - if (!static_branch_likely(&sched_smt_present)) + if (!sched_smt_active()) return -ENODEV; BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_THREAD != PIDTYPE_PID); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 14bd31b17c716..bcaadddf86240 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2247,7 +2247,7 @@ numa_type numa_classify(unsigned int imbalance_pct, static inline bool test_idle_cores(int cpu); static inline int numa_idle_core(int idle_core, int cpu) { - if (!static_branch_likely(&sched_smt_present) || + if (!sched_smt_active() || idle_core >= 0 || !test_idle_cores(cpu)) return idle_core; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index e476623a0c2af..ffe77b2b6296c 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1671,7 +1671,7 @@ extern void __update_idle_core(struct rq *rq); static inline void update_idle_core(struct rq *rq) { - if (static_branch_unlikely(&sched_smt_present)) + if (sched_smt_active()) __update_idle_core(rq); }