diff options
author | Wei Huang <wei.huang2@amd.com> | 2012-03-07 09:23:41 +0000 |
---|---|---|
committer | Wei Huang <wei.huang2@amd.com> | 2012-03-07 09:23:41 +0000 |
commit | 720a5095c435b215b3ae75726937f6250fe4e44d (patch) | |
tree | f5a832b684cb4468f1f8c553e2b85b17818d43c6 | |
parent | 21fb307747b358e43fe9a97a83f06e96552435d8 (diff) | |
download | xen-720a5095c435b215b3ae75726937f6250fe4e44d.tar.gz xen-720a5095c435b215b3ae75726937f6250fe4e44d.tar.bz2 xen-720a5095c435b215b3ae75726937f6250fe4e44d.zip |
x86: consolidate cpu_core_id and phys_proc_id into cpuinfo_x86 struct
This patch moves cpu_core_id and phys_proc_id into cpuinfo_x86
structure. This is similar to upstream Linux kernel's approach.
Signed-off-by: Wei Huang <wei.huang2@amd.com>
xen-unstable changeset: 23610:87c2013c2aa2
xen-unstable date: Tue Jun 28 09:13:31 2011 +0100
-rw-r--r-- | xen/arch/x86/cpu/amd.c | 6 | ||||
-rw-r--r-- | xen/arch/x86/cpu/common.c | 22 | ||||
-rw-r--r-- | xen/arch/x86/cpu/mcheck/mce.c | 4 | ||||
-rw-r--r-- | xen/arch/x86/smpboot.c | 16 | ||||
-rw-r--r-- | xen/include/asm-x86/processor.h | 8 |
5 files changed, 25 insertions, 31 deletions
diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c index 6556ec04c9..86e17a3247 100644 --- a/xen/arch/x86/cpu/amd.c +++ b/xen/arch/x86/cpu/amd.c @@ -579,11 +579,11 @@ static void __devinit init_amd(struct cpuinfo_x86 *c) while ((1 << bits) < c->x86_max_cores) bits++; } - cpu_core_id[cpu] = phys_proc_id[cpu] & ((1<<bits)-1); - phys_proc_id[cpu] >>= bits; + c->cpu_core_id = c->phys_proc_id & ((1<<bits)-1); + c->phys_proc_id >>= bits; if (opt_cpu_info) printk("CPU %d(%d) -> Core %d\n", - cpu, c->x86_max_cores, cpu_core_id[cpu]); + cpu, c->x86_max_cores, c->cpu_core_id); } #endif diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index 6564bf555a..39445e0a19 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -326,7 +326,7 @@ void __cpuinit generic_identify(struct cpuinfo_x86 * c) early_intel_workaround(c); #ifdef CONFIG_X86_HT - phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff; + c->phys_proc_id = (cpuid_ebx(1) >> 24) & 0xff; #endif } @@ -362,6 +362,8 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c) c->x86_max_cores = 1; c->x86_num_siblings = 1; c->x86_clflush_size = 0; + c->phys_proc_id = BAD_APICID; + c->cpu_core_id = BAD_APICID; memset(&c->x86_capability, 0, sizeof c->x86_capability); if (!have_cpuid_p()) { @@ -510,7 +512,6 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c) unsigned int ht_mask_width, core_plus_mask_width; unsigned int core_select_mask, core_level_siblings; unsigned int initial_apicid; - int cpu = smp_processor_id(); if ( c->cpuid_level < 0xb ) return; @@ -545,9 +546,9 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c) core_select_mask = (~(-1 << core_plus_mask_width)) >> ht_mask_width; - cpu_core_id[cpu] = phys_pkg_id(initial_apicid, ht_mask_width) + c->cpu_core_id = phys_pkg_id(initial_apicid, ht_mask_width) & core_select_mask; - phys_proc_id[cpu] = phys_pkg_id(initial_apicid, core_plus_mask_width); + c->phys_proc_id = phys_pkg_id(initial_apicid, core_plus_mask_width); c->apicid = phys_pkg_id(initial_apicid, 0); c->x86_max_cores = (core_level_siblings / c->x86_num_siblings); @@ -555,10 +556,10 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c) if ( opt_cpu_info ) { printk("CPU: Physical Processor ID: %d\n", - phys_proc_id[cpu]); + c->phys_proc_id); if ( c->x86_max_cores > 1 ) printk("CPU: Processor Core ID: %d\n", - cpu_core_id[cpu]); + c->cpu_core_id); } } @@ -567,7 +568,6 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c) { u32 eax, ebx, ecx, edx; int index_msb, core_bits; - int cpu = smp_processor_id(); cpuid(1, &eax, &ebx, &ecx, &edx); @@ -590,11 +590,11 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c) } index_msb = get_count_order(c->x86_num_siblings); - phys_proc_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb); + c->phys_proc_id = phys_pkg_id((ebx >> 24) & 0xFF, index_msb); if (opt_cpu_info) printk("CPU: Physical Processor ID: %d\n", - phys_proc_id[cpu]); + c->phys_proc_id); c->x86_num_siblings = c->x86_num_siblings / c->x86_max_cores; @@ -602,12 +602,12 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c) core_bits = get_count_order(c->x86_max_cores); - cpu_core_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb) & + c->cpu_core_id = phys_pkg_id((ebx >> 24) & 0xFF, index_msb) & ((1 << core_bits) - 1); if (opt_cpu_info && c->x86_max_cores > 1) printk("CPU: Processor Core ID: %d\n", - cpu_core_id[cpu]); + c->cpu_core_id); } } #endif diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c index 6080a7e321..73b83164cc 100644 --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -1041,9 +1041,9 @@ void x86_mc_get_cpu_info(unsigned cpu, uint32_t *chipid, uint16_t *coreid, if (nthreads != NULL) *nthreads = 1; } else { - *chipid = phys_proc_id[cpu]; + *chipid = c->phys_proc_id; if (c->x86_max_cores > 1) - *coreid = cpu_core_id[cpu]; + *coreid = c->cpu_core_id; else *coreid = 0; *threadid = c->apicid & ((1 << (c->x86_num_siblings - 1)) - 1); diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index fafcea8545..5e1cefad03 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -52,12 +52,6 @@ /* Set if we find a B stepping CPU */ static int smp_b_stepping; -/* Package ID of each logical CPU */ -int phys_proc_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID}; - -/* Core ID of each logical CPU */ -int cpu_core_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID}; - /* representing HT siblings of each logical CPU */ DEFINE_PER_CPU_READ_MOSTLY(cpumask_t, cpu_sibling_map); /* representing HT and core siblings of each logical CPU */ @@ -258,8 +252,8 @@ static void set_cpu_sibling_map(int cpu) { for_each_cpu_mask ( i, cpu_sibling_setup_map ) { - if ( (phys_proc_id[cpu] == phys_proc_id[i]) && - (cpu_core_id[cpu] == cpu_core_id[i]) ) + if ( (c[cpu].phys_proc_id == c[i].phys_proc_id) && + (c[cpu].cpu_core_id == c[i].cpu_core_id) ) { cpu_set(i, per_cpu(cpu_sibling_map, cpu)); cpu_set(cpu, per_cpu(cpu_sibling_map, i)); @@ -282,7 +276,7 @@ static void set_cpu_sibling_map(int cpu) for_each_cpu_mask ( i, cpu_sibling_setup_map ) { - if ( phys_proc_id[cpu] == phys_proc_id[i] ) + if ( c[cpu].phys_proc_id == c[i].phys_proc_id ) { cpu_set(i, per_cpu(cpu_core_map, cpu)); cpu_set(cpu, per_cpu(cpu_core_map, i)); @@ -858,8 +852,8 @@ remove_siblinginfo(int cpu) cpu_clear(cpu, per_cpu(cpu_sibling_map, sibling)); cpus_clear(per_cpu(cpu_sibling_map, cpu)); cpus_clear(per_cpu(cpu_core_map, cpu)); - phys_proc_id[cpu] = BAD_APICID; - cpu_core_id[cpu] = BAD_APICID; + c[cpu].phys_proc_id = BAD_APICID; + c[cpu].cpu_core_id = BAD_APICID; cpu_clear(cpu, cpu_sibling_setup_map); } diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h index bd800b7edc..d485c6ffe1 100644 --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -175,6 +175,8 @@ struct cpuinfo_x86 { __u32 x86_max_cores; /* cpuid returned max cores value */ __u32 booted_cores; /* number of cores as seen by OS */ __u32 x86_num_siblings; /* cpuid logical cpus per chip value */ + int phys_proc_id; /* package ID of each logical CPU */ + int cpu_core_id; /* core ID of each logical CPU*/ __u32 apicid; unsigned short x86_clflush_size; } __cacheline_aligned; @@ -196,8 +198,6 @@ extern struct cpuinfo_x86 cpu_data[]; extern void set_cpuid_faulting(bool_t enable); extern u64 host_pat; -extern int phys_proc_id[NR_CPUS]; -extern int cpu_core_id[NR_CPUS]; extern bool_t opt_cpu_info; /* Maximum width of physical addresses supported by the hardware */ @@ -217,8 +217,8 @@ extern void detect_ht(struct cpuinfo_x86 *c); static always_inline void detect_ht(struct cpuinfo_x86 *c) {} #endif -#define cpu_to_core(_cpu) (cpu_core_id[_cpu]) -#define cpu_to_socket(_cpu) (phys_proc_id[_cpu]) +#define cpu_to_core(_cpu) (cpu_data[_cpu].cpu_core_id) +#define cpu_to_socket(_cpu) (cpu_data[_cpu].phys_proc_id) /* * Generic CPUID function |