Skip to contentSkip to conversation

x86, acpi: map hotadded cpu to correct node.

PATCH In review Haicheng Li 2 participants 4 messages Feb 4, 2010 – Feb 10, 2010 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): C8EDE645B81E5141A8C6B2F73FD9265117C58A3504@shzsmsx501.ccr.corp.intel.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 1/1 x86, acpi: map hotadded cpu to correct node.

x86: map hotadded cpu to correct node.

When hotadd new cpu to system, if its affinitive node is online, should map the cpu to its own node. otherwise, let kernel select one online node for the new cpu later.

---
 arch/x86/kernel/acpi/boot.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
arch/x86/kernel/acpi/boot.c +21 -0
index 67e929b..92a4861 100644
@@ -49,6 +49,7 @@ EXPORT_SYMBOL(acpi_disabled);
 
 #ifdef	CONFIG_X86_64
 # include <asm/proto.h>
+# include <asm/numa_64.h>
 #endif				/* X86 */
 
 #define BAD_MADT_ENTRY(entry, end) (					    \
@@ -482,6 +483,25 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
  */
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 
+static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
+{
+#ifdef CONFIG_ACPI_NUMA
+	int nid;
+
+	nid = acpi_get_node(handle);
+	if (!node_online(nid))
+		return;
+#ifdef CONFIG_X86_64
+	apicid_to_node[physid] = nid;
+	numa_set_node(cpu, nid);
+#else /* CONFIG_X86_32 */
+	apicid_2_node[physid] = nid;
+	cpu_to_node_map[cpu] = nid;
+#endif
+
+#endif
+}
+
 static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
 {
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -540,6 +560,7 @@ static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
 	}
 
 	cpu = cpumask_first(new_map);
+	acpi_map_cpu2node(handle, cpu, physid);
 
 	*pcpu = cpu;
 	retval = 0;
Signature · 6 lines
1.6.0.rc1




-haicheng
#3 lore raw

hello,

any comments on this patch? in fact, it's a straightforward bug fix: with existing CPU hotadd code, new added CPUs won't be mapped to its own node. especially for hotadding a new node with CPU and MEM, new added memories can be mapped to this new node, but new added CPUs are always mapped to old nodes. This patch is to fix this obvious bug. thanks.

-haicheng

Quoted 57 lines · Haicheng Li

x86: map hotadded cpu to correct node.

When hotadd new cpu to system, if its affinitive node is online, should map the cpu to its own node. otherwise, let kernel select one online node for the new cpu later.

---
 arch/x86/kernel/acpi/boot.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
arch/x86/kernel/acpi/boot.c +20 -0
index 67e929b..92a4861 100644
@@ -49,6 +49,7 @@ EXPORT_SYMBOL(acpi_disabled);
 
 #ifdef    CONFIG_X86_64
 # include <asm/proto.h>
+# include <asm/numa_64.h>
 #endif                /* X86 */
 
 #define BAD_MADT_ENTRY(entry, end) (                        \
@@ -482,6 +483,25 @@ int acpi_register_gsi(struct device *dev, u32 gsi, 
 int trigger, int polarity)
  */
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 
+static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
+{
+#ifdef CONFIG_ACPI_NUMA
+    int nid;
+
+    nid = acpi_get_node(handle);
+    if (!node_online(nid))
+        return;
+#ifdef CONFIG_X86_64
+    apicid_to_node[physid] = nid;
+    numa_set_node(cpu, nid);
+#else /* CONFIG_X86_32 */
+    apicid_2_node[physid] = nid;
+    cpu_to_node_map[cpu] = nid;
+#endif
+
+#endif
+}
+
 static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
 {
     struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
arch/x86/kernel/acpi/boot.c +1 -0
@@ -540,6 +560,7 @@ static int __cpuinit _acpi_map_lsapic(acpi_handle 
 handle, int *pcpu)
     }
 
     cpu = cpumask_first(new_map);
+    acpi_map_cpu2node(handle, cpu, physid);
 
     *pcpu = cpu;
     retval = 0;
Tested-by Reviewed-by
#4 lore raw
Quoted 7 lines · On Monday 08 February 2010 03:48:06 Haicheng Li wrote:

