From: Yasunori Goto Change the name of old add_memory() to arch_add_memory. And use node id to get pgdat for the node at NODE_DATA(). Note: Powerpc's old add_memory() is defined as __devinit. However, add_memory() is usually called only after bootup. I suppose it may be redundant. But, I'm not well known about powerpc. So, I keep it. (But, __meminit is better at least.) Signed-off-by: Yasunori Goto Cc: Dave Hansen Cc: "Brown, Len" Signed-off-by: Andrew Morton --- arch/i386/mm/init.c | 2 +- arch/ia64/mm/init.c | 4 ++-- arch/powerpc/mm/mem.c | 9 ++++++--- arch/x86_64/mm/init.c | 6 +++--- drivers/acpi/acpi_memhotplug.c | 3 ++- drivers/base/memory.c | 4 +++- include/linux/memory_hotplug.h | 13 ++++++++++++- mm/memory_hotplug.c | 10 ++++++++++ 8 files changed, 39 insertions(+), 12 deletions(-) diff -puN arch/i386/mm/init.c~pgdat-allocation-for-new-node-add-specify-node-id arch/i386/mm/init.c --- devel/arch/i386/mm/init.c~pgdat-allocation-for-new-node-add-specify-node-id 2006-04-30 00:30:38.000000000 -0700 +++ devel-akpm/arch/i386/mm/init.c 2006-04-30 00:30:38.000000000 -0700 @@ -665,7 +665,7 @@ void __init mem_init(void) */ #ifdef CONFIG_MEMORY_HOTPLUG #ifndef CONFIG_NEED_MULTIPLE_NODES -int add_memory(u64 start, u64 size) +int arch_add_memory(int nid, u64 start , u64 size) { struct pglist_data *pgdata = &contig_page_data; struct zone *zone = pgdata->node_zones + MAX_NR_ZONES-1; diff -puN arch/ia64/mm/init.c~pgdat-allocation-for-new-node-add-specify-node-id arch/ia64/mm/init.c --- devel/arch/ia64/mm/init.c~pgdat-allocation-for-new-node-add-specify-node-id 2006-04-30 00:30:38.000000000 -0700 +++ devel-akpm/arch/ia64/mm/init.c 2006-04-30 00:30:38.000000000 -0700 @@ -652,7 +652,7 @@ void online_page(struct page *page) num_physpages++; } -int add_memory(u64 start, u64 size) +int arch_add_memory(int nid, u64 start, u64 size) { pg_data_t *pgdat; struct zone *zone; @@ -660,7 +660,7 @@ int add_memory(u64 start, u64 size) unsigned long nr_pages = size >> PAGE_SHIFT; int ret; - pgdat = NODE_DATA(0); + pgdat = NODE_DATA(nid); zone = pgdat->node_zones + ZONE_NORMAL; ret = __add_pages(zone, start_pfn, nr_pages); diff -puN arch/powerpc/mm/mem.c~pgdat-allocation-for-new-node-add-specify-node-id arch/powerpc/mm/mem.c --- devel/arch/powerpc/mm/mem.c~pgdat-allocation-for-new-node-add-specify-node-id 2006-04-30 00:30:38.000000000 -0700 +++ devel-akpm/arch/powerpc/mm/mem.c 2006-04-30 00:30:38.000000000 -0700 @@ -114,15 +114,18 @@ void online_page(struct page *page) num_physpages++; } -int __devinit add_memory(u64 start, u64 size) +int memory_add_physaddr_to_nid(u64 start) +{ + return hot_add_scn_to_nid(start); +} + +int __devinit arch_add_memory(in nid, u64 start, u64 size) { struct pglist_data *pgdata; struct zone *zone; - int nid; unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT; - nid = hot_add_scn_to_nid(start); pgdata = NODE_DATA(nid); start = (unsigned long)__va(start); diff -puN arch/x86_64/mm/init.c~pgdat-allocation-for-new-node-add-specify-node-id arch/x86_64/mm/init.c --- devel/arch/x86_64/mm/init.c~pgdat-allocation-for-new-node-add-specify-node-id 2006-04-30 00:30:38.000000000 -0700 +++ devel-akpm/arch/x86_64/mm/init.c 2006-04-30 00:30:38.000000000 -0700 @@ -551,9 +551,9 @@ int __add_pages(struct zone *z, unsigned * Memory is added always to NORMAL zone. This means you will never get * additional DMA/DMA32 memory. */ -int add_memory(u64 start, u64 size) +int arch_add_memory(int nid, u64 start, u64 size) { - struct pglist_data *pgdat = NODE_DATA(0); + struct pglist_data *pgdat = NODE_DATA(nid); struct zone *zone = pgdat->node_zones + MAX_NR_ZONES-2; unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT; @@ -570,7 +570,7 @@ error: printk("%s: Problem encountered in __add_pages!\n", __func__); return ret; } -EXPORT_SYMBOL_GPL(add_memory); +EXPORT_SYMBOL_GPL(arch_add_memory); int remove_memory(u64 start, u64 size) { diff -puN drivers/acpi/acpi_memhotplug.c~pgdat-allocation-for-new-node-add-specify-node-id drivers/acpi/acpi_memhotplug.c --- devel/drivers/acpi/acpi_memhotplug.c~pgdat-allocation-for-new-node-add-specify-node-id 2006-04-30 00:30:38.000000000 -0700 +++ devel-akpm/drivers/acpi/acpi_memhotplug.c 2006-04-30 00:30:38.000000000 -0700 @@ -215,6 +215,7 @@ static int acpi_memory_enable_device(str { int result, num_enabled = 0; struct acpi_memory_info *info; + int node = 0; ACPI_FUNCTION_TRACE("acpi_memory_enable_device"); @@ -244,7 +245,7 @@ static int acpi_memory_enable_device(str continue; } - result = add_memory(info->start_addr, info->length); + result = add_memory(node, info->start_addr, info->length); if (result) continue; info->enabled = 1; diff -puN drivers/base/memory.c~pgdat-allocation-for-new-node-add-specify-node-id drivers/base/memory.c --- devel/drivers/base/memory.c~pgdat-allocation-for-new-node-add-specify-node-id 2006-04-30 00:30:38.000000000 -0700 +++ devel-akpm/drivers/base/memory.c 2006-04-30 00:30:38.000000000 -0700 @@ -306,11 +306,13 @@ static ssize_t memory_probe_store(struct class *class, const char *buf, size_t count) { u64 phys_addr; + int nid; int ret; phys_addr = simple_strtoull(buf, NULL, 0); - ret = add_memory(phys_addr, PAGES_PER_SECTION << PAGE_SHIFT); + nid = memory_add_physaddr_to_nid(phys_addr); + ret = add_memory(nid, phys_addr, PAGES_PER_SECTION << PAGE_SHIFT); if (ret) count = ret; diff -puN include/linux/memory_hotplug.h~pgdat-allocation-for-new-node-add-specify-node-id include/linux/memory_hotplug.h --- devel/include/linux/memory_hotplug.h~pgdat-allocation-for-new-node-add-specify-node-id 2006-04-30 00:30:38.000000000 -0700 +++ devel-akpm/include/linux/memory_hotplug.h 2006-04-30 00:30:38.000000000 -0700 @@ -63,6 +63,16 @@ extern int online_pages(unsigned long, u /* reasonably generic interface to expand the physical pages in a zone */ extern int __add_pages(struct zone *zone, unsigned long start_pfn, unsigned long nr_pages); + +#if defined(CONFIG_NUMA) +extern int memory_add_physaddr_to_nid(u64 start); +#else +static inline int memofy_add_physaddr_to_nid(u64 start) +{ + return 0; +} +#endif + #else /* ! CONFIG_MEMORY_HOTPLUG */ /* * Stub functions for when hotplug is off @@ -99,7 +109,8 @@ static inline int __remove_pages(struct return -ENOSYS; } -extern int add_memory(u64 start, u64 size); +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(u64 start, u64 size); #endif /* __LINUX_MEMORY_HOTPLUG_H */ diff -puN mm/memory_hotplug.c~pgdat-allocation-for-new-node-add-specify-node-id mm/memory_hotplug.c --- devel/mm/memory_hotplug.c~pgdat-allocation-for-new-node-add-specify-node-id 2006-04-30 00:30:38.000000000 -0700 +++ devel-akpm/mm/memory_hotplug.c 2006-04-30 00:30:38.000000000 -0700 @@ -163,3 +163,13 @@ int online_pages(unsigned long pfn, unsi return 0; } + +int add_memory(int nid, u64 start, u64 size) +{ + int ret; + + /* call arch's memory hotadd */ + ret = arch_add_memory(nid, start, size); + + return ret; +} _