* [PATCH] x86: introduce initial apicid
@ 2008-03-06 21:46 Yinghai Lu
2008-03-07 8:47 ` Ingo Molnar
2008-03-07 11:02 ` Andi Kleen
0 siblings, 2 replies; 3+ messages in thread
From: Yinghai Lu @ 2008-03-06 21:46 UTC (permalink / raw)
To: Ingo Molnar, Andrew Morton, Thomas Gleixner, H. Peter Anvin, Andi Kleen
Cc: kernel list
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: x86_initial_apicid_x.patch --]
[-- Type: text/x-patch; name=x86_initial_apicid_x.patch, Size: 4524 bytes --]
[PATCH] 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
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Index: linux-2.6/arch/x86/kernel/cpu/common.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/common.c
+++ linux-2.6/arch/x86/kernel/cpu/common.c
@@ -369,10 +369,12 @@ static void __cpuinit generic_identify(s
if (c->x86 >= 0x6)
c->x86_model += ((tfms >> 16) & 0xF) << 4;
c->x86_mask = tfms & 15;
+ c->initial_apicid = (ebx >> 24) & 0xFF;
#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
- c->apicid = (ebx >> 24) & 0xFF;
+ c->apicid = c->initial_apicid;
#endif
if (test_cpu_cap(c, X86_FEATURE_CLFLSH))
c->x86_clflush_size = ((ebx >> 8) & 0xff) * 8;
@@ -395,9 +397,6 @@ static void __cpuinit generic_identify(s
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)
@@ -554,7 +553,7 @@ void __cpuinit detect_ht(struct cpuinfo_
}
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",
c->phys_proc_id);
@@ -565,7 +564,7 @@ void __cpuinit detect_ht(struct cpuinfo_
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);
if (c->x86_max_cores > 1)
Index: linux-2.6/arch/x86/kernel/cpu/proc.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/proc.c
+++ linux-2.6/arch/x86/kernel/cpu/proc.c
@@ -19,6 +19,8 @@ static void show_cpuinfo_core(struct seq
cpus_weight(per_cpu(cpu_core_map, cpu)));
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, "apicid\t\t: %d\n", c->apicid);
+ seq_printf(m, "initial apicid\t: %d\n", c->initial_apicid);
}
#endif
}
@@ -60,6 +62,7 @@ static void show_cpuinfo_core(struct seq
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, "apicid\t\t: %d\n", c->apicid);
+ seq_printf(m, "initial apicid\t: %d\n", c->initial_apicid);
}
#endif
}
Index: linux-2.6/arch/x86/kernel/setup_64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/setup_64.c
+++ linux-2.6/arch/x86/kernel/setup_64.c
@@ -564,9 +564,9 @@ static void __cpuinit amd_detect_cmp(str
bits = c->x86_coreid_bits;
/* Low order bits define the core id (index of core in socket) */
- c->cpu_core_id = c->phys_proc_id & ((1 << bits)-1);
- /* Convert the APIC ID into the socket ID */
- c->phys_proc_id = (c->apicid - boot_cpu_id) >> bits;
+ c->cpu_core_id = c->initial_apicid & ((1 << bits)-1);
+ /* Convert the initial APIC ID into the socket ID */
+ c->phys_proc_id = c->initial_apicid >> bits;
#ifdef CONFIG_NUMA
node = c->phys_proc_id;
@@ -583,7 +583,7 @@ static void __cpuinit amd_detect_cmp(str
If that doesn't result in a usable node fall back to the
path for the previous case. */
- int ht_nodeid = apicid - boot_cpu_id;
+ int ht_nodeid = c->initial_apicid;
if (ht_nodeid >= 0 &&
apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
@@ -949,8 +949,9 @@ static void __cpuinit early_identify_cpu
c->x86 = 4;
}
+ c->initial_apicid = (cpuid_ebx(1) >> 24) & 0xff;
#ifdef CONFIG_SMP
- c->phys_proc_id = (cpuid_ebx(1) >> 24) & 0xff;
+ c->phys_proc_id = c->initial_apicid;
#endif
/* AMD-defined flags: level 0x80000001 */
xlvl = cpuid_eax(0x80000000);
Index: linux-2.6/include/asm-x86/processor.h
===================================================================
--- linux-2.6.orig/include/asm-x86/processor.h
+++ linux-2.6/include/asm-x86/processor.h
@@ -101,6 +101,7 @@ struct cpuinfo_x86 {
/* cpuid returned max cores value: */
u16 x86_max_cores;
u16 apicid;
+ u16 initial_apicid;
u16 x86_clflush_size;
#ifdef CONFIG_SMP
/* number of cores as seen by the OS: */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86: introduce initial apicid
2008-03-06 21:46 [PATCH] x86: introduce initial apicid Yinghai Lu
@ 2008-03-07 8:47 ` Ingo Molnar
2008-03-07 11:02 ` Andi Kleen
1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2008-03-07 8:47 UTC (permalink / raw)
To: Yinghai Lu
Cc: Andrew Morton, Thomas Gleixner, H. Peter Anvin, Andi Kleen, kernel list
* Yinghai Lu <yhlu.kernel@gmail.com> wrote:
> [PATCH] 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
thanks, applied. This is a quirky area of x86 which is a frequent source
of problems so i guess having more information in /proc/cpuinfo doesnt
hurt ...
Ingo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86: introduce initial apicid
2008-03-06 21:46 [PATCH] x86: introduce initial apicid Yinghai Lu
2008-03-07 8:47 ` Ingo Molnar
@ 2008-03-07 11:02 ` Andi Kleen
1 sibling, 0 replies; 3+ messages in thread
From: Andi Kleen @ 2008-03-07 11:02 UTC (permalink / raw)
To: Yinghai Lu
Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, H. Peter Anvin,
Andi Kleen, kernel list
On Thu, Mar 06, 2008 at 01:46:39PM -0800, Yinghai Lu wrote:
>
> [PATCH] 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
Looks good to me now.
-Andi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-03-07 11:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-06 21:46 [PATCH] x86: introduce initial apicid Yinghai Lu
2008-03-07 8:47 ` Ingo Molnar
2008-03-07 11:02 ` Andi Kleen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).