[patch 49/53] x86: Use topology functions instead of smp_num_siblings where applicable

Thomas Gleixner
2023-08-07T13:56:48Z

Accessors exist for a reason.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/include/asm/perf_event_p4.h | 11 ++---------
arch/x86/kernel/process.c | 2 +-
arch/x86/kernel/smpboot.c | 2 +-
3 files changed, 4 insertions(+), 11 deletions(-)

--- a/arch/x86/include/asm/perf_event_p4.h
+++ b/arch/x86/include/asm/perf_event_p4.h
@@ -180,19 +180,12 @@ static inline u64 p4_clear_ht_bit(u64 co

static inline int p4_ht_active(void)
{
-#ifdef CONFIG_SMP
- return smp_num_siblings > 1;
-#endif
- return 0;
+ return topology_smt_supported();
}

static inline int p4_ht_thread(int cpu)
{
-#ifdef CONFIG_SMP
- if (smp_num_siblings == 2)
- return cpu != cpumask_first(this_cpu_cpumask_var_ptr(cpu_sibling_map));
-#endif
- return 0;
+ return !topology_is_primary_thread(cpu);
}

static inline int p4_should_swap_ts(u64 config, int cpu)
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -924,7 +924,7 @@ static __cpuidle void mwait_idle(void)
void select_idle_routine(const struct cpuinfo_x86 *c)
{
#ifdef CONFIG_SMP
- if (boot_option_idle_override == IDLE_POLL && smp_num_siblings > 1)
+ if (boot_option_idle_override == IDLE_POLL && topology_smt_supported())
pr_warn_once("WARNING: polling idle and HT enabled, performance may degrade\n");
#endif
if (x86_idle_set() || boot_option_idle_override == IDLE_POLL)
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -573,7 +573,7 @@ static void __init build_sched_topology(

void set_cpu_sibling_map(int cpu)
{
- bool has_smt = smp_num_siblings > 1;
+ bool has_smt = topology_smt_supported();
bool has_mp = has_smt || boot_cpu_data.x86_max_cores > 1;
struct cpuinfo_x86 *c = &cpu_data(cpu);
struct cpuinfo_x86 *o;