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.
Signed-off-by: Haicheng Li <[email protected]>
---
arch/x86/kernel/acpi/boot.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 67e929b..92a4861 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -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;
--
1.6.0.rc1
-haicheng
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
Haicheng Li wrote:
> 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.
>
> Signed-off-by: Haicheng Li <[email protected]>
> ---
> arch/x86/kernel/acpi/boot.c | 21 +++++++++++++++++++++
> 1 files changed, 21 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
> index 67e929b..92a4861 100644
> --- a/arch/x86/kernel/acpi/boot.c
> +++ b/arch/x86/kernel/acpi/boot.c
> @@ -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;
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:
Tested-by: Thomas Renninger <[email protected]>
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:
> -haicheng
>
> Haicheng Li wrote:
> > 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.
> >
> > Signed-off-by: Haicheng Li <[email protected]>
> > ---
> > arch/x86/kernel/acpi/boot.c | 21 +++++++++++++++++++++
> > 1 files changed, 21 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
> > index 67e929b..92a4861 100644
> > --- a/arch/x86/kernel/acpi/boot.c
> > +++ b/arch/x86/kernel/acpi/boot.c
> > @@ -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))
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:
Reviewed-by: Thomas Renninger <[email protected]>
Thanks,
Thomas
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.
Signed-off-by: Haicheng Li <[email protected]>
LKML-Reference: <[email protected]>
Tested-by: Thomas Renninger <[email protected]>
Signed-off-by: H. Peter Anvin <[email protected]>
---
arch/x86/kernel/acpi/boot.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 036d28a..7db15e1 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -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;