x86: introduce initial apicid

store initial_apicid from early identify. it is could be different from
phys_proc_id later.

also print it out in /proc/cpuinfo.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Yinghai Lu 2008-03-06 13:46:39 -08:00 committed by Ingo Molnar
parent 459cce7267
commit 01aaea1afb
4 changed files with 16 additions and 12 deletions

View File

@ -369,10 +369,12 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
if (c->x86 >= 0x6) if (c->x86 >= 0x6)
c->x86_model += ((tfms >> 16) & 0xF) << 4; c->x86_model += ((tfms >> 16) & 0xF) << 4;
c->x86_mask = tfms & 15; c->x86_mask = tfms & 15;
c->initial_apicid = (ebx >> 24) & 0xFF;
#ifdef CONFIG_X86_HT #ifdef CONFIG_X86_HT
c->apicid = phys_pkg_id((ebx >> 24) & 0xFF, 0); c->apicid = phys_pkg_id(c->initial_apicid, 0);
c->phys_proc_id = c->initial_apicid;
#else #else
c->apicid = (ebx >> 24) & 0xFF; c->apicid = c->initial_apicid;
#endif #endif
if (test_cpu_cap(c, X86_FEATURE_CLFLSH)) if (test_cpu_cap(c, X86_FEATURE_CLFLSH))
c->x86_clflush_size = ((ebx >> 8) & 0xff) * 8; c->x86_clflush_size = ((ebx >> 8) & 0xff) * 8;
@ -395,9 +397,6 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
init_scattered_cpuid_features(c); init_scattered_cpuid_features(c);
} }
#ifdef CONFIG_X86_HT
c->phys_proc_id = (cpuid_ebx(1) >> 24) & 0xff;
#endif
} }
static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c) static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
@ -554,7 +553,7 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
} }
index_msb = get_count_order(smp_num_siblings); index_msb = get_count_order(smp_num_siblings);
c->phys_proc_id = phys_pkg_id((ebx >> 24) & 0xFF, index_msb); c->phys_proc_id = phys_pkg_id(c->initial_apicid, index_msb);
printk(KERN_INFO "CPU: Physical Processor ID: %d\n", printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
c->phys_proc_id); c->phys_proc_id);
@ -565,7 +564,7 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
core_bits = get_count_order(c->x86_max_cores); core_bits = get_count_order(c->x86_max_cores);
c->cpu_core_id = phys_pkg_id((ebx >> 24) & 0xFF, index_msb) & c->cpu_core_id = phys_pkg_id(c->initial_apicid, index_msb) &
((1 << core_bits) - 1); ((1 << core_bits) - 1);
if (c->x86_max_cores > 1) if (c->x86_max_cores > 1)

View File

@ -19,6 +19,8 @@ static void show_cpuinfo_core(struct seq_file *m, struct cpuinfo_x86 *c,
cpus_weight(per_cpu(cpu_core_map, cpu))); cpus_weight(per_cpu(cpu_core_map, cpu)));
seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id); seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
seq_printf(m, "cpu cores\t: %d\n", c->booted_cores); seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
seq_printf(m, "apicid\t\t: %d\n", c->apicid);
seq_printf(m, "initial apicid\t: %d\n", c->initial_apicid);
} }
#endif #endif
} }
@ -60,6 +62,7 @@ static void show_cpuinfo_core(struct seq_file *m, struct cpuinfo_x86 *c,
seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id); seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
seq_printf(m, "cpu cores\t: %d\n", c->booted_cores); seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
seq_printf(m, "apicid\t\t: %d\n", c->apicid); seq_printf(m, "apicid\t\t: %d\n", c->apicid);
seq_printf(m, "initial apicid\t: %d\n", c->initial_apicid);
} }
#endif #endif
} }

View File

@ -562,9 +562,9 @@ static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c)
bits = c->x86_coreid_bits; bits = c->x86_coreid_bits;
/* Low order bits define the core id (index of core in socket) */ /* Low order bits define the core id (index of core in socket) */
c->cpu_core_id = c->phys_proc_id & ((1 << bits)-1); c->cpu_core_id = c->initial_apicid & ((1 << bits)-1);
/* Convert the APIC ID into the socket ID */ /* Convert the initial APIC ID into the socket ID */
c->phys_proc_id = (c->apicid - boot_cpu_id) >> bits; c->phys_proc_id = c->initial_apicid >> bits;
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
node = c->phys_proc_id; node = c->phys_proc_id;
@ -581,7 +581,7 @@ static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c)
If that doesn't result in a usable node fall back to the If that doesn't result in a usable node fall back to the
path for the previous case. */ path for the previous case. */
int ht_nodeid = apicid - boot_cpu_id; int ht_nodeid = c->initial_apicid;
if (ht_nodeid >= 0 && if (ht_nodeid >= 0 &&
apicid_to_node[ht_nodeid] != NUMA_NO_NODE) apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
@ -936,8 +936,9 @@ static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
c->x86 = 4; c->x86 = 4;
} }
c->initial_apicid = (cpuid_ebx(1) >> 24) & 0xff;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
c->phys_proc_id = (cpuid_ebx(1) >> 24) & 0xff; c->phys_proc_id = c->initial_apicid;
#endif #endif
/* AMD-defined flags: level 0x80000001 */ /* AMD-defined flags: level 0x80000001 */
xlvl = cpuid_eax(0x80000000); xlvl = cpuid_eax(0x80000000);

View File

@ -101,6 +101,7 @@ struct cpuinfo_x86 {
/* cpuid returned max cores value: */ /* cpuid returned max cores value: */
u16 x86_max_cores; u16 x86_max_cores;
u16 apicid; u16 apicid;
u16 initial_apicid;
u16 x86_clflush_size; u16 x86_clflush_size;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
/* number of cores as seen by the OS: */ /* number of cores as seen by the OS: */