mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
x86/cpu/topology: Make primary thread mask available with SMP=n
cpu_primary_thread_mask is only defined when CONFIG_SMP=y. However, even
in UP kernels there is always exactly one CPU, which can reasonably be
treated as the primary thread.
Historically, topology_is_primary_thread() always returned true with
CONFIG_SMP=n. A recent commit:
4b455f5994 ("cpu/SMT: Provide a default topology_is_primary_thread()")
replaced it with a generic implementation with the note:
"When disabling SMT, the primary thread of the SMT will remain
enabled/active. Architectures that have a special primary thread (e.g.
x86) need to override this function. ..."
For consistency and clarity, make the primary thread mask available
regardless of SMP, similar to cpu_possible_mask and cpu_present_mask.
Move __cpu_primary_thread_mask into common code to prevent build issues.
Let cpu_mark_primary_thread() configure the mask even for UP kernels,
alongside other masks. Then, topology_is_primary_thread() can
consistently reference it.
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Link: https://lore.kernel.org/r/20250320234104.8288-1-chang.seok.bae@intel.com
This commit is contained in:
committed by
Borislav Petkov (AMD)
parent
3a86608788
commit
ed44a5625f
@@ -218,6 +218,12 @@ static inline unsigned int topology_amd_nodes_per_pkg(void)
|
|||||||
return __amd_nodes_per_pkg;
|
return __amd_nodes_per_pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else /* CONFIG_SMP */
|
||||||
|
static inline int topology_phys_to_logical_pkg(unsigned int pkg) { return 0; }
|
||||||
|
static inline int topology_max_smt_threads(void) { return 1; }
|
||||||
|
static inline unsigned int topology_amd_nodes_per_pkg(void) { return 1; }
|
||||||
|
#endif /* !CONFIG_SMP */
|
||||||
|
|
||||||
extern struct cpumask __cpu_primary_thread_mask;
|
extern struct cpumask __cpu_primary_thread_mask;
|
||||||
#define cpu_primary_thread_mask ((const struct cpumask *)&__cpu_primary_thread_mask)
|
#define cpu_primary_thread_mask ((const struct cpumask *)&__cpu_primary_thread_mask)
|
||||||
|
|
||||||
@@ -241,12 +247,6 @@ static inline bool topology_is_core_online(unsigned int cpu)
|
|||||||
}
|
}
|
||||||
#define topology_is_core_online topology_is_core_online
|
#define topology_is_core_online topology_is_core_online
|
||||||
|
|
||||||
#else /* CONFIG_SMP */
|
|
||||||
static inline int topology_phys_to_logical_pkg(unsigned int pkg) { return 0; }
|
|
||||||
static inline int topology_max_smt_threads(void) { return 1; }
|
|
||||||
static inline unsigned int topology_amd_nodes_per_pkg(void) { return 1; }
|
|
||||||
#endif /* !CONFIG_SMP */
|
|
||||||
|
|
||||||
static inline void arch_fix_phys_package_id(int num, u32 slot)
|
static inline void arch_fix_phys_package_id(int num, u32 slot)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,15 +75,11 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
|
|||||||
return phys_id == (u64)cpuid_to_apicid[cpu];
|
return phys_id == (u64)cpuid_to_apicid[cpu];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
static void cpu_mark_primary_thread(unsigned int cpu, unsigned int apicid)
|
static void cpu_mark_primary_thread(unsigned int cpu, unsigned int apicid)
|
||||||
{
|
{
|
||||||
if (!(apicid & (__max_threads_per_core - 1)))
|
if (!(apicid & (__max_threads_per_core - 1)))
|
||||||
cpumask_set_cpu(cpu, &__cpu_primary_thread_mask);
|
cpumask_set_cpu(cpu, &__cpu_primary_thread_mask);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static inline void cpu_mark_primary_thread(unsigned int cpu, unsigned int apicid) { }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert the APIC ID to a domain level ID by masking out the low bits
|
* Convert the APIC ID to a domain level ID by masking out the low bits
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ EXPORT_SYMBOL_GPL(x86_topo_system);
|
|||||||
unsigned int __amd_nodes_per_pkg __ro_after_init;
|
unsigned int __amd_nodes_per_pkg __ro_after_init;
|
||||||
EXPORT_SYMBOL_GPL(__amd_nodes_per_pkg);
|
EXPORT_SYMBOL_GPL(__amd_nodes_per_pkg);
|
||||||
|
|
||||||
|
/* CPUs which are the primary SMT threads */
|
||||||
|
struct cpumask __cpu_primary_thread_mask __read_mostly;
|
||||||
|
|
||||||
void topology_set_dom(struct topo_scan *tscan, enum x86_topology_domains dom,
|
void topology_set_dom(struct topo_scan *tscan, enum x86_topology_domains dom,
|
||||||
unsigned int shift, unsigned int ncpus)
|
unsigned int shift, unsigned int ncpus)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -103,9 +103,6 @@ EXPORT_PER_CPU_SYMBOL(cpu_core_map);
|
|||||||
DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_die_map);
|
DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_die_map);
|
||||||
EXPORT_PER_CPU_SYMBOL(cpu_die_map);
|
EXPORT_PER_CPU_SYMBOL(cpu_die_map);
|
||||||
|
|
||||||
/* CPUs which are the primary SMT threads */
|
|
||||||
struct cpumask __cpu_primary_thread_mask __read_mostly;
|
|
||||||
|
|
||||||
/* Representing CPUs for which sibling maps can be computed */
|
/* Representing CPUs for which sibling maps can be computed */
|
||||||
static cpumask_var_t cpu_sibling_setup_mask;
|
static cpumask_var_t cpu_sibling_setup_mask;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user