hello,

any comments on this patch? in fact, it's a straightforward bug fix: with existing CPU hotadd code, new added CPUs won't be mapped to its own node. especially for hotadding a new node with CPU and MEM, new added memories can be mapped to this new node, but new added CPUs are always mapped to old nodes. This patch is to fix this obvious bug. thanks.

I can confirm that this patch works as expected:

While the cores previously showed up on the wrong, already existing node, they are now added to the correct one.

Be aware that there seem to be other issues (Andi posted some slab memory hot plug fixes recently).

Find one "nit pick" below:

Quoted 31 lines

-haicheng

Quoted 28 lines · Haicheng Li

x86: map hotadded cpu to correct node.

When hotadd new cpu to system, if its affinitive node is online, should map the cpu to its own node. otherwise, let kernel select one online node for the new cpu later.

---
 arch/x86/kernel/acpi/boot.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
arch/x86/kernel/acpi/boot.c +1 -0
index 67e929b..92a4861 100644
@@ -49,6 +49,7 @@ EXPORT_SYMBOL(acpi_disabled);
 
 #ifdef    CONFIG_X86_64
 # include <asm/proto.h>
+# include <asm/numa_64.h>
 #endif                /* X86 */
 
 #define BAD_MADT_ENTRY(entry, end) (                        \
@@ -482,6 +483,25 @@ int acpi_register_gsi(struct device *dev, u32 gsi, 
 int trigger, int polarity)
  */
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 
Quoted 7 lines

arch/x86/kernel/acpi/boot.c int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity) · line 492

Quoted 7 lines
arch/x86/kernel/acpi/boot.c +7 -0
+static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
+{
+#ifdef CONFIG_ACPI_NUMA
+    int nid;
+
+    nid = acpi_get_node(handle);
+    if (!node_online(nid))

if (nid == -1 || !node_online(nid))
would avoid passing an invalid param to node_online(..) node_online() probably already can handle this...
A maintainer eventually could fiddle this into the patch/line without the need of re-posting.

I am not that familiar with numa node handling, but went the code and spec up and down a bit. Also assigning a node no. is rather straight forward, thus I can give this a:

Thanks,

Thomas

#5 lore raw

[tip:x86/numa] x86, acpi: Map hotadded cpu to correct node.

In reply to Haicheng Li
Commit-ID:  0271f91003d3703675be13b8865618359a6caa1f
Gitweb:     http://git.kernel.org/tip/0271f91003d3703675be13b8865618359a6caa1f
Author:     Haicheng Li <[email protected]>
AuthorDate: Thu, 4 Feb 2010 19:06:33 +0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Wed, 10 Feb 2010 11:00:43 -0800

x86, acpi: Map hotadded cpu to correct node.

When hotadd new cpu to system, if its affinitive node is online, should map the cpu to its own node. Otherwise, let kernel select one online node for the new cpu later.

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/acpi/boot.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
arch/x86/kernel/acpi/boot.c +21 -0
index 036d28a..7db15e1 100644
@@ -49,6 +49,7 @@ EXPORT_SYMBOL(acpi_disabled);
 
 #ifdef	CONFIG_X86_64
 # include <asm/proto.h>
+# include <asm/numa_64.h>
 #endif				/* X86 */
 
 #define BAD_MADT_ENTRY(entry, end) (					    \
@@ -482,6 +483,25 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
  */
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 
+static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
+{
+#ifdef CONFIG_ACPI_NUMA
+	int nid;
+
+	nid = acpi_get_node(handle);
+	if (nid == -1 || !node_online(nid))
+		return;
+#ifdef CONFIG_X86_64
+	apicid_to_node[physid] = nid;
+	numa_set_node(cpu, nid);
+#else /* CONFIG_X86_32 */
+	apicid_2_node[physid] = nid;
+	cpu_to_node_map[cpu] = nid;
+#endif
+
+#endif
+}
+
 static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
 {
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -540,6 +560,7 @@ static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
 	}
 
 	cpu = cpumask_first(new_map);
+	acpi_map_cpu2node(handle, cpu, physid);
 
 	*pcpu = cpu;
 	retval = 0;