LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v4] x86: Fix sibling map with NumaChip
@ 2015-03-12  4:52 Daniel J Blueman
  2015-03-12 14:50 ` Borislav Petkov
  2015-03-16 12:06 ` [tip:x86/urgent] x86/apic/numachip: " tip-bot for Daniel J Blueman
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel J Blueman @ 2015-03-12  4:52 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Daniel J Blueman, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	x86, linux-kernel, Steffen Persvold

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.

Signed-off-by: Daniel J Blueman <daniel@numascale.com>
---
 arch/x86/kernel/apic/apic_numachip.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c
index c2fd21f..c1f4f36 100644
--- a/arch/x86/kernel/apic/apic_numachip.c
+++ b/arch/x86/kernel/apic/apic_numachip.c
@@ -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)
-- 
1.9.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4] x86: Fix sibling map with NumaChip
  2015-03-12  4:52 [PATCH v4] x86: Fix sibling map with NumaChip Daniel J Blueman
@ 2015-03-12 14:50 ` Borislav Petkov
  2015-03-16 12:06 ` [tip:x86/urgent] x86/apic/numachip: " tip-bot for Daniel J Blueman
  1 sibling, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2015-03-12 14:50 UTC (permalink / raw)
  To: Daniel J Blueman
  Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, x86, linux-kernel,
	Steffen Persvold

On Thu, Mar 12, 2015 at 12:52:30PM +0800, Daniel J Blueman wrote:
> 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.
> 
> Signed-off-by: Daniel J Blueman <daniel@numascale.com>
> ---
>  arch/x86/kernel/apic/apic_numachip.c | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)

Queued for urgent/stable.

Thanks.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:x86/urgent] x86/apic/numachip: Fix sibling map with NumaChip
  2015-03-12  4:52 [PATCH v4] x86: Fix sibling map with NumaChip Daniel J Blueman
  2015-03-12 14:50 ` Borislav Petkov
@ 2015-03-16 12:06 ` tip-bot for Daniel J Blueman
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Daniel J Blueman @ 2015-03-16 12:06 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: daniel, mingo, hpa, sp, linux-kernel, stable, bp, tglx

Commit-ID:  c8a470cab030bae8f9e6e5cfff72b047b7c627a7
Gitweb:     http://git.kernel.org/tip/c8a470cab030bae8f9e6e5cfff72b047b7c627a7
Author:     Daniel J Blueman <daniel@numascale.com>
AuthorDate: Thu, 12 Mar 2015 16:55:13 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
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

Signed-off-by: Daniel J Blueman <daniel@numascale.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Steffen Persvold <sp@numascale.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1426135950-10110-1-git-send-email-daniel@numascale.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/apic/apic_numachip.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c
index c2fd21f..017149c 100644
--- a/arch/x86/kernel/apic/apic_numachip.c
+++ b/arch/x86/kernel/apic/apic_numachip.c
@@ -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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-16 12:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12  4:52 [PATCH v4] x86: Fix sibling map with NumaChip Daniel J Blueman
2015-03-12 14:50 ` Borislav Petkov
2015-03-16 12:06 ` [tip:x86/urgent] x86/apic/numachip: " tip-bot for Daniel J Blueman

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).