mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00
x86/apic: Provide cpu_primary_thread mask
Make the primary thread tracking CPU mask based in preparation for simpler handling of parallel bootup. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Michael Kelley <mikelley@microsoft.com> Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name> Tested-by: Helge Deller <deller@gmx.de> # parisc Tested-by: Guilherme G. Piccoli <gpiccoli@igalia.com> # Steam Deck Link: https://lore.kernel.org/r/20230512205257.186599880@linutronix.de
This commit is contained in:
parent
8b5a0f957c
commit
f54d4434c2
4 changed files with 27 additions and 26 deletions
|
@ -506,10 +506,8 @@ extern int default_check_phys_apicid_present(int phys_apicid);
|
||||||
#endif /* CONFIG_X86_LOCAL_APIC */
|
#endif /* CONFIG_X86_LOCAL_APIC */
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
bool apic_id_is_primary_thread(unsigned int id);
|
|
||||||
void apic_smt_update(void);
|
void apic_smt_update(void);
|
||||||
#else
|
#else
|
||||||
static inline bool apic_id_is_primary_thread(unsigned int id) { return false; }
|
|
||||||
static inline void apic_smt_update(void) { }
|
static inline void apic_smt_update(void) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
* CONFIG_NUMA.
|
* CONFIG_NUMA.
|
||||||
*/
|
*/
|
||||||
#include <linux/numa.h>
|
#include <linux/numa.h>
|
||||||
|
#include <linux/cpumask.h>
|
||||||
|
|
||||||
#ifdef CONFIG_NUMA
|
#ifdef CONFIG_NUMA
|
||||||
#include <linux/cpumask.h>
|
|
||||||
|
|
||||||
#include <asm/mpspec.h>
|
#include <asm/mpspec.h>
|
||||||
#include <asm/percpu.h>
|
#include <asm/percpu.h>
|
||||||
|
@ -139,9 +139,20 @@ static inline int topology_max_smt_threads(void)
|
||||||
int topology_update_package_map(unsigned int apicid, unsigned int cpu);
|
int topology_update_package_map(unsigned int apicid, unsigned int cpu);
|
||||||
int topology_update_die_map(unsigned int dieid, unsigned int cpu);
|
int topology_update_die_map(unsigned int dieid, unsigned int cpu);
|
||||||
int topology_phys_to_logical_pkg(unsigned int pkg);
|
int topology_phys_to_logical_pkg(unsigned int pkg);
|
||||||
bool topology_is_primary_thread(unsigned int cpu);
|
|
||||||
bool topology_smt_supported(void);
|
bool topology_smt_supported(void);
|
||||||
#else
|
|
||||||
|
extern struct cpumask __cpu_primary_thread_mask;
|
||||||
|
#define cpu_primary_thread_mask ((const struct cpumask *)&__cpu_primary_thread_mask)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* topology_is_primary_thread - Check whether CPU is the primary SMT thread
|
||||||
|
* @cpu: CPU to check
|
||||||
|
*/
|
||||||
|
static inline bool topology_is_primary_thread(unsigned int cpu)
|
||||||
|
{
|
||||||
|
return cpumask_test_cpu(cpu, cpu_primary_thread_mask);
|
||||||
|
}
|
||||||
|
#else /* CONFIG_SMP */
|
||||||
#define topology_max_packages() (1)
|
#define topology_max_packages() (1)
|
||||||
static inline int
|
static inline int
|
||||||
topology_update_package_map(unsigned int apicid, unsigned int cpu) { return 0; }
|
topology_update_package_map(unsigned int apicid, unsigned int cpu) { return 0; }
|
||||||
|
@ -152,7 +163,7 @@ static inline int topology_max_die_per_package(void) { return 1; }
|
||||||
static inline int topology_max_smt_threads(void) { return 1; }
|
static inline int topology_max_smt_threads(void) { return 1; }
|
||||||
static inline bool topology_is_primary_thread(unsigned int cpu) { return true; }
|
static inline bool topology_is_primary_thread(unsigned int cpu) { return true; }
|
||||||
static inline bool topology_smt_supported(void) { return false; }
|
static inline bool topology_smt_supported(void) { return false; }
|
||||||
#endif
|
#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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2386,20 +2386,16 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
/**
|
static void cpu_mark_primary_thread(unsigned int cpu, unsigned int apicid)
|
||||||
* apic_id_is_primary_thread - Check whether APIC ID belongs to a primary thread
|
|
||||||
* @apicid: APIC ID to check
|
|
||||||
*/
|
|
||||||
bool apic_id_is_primary_thread(unsigned int apicid)
|
|
||||||
{
|
{
|
||||||
u32 mask;
|
|
||||||
|
|
||||||
if (smp_num_siblings == 1)
|
|
||||||
return true;
|
|
||||||
/* Isolate the SMT bit(s) in the APICID and check for 0 */
|
/* Isolate the SMT bit(s) in the APICID and check for 0 */
|
||||||
mask = (1U << (fls(smp_num_siblings) - 1)) - 1;
|
u32 mask = (1U << (fls(smp_num_siblings) - 1)) - 1;
|
||||||
return !(apicid & mask);
|
|
||||||
|
if (smp_num_siblings == 1 || !(apicid & mask))
|
||||||
|
cpumask_set_cpu(cpu, &__cpu_primary_thread_mask);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static inline void cpu_mark_primary_thread(unsigned int cpu, unsigned int apicid) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2544,6 +2540,8 @@ int generic_processor_info(int apicid, int version)
|
||||||
set_cpu_present(cpu, true);
|
set_cpu_present(cpu, true);
|
||||||
num_processors++;
|
num_processors++;
|
||||||
|
|
||||||
|
cpu_mark_primary_thread(cpu, apicid);
|
||||||
|
|
||||||
return cpu;
|
return cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,9 @@ EXPORT_PER_CPU_SYMBOL(cpu_die_map);
|
||||||
DEFINE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);
|
DEFINE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);
|
||||||
EXPORT_PER_CPU_SYMBOL(cpu_info);
|
EXPORT_PER_CPU_SYMBOL(cpu_info);
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
@ -276,15 +279,6 @@ static void notrace start_secondary(void *unused)
|
||||||
cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
|
cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* topology_is_primary_thread - Check whether CPU is the primary SMT thread
|
|
||||||
* @cpu: CPU to check
|
|
||||||
*/
|
|
||||||
bool topology_is_primary_thread(unsigned int cpu)
|
|
||||||
{
|
|
||||||
return apic_id_is_primary_thread(per_cpu(x86_cpu_to_apicid, cpu));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* topology_smt_supported - Check whether SMT is supported by the CPUs
|
* topology_smt_supported - Check whether SMT is supported by the CPUs
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue