Commit 8c2676a5870ab15cbeea9f826266bc946fe3cc26

Authored by Keith Mannthey
Committed by Linus Torvalds
1 parent 4942e998b4

[PATCH] hot-add-mem x86_64: memory_add_physaddr_to_nid node fixup

In cases where the acpi memory-add event does not containe the pxm (node)
infomation allow the driver to look up node info based on the address.  The
acpi_get_node call returns -1 if it can't decode the pxm info, this causes
add_memory to panic.  acpi_get_node would have to decode the resource from the
handle (a lenghty proposition).  This seems to be the cleanist point to
interject the hook.

[kamezawa.hiroyu@jp.fujitsu.com: build fixes]
[y-goto@jp.fujitsu.com: build fixes]
Signed-off-by: Keith Mannthey <kmannth@us.ibm.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Andi Kleen <ak@muc.de>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 4 changed files with 25 additions and 0 deletions Side-by-side Diff

... ... @@ -16,6 +16,7 @@
16 16 #include <linux/node.h>
17 17 #include <linux/init.h>
18 18 #include <linux/bootmem.h>
  19 +#include <linux/module.h>
19 20 #include <asm/mmzone.h>
20 21 #include <asm/numa.h>
21 22  
... ... @@ -69,5 +70,22 @@
69 70  
70 71 return 0;
71 72 }
  73 +
  74 +#ifdef CONFIG_MEMORY_HOTPLUG
  75 +/*
  76 + * SRAT information is stored in node_memblk[], then we can use SRAT
  77 + * information at memory-hot-add if necessary.
  78 + */
  79 +
  80 +int memory_add_physaddr_to_nid(u64 addr)
  81 +{
  82 + int nid = paddr_to_nid(addr);
  83 + if (nid < 0)
  84 + return 0;
  85 + return nid;
  86 +}
  87 +
  88 +EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
  89 +#endif
72 90 #endif
arch/x86_64/mm/init.c
... ... @@ -498,6 +498,7 @@
498 498 {
499 499 return 0;
500 500 }
  501 +EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
501 502 #endif
502 503  
503 504 #else /* CONFIG_MEMORY_HOTPLUG */
arch/x86_64/mm/srat.c
... ... @@ -477,4 +477,5 @@
477 477  
478 478 return ret;
479 479 }
  480 +EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
drivers/acpi/acpi_memhotplug.c
... ... @@ -238,6 +238,10 @@
238 238 num_enabled++;
239 239 continue;
240 240 }
  241 +
  242 + if (node < 0)
  243 + node = memory_add_physaddr_to_nid(info->start_addr);
  244 +
241 245 result = add_memory(node, info->start_addr, info->length);
242 246 if (result)
243 247 continue;