please check my version, we should use core id bits instead.
it should replace
[PATCH for review] [37/48] x86_64: make k8topology multi-core aware
YH
[PATCH] x86_64: use apic core id bits for core nums
we need to use apic core id bits to get core num and use that get apic_to_node
correctly.
it will work with quad core downcores cpus.
Signed-off-by: Yinghai Lu <[email protected]>
diff --git a/arch/x86_64/mm/k8topology.c b/arch/x86_64/mm/k8topology.c
index f983c75..3e8e47f 100644
--- a/arch/x86_64/mm/k8topology.c
+++ b/arch/x86_64/mm/k8topology.c
@@ -49,7 +49,10 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
int found = 0;
u32 reg;
unsigned numnodes;
- unsigned dualcore = 0;
+ unsigned cores;
+ u32 ecx;
+ unsigned bits;
+ int j;
if (!early_pci_allowed())
return -1;
@@ -67,14 +70,26 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
printk(KERN_INFO "Number of nodes %d\n", numnodes);
+ ecx = cpuid_ecx(0x80000008);
+ cores = (ecx & 0xff) + 1;
+
+ /* CPU telling us the core id bits shift? */
+ bits = (ecx >> 12) & 0xF;
+
+ /* Otherwise recompute */
+ if (bits == 0) {
+ while ((1 << bits) < cores)
+ bits++;
+ }
+
+ cores = (1<<bits);
+
memset(&nodes,0,sizeof(nodes));
prevbase = 0;
for (i = 0; i < 8; i++) {
unsigned long base,limit;
u32 nodeid;
- /* Undefined before E stepping, but hopefully 0 */
- dualcore |= ((read_pci_config(0, nb, 3, 0xe8) >> 12) & 3) == 1;
base = read_pci_config(0, nb, 1, 0x40 + i*8);
limit = read_pci_config(0, nb, 1, 0x44 + i*8);
@@ -170,8 +185,8 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
for (i = 0; i < 8; i++) {
if (nodes[i].start != nodes[i].end) {
nodeid = nodeids[i];
- apicid_to_node[nodeid << dualcore] = i;
- apicid_to_node[(nodeid << dualcore) + dualcore] = i;
+ for (j = 0; j < cores; j++)
+ apicid_to_node[(nodeid << bits) + j] = i;
setup_node_bootmem(i, nodes[i].start, nodes[i].end);
}
}
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]