x86: Fix sibling map with NumaChip
Subsystems (2)
PATCH v4 1/1 x86: Fix sibling map with NumaChip
On NumaChip systems, the physical processor ID assignment wasn't accounting for the number of nodes in AMD multi-module processors, giving an incorrect sibling map:
$ cd /sys/devices/system/cpu/cpu29/topology $ grep . * core_id:5 core_siblings:00000000,ff000000 core_siblings_list:24-31 physical_package_id:3 thread_siblings:00000000,30000000 thread_siblings_list:28-29
After fixing:
core_id:5
core_siblings:00000000,ffff0000
core_siblings_list:16-31
physical_package_id:1
thread_siblings:00000000,30000000
thread_siblings_list:28-29
v2: Fix to check for MSR availability before use, as per Boris's feedback
v3: Test against boot cpu to correct behaviour on larger systems with global IO
v4: Use static_cpu_has_safe(), as Boris suggests
Candidate for stable.
--- arch/x86/kernel/apic/apic_numachip.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
arch/x86/kernel/apic/apic_numachip.c +16 -6
@@ -37,10 +37,12 @@ static const struct apic apic_numachip;static unsigned int get_apic_id (unsigned long x) {unsigned long value; -unsigned int id; +unsigned int id = (x >>24 ) &0xff ; -rdmsrl (MSR_FAM10H_NODE_ID , value); - id = ((x >>24 ) &0xffU ) | ((value <<2 ) &0xff00U ); +if (static_cpu_has_safe (X86_FEATURE_NODEID_MSR )) { +rdmsrl (MSR_FAM10H_NODE_ID , value); + id |= (value <<2 ) &0xff00 ; + }return id; }
@@ -155,10 +157,18 @@ static int __init numachip_probe(void)static void fixup_cpu_id (struct cpuinfo_x86 *c,int node) { -if (c->phys_proc_id != node) { - c->phys_proc_id = node; -per_cpu (cpu_llc_id,smp_processor_id ()) = node; +u64 val; +u32 nodes =1 ; + +this_cpu_write (cpu_llc_id, node); + +/* Account for nodes per socket in multi-core-module processors */ +if (static_cpu_has_safe (X86_FEATURE_NODEID_MSR )) { +rdmsrl (MSR_FAM10H_NODE_ID , val); + nodes = ((val >>3 ) &7 ) +1 ; } + + c->phys_proc_id = node / nodes; }static int __init numachip_system_init (void )
Signature · 1 line
1.9.1
Borislav Petkov
maintainerQuoted 26 lines · Daniel J Blueman
On NumaChip systems, the physical processor ID assignment wasn't accounting for the number of nodes in AMD multi-module processors, giving an incorrect sibling map:
$ cd /sys/devices/system/cpu/cpu29/topology $ grep . * core_id:5 core_siblings:00000000,ff000000 core_siblings_list:24-31 physical_package_id:3 thread_siblings:00000000,30000000 thread_siblings_list:28-29After fixing:
core_id:5
core_siblings:00000000,ffff0000
core_siblings_list:16-31
physical_package_id:1
thread_siblings:00000000,30000000
thread_siblings_list:28-29v2: Fix to check for MSR availability before use, as per Boris's feedback
v3: Test against boot cpu to correct behaviour on larger systems with global IO
v4: Usestatic_cpu_has_safe(), as Boris suggests
Quoted 6 lines
Candidate for stable.
Signed-off-by Daniel J Blueman <[email protected]>--- arch/x86/kernel/apic/apic_numachip.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
Queued for urgent/stable.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--tip-bot for Daniel J Blueman
merge bot[tip:x86/urgent] x86/apic/numachip: Fix sibling map with NumaChip
In reply to Daniel J Bluemanx86/apic/numachip: Fix sibling map with NumaChip
Commit-ID: c8a470cab030bae8f9e6e5cfff72b047b7c627a7 Gitweb: http://git.kernel.org/tip/c8a470cab030bae8f9e6e5cfff72b047b7c627a7 Author: Daniel J Blueman <[email protected]> AuthorDate: Thu, 12 Mar 2015 16:55:13 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 12 Mar 2015 16:58:59 +0100
x86/apic/numachip: Fix sibling map with NumaChip
On NumaChip systems, the physical processor ID assignment wasn't accounting for the number of nodes in AMD multi-module processors, giving an incorrect sibling map:
$ cd /sys/devices/system/cpu/cpu29/topology $ grep . * core_id:5 core_siblings:00000000,ff000000 core_siblings_list:24-31 physical_package_id:3 thread_siblings:00000000,30000000 thread_siblings_list:28-29
This fixes it:
$ cd /sys/devices/system/cpu/cpu29/topology $ grep . * core_id:5 core_siblings:00000000,ffff0000 core_siblings_list:16-31 physical_package_id:1 thread_siblings:00000000,30000000 thread_siblings_list:28-29
--- arch/x86/kernel/apic/apic_numachip.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
arch/x86/kernel/apic/apic_numachip.c +16 -6
@@ -37,10 +37,12 @@ static const struct apic apic_numachip;static unsigned int get_apic_id (unsigned long x) {unsigned long value; -unsigned int id; +unsigned int id = (x >>24 ) &0xff ; -rdmsrl (MSR_FAM10H_NODE_ID , value); - id = ((x >>24 ) &0xffU ) | ((value <<2 ) &0xff00U ); +if (static_cpu_has_safe (X86_FEATURE_NODEID_MSR )) { +rdmsrl (MSR_FAM10H_NODE_ID , value); + id |= (value <<2 ) &0xff00 ; + }return id; }
@@ -155,10 +157,18 @@ static int __init numachip_probe(void)static void fixup_cpu_id (struct cpuinfo_x86 *c,int node) { -if (c->phys_proc_id != node) { - c->phys_proc_id = node; -per_cpu (cpu_llc_id,smp_processor_id ()) = node; +u64 val; +u32 nodes =1 ; + +this_cpu_write (cpu_llc_id, node); + +/* Account for nodes per socket in multi-core-module processors */ +if (static_cpu_has_safe (X86_FEATURE_NODEID_MSR )) { +rdmsrl (MSR_FAM10H_NODE_ID , val); + nodes = ((val >>3 ) &7 ) +1 ; } + + c->phys_proc_id = node / nodes; }static int __init numachip_system_init (void )