===================================================================
@@ -452,12 +452,33 @@ static int acpi_memory_device_add(struct
static int acpi_memory_device_remove(struct acpi_device *device, int type)
{
struct acpi_memory_device *mem_device = NULL;
-
+ struct acpi_memory_info *info, *tmp;
+ int result;
+ int node;
if (!device || !acpi_driver_data(device))
return -EINVAL;
mem_device = acpi_driver_data(device);
+
+ node = acpi_get_node(mem_device->device->handle);
+
+ list_for_each_entry_safe(info, tmp, &mem_device->res_list, list) {
+ if (!info->enabled)
+ continue;
+
+ result = offline_memory(info->start_addr, info->length);
+ if (result)
+ return result;
+
+ result = remove_memory(node, info->start_addr, info->length);
+ if (result)
+ return result;
+
+ list_del(&info->list);
+ kfree(info);
+ }
+
kfree(mem_device);
return 0;
===================================================================
@@ -233,6 +233,7 @@ static inline int is_mem_section_removab
extern int mem_online_node(int nid);
extern int add_memory(int nid, u64 start, u64 size);
extern int arch_add_memory(int nid, u64 start, u64 size);
+extern int remove_memory(int nid, u64 start, u64 size);
extern int offline_memory(u64 start, u64 size);
extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
int nr_pages);
===================================================================
@@ -659,6 +659,14 @@ out:
}
EXPORT_SYMBOL_GPL(add_memory);
+int remove_memory(int nid, u64 start, u64 size)
+{
+ return -EBUSY;
+
+}
+EXPORT_SYMBOL_GPL(remove_memory);
+
+
#ifdef CONFIG_MEMORY_HOTREMOVE
/*
* A free page on the buddy free lists (not the per-cpu lists) has PageBuddy
acpi_memory_device_remove() has been prepared to remove physical memory. But, the function only frees acpi_memory_device currentlry. The patch adds following functions into acpi_memory_device_remove(): - offline memory - remove physical memory (only return -EBUSY) - free acpi_memory_device CC: Len Brown <len.brown@intel.com> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org> CC: Paul Mackerras <paulus@samba.org> CC: Christoph Lameter <cl@linux.com> Cc: Minchan Kim <minchan.kim@gmail.com> CC: Andrew Morton <akpm@linux-foundation.org> CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> CC: Wen Congyang <wency@cn.fujitsu.com> Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> --- drivers/acpi/acpi_memhotplug.c | 23 ++++++++++++++++++++++- include/linux/memory_hotplug.h | 1 + mm/memory_hotplug.c | 8 ++++++++ 3 files changed, 31 insertions(+), 1 deletion(-)