From: Rohit Seth Move the phys_core_id and cpu_core_id to cpuinfo_x86 structure. Similar patch for x86_64 is already accepted by Andi earlier this week. Signed-off-by: Rohit Seth Cc: Andi Kleen Signed-off-by: Andrew Morton --- arch/i386/kernel/cpu/amd.c | 6 +++--- arch/i386/kernel/cpu/common.c | 10 +++++----- arch/i386/kernel/cpu/proc.c | 4 ++-- arch/i386/kernel/smpboot.c | 16 +++++----------- include/asm-i386/processor.h | 8 +++++--- include/asm-i386/topology.h | 6 ++---- 6 files changed, 22 insertions(+), 28 deletions(-) diff -puN arch/i386/kernel/cpu/amd.c~i386-moving-phys_proc_id-and-cpu_core_id-to-cpuinfo_x86 arch/i386/kernel/cpu/amd.c --- devel/arch/i386/kernel/cpu/amd.c~i386-moving-phys_proc_id-and-cpu_core_id-to-cpuinfo_x86 2006-05-29 13:15:59.000000000 -0700 +++ devel-akpm/arch/i386/kernel/cpu/amd.c 2006-05-29 13:16:48.000000000 -0700 @@ -235,10 +235,10 @@ static void __init init_amd(struct cpuin while ((1 << bits) < c->x86_max_cores) bits++; } - cpu_core_id[cpu] = phys_proc_id[cpu] & ((1<>= bits; + c->cpu_core_id = c->phys_proc_id & ((1<phys_proc_id >>= bits; printk(KERN_INFO "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 -puN arch/i386/kernel/cpu/common.c~i386-moving-phys_proc_id-and-cpu_core_id-to-cpuinfo_x86 arch/i386/kernel/cpu/common.c --- devel/arch/i386/kernel/cpu/common.c~i386-moving-phys_proc_id-and-cpu_core_id-to-cpuinfo_x86 2006-05-29 13:15:59.000000000 -0700 +++ devel-akpm/arch/i386/kernel/cpu/common.c 2006-05-29 13:15:59.000000000 -0700 @@ -319,7 +319,7 @@ void __cpuinit generic_identify(struct 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 } @@ -498,10 +498,10 @@ void __cpuinit detect_ht(struct cpuinfo_ } index_msb = get_count_order(smp_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); printk(KERN_INFO "CPU: Physical Processor ID: %d\n", - phys_proc_id[cpu]); + c->phys_proc_id); smp_num_siblings = smp_num_siblings / c->x86_max_cores; @@ -509,12 +509,12 @@ void __cpuinit detect_ht(struct cpuinfo_ 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 (c->x86_max_cores > 1) printk(KERN_INFO "CPU: Processor Core ID: %d\n", - cpu_core_id[cpu]); + c->cpu_core_id); } } #endif diff -puN arch/i386/kernel/cpu/proc.c~i386-moving-phys_proc_id-and-cpu_core_id-to-cpuinfo_x86 arch/i386/kernel/cpu/proc.c --- devel/arch/i386/kernel/cpu/proc.c~i386-moving-phys_proc_id-and-cpu_core_id-to-cpuinfo_x86 2006-05-29 13:15:59.000000000 -0700 +++ devel-akpm/arch/i386/kernel/cpu/proc.c 2006-05-29 13:15:59.000000000 -0700 @@ -109,9 +109,9 @@ static int show_cpuinfo(struct seq_file seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); #ifdef CONFIG_X86_HT if (c->x86_max_cores * smp_num_siblings > 1) { - seq_printf(m, "physical id\t: %d\n", phys_proc_id[n]); + seq_printf(m, "physical id\t: %d\n", c->phys_proc_id); seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[n])); - seq_printf(m, "core id\t\t: %d\n", cpu_core_id[n]); + seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id); seq_printf(m, "cpu cores\t: %d\n", c->booted_cores); } #endif diff -puN arch/i386/kernel/smpboot.c~i386-moving-phys_proc_id-and-cpu_core_id-to-cpuinfo_x86 arch/i386/kernel/smpboot.c --- devel/arch/i386/kernel/smpboot.c~i386-moving-phys_proc_id-and-cpu_core_id-to-cpuinfo_x86 2006-05-29 13:15:59.000000000 -0700 +++ devel-akpm/arch/i386/kernel/smpboot.c 2006-05-29 13:15:59.000000000 -0700 @@ -67,12 +67,6 @@ int smp_num_siblings = 1; EXPORT_SYMBOL(smp_num_siblings); #endif -/* 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}; - /* Last level cache ID of each logical CPU */ int cpu_llc_id[NR_CPUS] __cpuinitdata = {[0 ... NR_CPUS-1] = BAD_APICID}; @@ -471,8 +465,8 @@ set_cpu_sibling_map(int cpu) if (smp_num_siblings > 1) { 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, cpu_sibling_map[cpu]); cpu_set(cpu, cpu_sibling_map[i]); cpu_set(i, cpu_core_map[cpu]); @@ -499,7 +493,7 @@ set_cpu_sibling_map(int cpu) cpu_set(i, c[cpu].llc_shared_map); cpu_set(cpu, c[i].llc_shared_map); } - if (phys_proc_id[cpu] == phys_proc_id[i]) { + if (c[cpu].phys_proc_id == c[i].phys_proc_id) { cpu_set(i, cpu_core_map[cpu]); cpu_set(cpu, cpu_core_map[i]); /* @@ -1351,8 +1345,8 @@ remove_siblinginfo(int cpu) cpu_clear(cpu, cpu_sibling_map[sibling]); cpus_clear(cpu_sibling_map[cpu]); cpus_clear(cpu_core_map[cpu]); - phys_proc_id[cpu] = BAD_APICID; - cpu_core_id[cpu] = BAD_APICID; + c[cpu].phys_proc_id = 0; + c[cpu].cpu_core_id = 0; cpu_clear(cpu, cpu_sibling_setup_map); } diff -puN include/asm-i386/processor.h~i386-moving-phys_proc_id-and-cpu_core_id-to-cpuinfo_x86 include/asm-i386/processor.h --- devel/include/asm-i386/processor.h~i386-moving-phys_proc_id-and-cpu_core_id-to-cpuinfo_x86 2006-05-29 13:15:59.000000000 -0700 +++ devel-akpm/include/asm-i386/processor.h 2006-05-29 13:15:59.000000000 -0700 @@ -71,8 +71,12 @@ struct cpuinfo_x86 { cpumask_t llc_shared_map; /* cpus sharing the last level cache */ #endif unsigned char x86_max_cores; /* cpuid returned max cores value */ - unsigned char booted_cores; /* number of cores as seen by OS */ unsigned char apicid; +#ifdef CONFIG_SMP + unsigned char booted_cores; /* number of cores as seen by OS */ + __u8 phys_proc_id; /* Physical processor id. */ + __u8 cpu_core_id; /* Core id */ +#endif } __attribute__((__aligned__(SMP_CACHE_BYTES))); #define X86_VENDOR_INTEL 0 @@ -104,8 +108,6 @@ extern struct cpuinfo_x86 cpu_data[]; #define current_cpu_data boot_cpu_data #endif -extern int phys_proc_id[NR_CPUS]; -extern int cpu_core_id[NR_CPUS]; extern int cpu_llc_id[NR_CPUS]; extern char ignore_fpu_irq; diff -puN include/asm-i386/topology.h~i386-moving-phys_proc_id-and-cpu_core_id-to-cpuinfo_x86 include/asm-i386/topology.h --- devel/include/asm-i386/topology.h~i386-moving-phys_proc_id-and-cpu_core_id-to-cpuinfo_x86 2006-05-29 13:15:59.000000000 -0700 +++ devel-akpm/include/asm-i386/topology.h 2006-05-29 13:15:59.000000000 -0700 @@ -28,10 +28,8 @@ #define _ASM_I386_TOPOLOGY_H #ifdef CONFIG_X86_HT -#define topology_physical_package_id(cpu) \ - (phys_proc_id[cpu] == BAD_APICID ? -1 : phys_proc_id[cpu]) -#define topology_core_id(cpu) \ - (cpu_core_id[cpu] == BAD_APICID ? 0 : cpu_core_id[cpu]) +#define topology_physical_package_id(cpu) (cpu_data[cpu].phys_proc_id) +#define topology_core_id(cpu) (cpu_data[cpu].cpu_core_id) #define topology_core_siblings(cpu) (cpu_core_map[cpu]) #define topology_thread_siblings(cpu) (cpu_sibling_map[cpu]) #endif _