x86: identifying the boot cpu
PATCH 1/3 x86: identifying the boot cpu
Provide helpers to access the socket and core IDs, resulting from identification phase. Initialize socket and core ID to -1 i.e invalid instead of 0.
--- xen/arch/x86/setup.c | 7 +++++-- xen/arch/x86/smpboot.c | 3 ++- xen/include/asm-x86/processor.h | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-)
xen/arch/x86/setup.c +5 -2
@@ -1259,6 +1259,11 @@ void __init noreturn __start_xen(unsigned long mbi_p)microcode_grab_module (module_map, mbi, bootstrap_map);timer_init (); +/* +* Identify the boot CPU, in case the scheduler initialization +* needs to know about it (e.g., topology, etc.) +*/ +identify_cpu (&boot_cpu_data);init_idle_domain ();
@@ -1270,8 +1275,6 @@ void __init noreturn __start_xen(unsigned long mbi_p)arch_init_memory (); -identify_cpu (&boot_cpu_data); -if ( cpu_has_fxsr )set_in_cr4 (X86_CR4_OSFXSR );if ( cpu_has_xmm )
xen/arch/x86/smpboot.c +2 -1
@@ -59,7 +59,8 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask);cpumask_t cpu_online_map__read_mostly ;EXPORT_SYMBOL (cpu_online_map); -struct cpuinfo_x86 cpu_data[NR_CPUS ]; +struct cpuinfo_x86 cpu_data[NR_CPUS ] = + { [0 ...NR_CPUS -1 ] = { .phys_proc_id=-1 , .cpu_core_id=-1 } };u32 x86_cpu_to_apicid[NR_CPUS ]__read_mostly = { [0 ...NR_CPUS -1 ] =BAD_APICID };
xen/include/asm-x86/processor.h +2 -0
@@ -214,7 +214,9 @@ extern void detect_extended_topology(struct cpuinfo_x86 *c);extern void detect_ht (struct cpuinfo_x86 *c); +#define boot_cpu_to_core () (boot_cpu_data.cpu_core_id)#define cpu_to_core (_cpu) (cpu_data[_cpu].cpu_core_id) +#define boot_cpu_to_socket () (boot_cpu_data.phys_proc_id)#define cpu_to_socket (_cpu) (cpu_data[_cpu].phys_proc_id)unsigned int apicid_to_socket (unsigned int );
Signature · 1 line
1.9.1
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 12.03.15 at 15:55, <[email protected]> wrote:
Provide helpers to access the socket and core IDs, resulting from identification phase.
Initialize socket and core ID to -1 i.e invalid instead of 0.
You still don't say _why_ both of these are needed.
xen/arch/x86/smpboot.c DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask); · line 63
Quoted 9 lines
xen/arch/x86/smpboot.c +2
-1@@ -59,7 +59,8 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask);cpumask_t cpu_online_map__read_mostly ;EXPORT_SYMBOL (cpu_online_map); -struct cpuinfo_x86 cpu_data[NR_CPUS ]; +struct cpuinfo_x86 cpu_data[NR_CPUS ] = + { [0 ...NR_CPUS -1 ] = { .phys_proc_id=-1 , .cpu_core_id=-1 } };
And if this initialization is relevant, then upon offlining CPUs you should put the -1s back.
Also - spaces around = please.
Jan
Quoted 40 lines · Uma Sharma
Provide helpers to access the socket and core IDs, resulting from identification phase. Initialize socket and core ID to -1 i.e invalid instead of 0.
Signed-off-by Uma Sharma <[email protected]>--- xen/arch/x86/setup.c | 7 +++++-- xen/arch/x86/smpboot.c | 3 ++- xen/include/asm-x86/processor.h | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-)xen/arch/x86/setup.c +5
-2@@ -1259,6 +1259,11 @@ void __init noreturn __start_xen(unsigned long mbi_p)microcode_grab_module (module_map, mbi, bootstrap_map);timer_init (); +/* +* Identify the boot CPU, in case the scheduler initialization +* needs to know about it (e.g., topology, etc.) +*/ +identify_cpu (&boot_cpu_data);init_idle_domain ();@@ -1270,8 +1275,6 @@ void __init noreturn __start_xen(unsigned long mbi_p)arch_init_memory (); -identify_cpu (&boot_cpu_data); -if ( cpu_has_fxsr )set_in_cr4 (X86_CR4_OSFXSR );if ( cpu_has_xmm )xen/arch/x86/smpboot.c +0
-0
xen/arch/x86/smpboot.c DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask); · line 63
Quoted 6 lines
xen/arch/x86/smpboot.c +2
-1@@ -59,7 +59,8 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask);cpumask_t cpu_online_map__read_mostly ;EXPORT_SYMBOL (cpu_online_map); -struct cpuinfo_x86 cpu_data[NR_CPUS ]; +struct cpuinfo_x86 cpu_data[NR_CPUS ] = + { [0 ...NR_CPUS -1 ] = { .phys_proc_id=-1 , .cpu_core_id=-1 } };
I think these need to be initialized to BAD_APICID since that's what these fields are typically set to when no information is available.
(Or perhaps new macros should be defined and code that used to set these fields to BAD_APICID updated accordingly)
-boris
Quoted 17 lines
xen/arch/x86/smpboot.c +0
-0u32 x86_cpu_to_apicid[NR_CPUS ]__read_mostly = { [0 ...NR_CPUS -1 ] =BAD_APICID };xen/include/asm-x86/processor.h +2
-0@@ -214,7 +214,9 @@ extern void detect_extended_topology(struct cpuinfo_x86 *c);extern void detect_ht (struct cpuinfo_x86 *c); +#define boot_cpu_to_core () (boot_cpu_data.cpu_core_id)#define cpu_to_core (_cpu) (cpu_data[_cpu].cpu_core_id) +#define boot_cpu_to_socket () (boot_cpu_data.phys_proc_id)#define cpu_to_socket (_cpu) (cpu_data[_cpu].phys_proc_id)unsigned int apicid_to_socket (unsigned int );