[PATCH] [RESEND] x86_64: add memory hotremove config option

From: Gary Hade
Date: Fri Sep 05 2008 - 13:22:22 EST


Resending with linux-kernel@xxxxxxxxxxxxxxx and x86@xxxxxxxxxx copied
this time. No changes other than this and modified Subject line. The
only response so far on linux-mm has been an Acked-by: from
Yasunori Goto <y-goto@xxxxxxxxxxxxxx>


Add memory hotremove config option to x86_64

Memory hotremove functionality can currently be configured into
the ia64, powerpc, and s390 kernels. This patch makes it possible
to configure the memory hotremove functionality into the x86_64
kernel as well.

Signed-off-by: Gary Hade <garyhade@xxxxxxxxxx>

---
arch/x86/Kconfig | 3 +++
arch/x86/mm/init_64.c | 18 ++++++++++++++++++
2 files changed, 21 insertions(+)

Index: linux-2.6.27-rc5/arch/x86/Kconfig
===================================================================
--- linux-2.6.27-rc5.orig/arch/x86/Kconfig 2008-09-03 13:33:59.000000000 -0700
+++ linux-2.6.27-rc5/arch/x86/Kconfig 2008-09-03 13:34:55.000000000 -0700
@@ -1384,6 +1384,9 @@
def_bool y
depends on X86_64 || (X86_32 && HIGHMEM)

+config ARCH_ENABLE_MEMORY_HOTREMOVE
+ def_bool y
+
config HAVE_ARCH_EARLY_PFN_TO_NID
def_bool X86_64
depends on NUMA
Index: linux-2.6.27-rc5/arch/x86/mm/init_64.c
===================================================================
--- linux-2.6.27-rc5.orig/arch/x86/mm/init_64.c 2008-09-03 13:34:08.000000000 -0700
+++ linux-2.6.27-rc5/arch/x86/mm/init_64.c 2008-09-03 13:34:55.000000000 -0700
@@ -740,6 +740,24 @@
EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
#endif

+#ifdef CONFIG_MEMORY_HOTREMOVE
+int remove_memory(u64 start, u64 size)
+{
+ unsigned long start_pfn, end_pfn;
+ unsigned long timeout = 120 * HZ;
+ int ret;
+ start_pfn = start >> PAGE_SHIFT;
+ end_pfn = start_pfn + (size >> PAGE_SHIFT);
+ ret = offline_pages(start_pfn, end_pfn, timeout);
+ if (ret)
+ goto out;
+ /* Arch-specific calls go here */
+out:
+ return ret;
+}
+EXPORT_SYMBOL_GPL(remove_memory);
+#endif /* CONFIG_MEMORY_HOTREMOVE */
+
#endif /* CONFIG_MEMORY_HOTPLUG */

/*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/