Re: [PATCH 2/3] acpi, memory-hotplug: Extend movablemem_map ranges to the end of node.
Hi Andrew, On 01/26/2013 08:36 AM, Andrew Morton wrote: The patch generates a bunch of rejects, partly due to linux-next changes but I think I fixed everything up OK. Thank you for your fixing. :) index 4ddf497..f841d0e 100644 --- a/arch/x86/mm/srat.c +++ b/arch/x86/mm/srat.c @@ -141,11 +141,16 @@ static inline int save_add_info(void) {return 1;} static inline int save_add_info(void) {return 0;} #endif +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP +extern struct movablemem_map movablemem_map; +#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ Well. a) we shouldn't put extern declarations in C files - put them in headers so we can be assured that all compilation units agree on the type. OK, got it. :) b) the ifdefs are unneeded - a unused extern declaration is OK (as long as the type itself is always defined!) I think struct movablemem_map is defined in mm.h, protected by CONFIG_HAVE_MEMBLOCK_NODE_MAP. So the declaration needs to be protected by CONFIG_HAVE_MEMBLOCK_NODE_MAP. c) movablemem_map is already declared in memblock.h. Hum, yes, it is defined in mm.h, included by memblock.h :) So I zapped the above three lines. @@ -178,9 +185,57 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) node_set(node, numa_nodes_parsed); - printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n", + printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx] %s\n", node, pxm, - (unsigned long long) start, (unsigned long long) end - 1); + (unsigned long long) start, (unsigned long long) end - 1, + hotpluggable ? "Hot Pluggable": ""); + +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP + int overlap; + unsigned long start_pfn, end_pfn; no, we don't put declarations of locals in the middle of C statements like this: arch/x86/mm/srat.c: In function 'acpi_numa_memory_affinity_init': arch/x86/mm/srat.c:185: warning: ISO C90 forbids mixed declarations and code Did your compiler not emit this warning? Sorry, I think it did, but I missed it. THanks for fixing that. :) I fixed this by moving the code into a new function "handle_movablemem". Feel free to suggest a more appropriate name! From: Andrew Morton Subject: acpi-memory-hotplug-extend-movablemem_map-ranges-to-the-end-of-node-fix clean up code, fix build warning Cc: "Brown, Len" Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Jiang Liu Cc: Jianguo Wu Cc: KOSAKI Motohiro Cc: Kamezawa Hiroyuki Cc: Lai Jiangshan Cc: Len Brown Cc: Tang Chen Cc: Thomas Gleixner Cc: Wu Jianguo Cc: Yasuaki Ishimatsu Signed-off-by: Andrew Morton --- arch/x86/mm/srat.c | 93 ++- 1 file changed, 49 insertions(+), 44 deletions(-) diff -puN arch/x86/mm/srat.c~acpi-memory-hotplug-extend-movablemem_map-ranges-to-the-end-of-node-fix arch/x86/mm/srat.c --- a/arch/x86/mm/srat.c~acpi-memory-hotplug-extend-movablemem_map-ranges-to-the-end-of-node-fix +++ a/arch/x86/mm/srat.c @@ -142,50 +142,8 @@ static inline int save_add_info(void) {r #endif #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP -extern struct movablemem_map movablemem_map; -#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ - -/* Callback for parsing of the Proximity Domain<-> Memory Area mappings */ -int __init -acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) +static void __init handle_movablemem(int node, u64 start, u64 end) { - u64 start, end; - u32 hotpluggable; - int node, pxm; - - if (srat_disabled()) - goto out_err; - if (ma->header.length != sizeof(struct acpi_srat_mem_affinity)) - goto out_err_bad_srat; - if ((ma->flags& ACPI_SRAT_MEM_ENABLED) == 0) - goto out_err; - hotpluggable = ma->flags& ACPI_SRAT_MEM_HOT_PLUGGABLE; - if (hotpluggable&& !save_add_info()) - goto out_err; - - start = ma->base_address; - end = start + ma->length; - pxm = ma->proximity_domain; - if (acpi_srat_revision<= 1) - pxm&= 0xff; - - node = setup_node(pxm); - if (node< 0) { - printk(KERN_ERR "SRAT: Too many proximity domains.\n"); - goto out_err_bad_srat; - } - - if (numa_add_memblk(node, start, end)< 0) - goto out_err_bad_srat; - - node_set(node, numa_nodes_parsed); - - printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx] %s\n", - node, pxm, - (unsigned long long) start, (unsigned long long) end - 1, - hotpluggable ? "Hot Pluggable": ""); - -#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP int overlap; unsigned long start_pfn, end_pfn; @@ -229,7 +187,54 @@ acpi_numa_memory_affinity_init(struct ac */ insert_movablemem_map(start_pfn, end_pfn); } -#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ +} +#else /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
Re: [PATCH 2/3] acpi, memory-hotplug: Extend movablemem_map ranges to the end of node.
Hi Andrew, On 01/26/2013 08:36 AM, Andrew Morton wrote: The patch generates a bunch of rejects, partly due to linux-next changes but I think I fixed everything up OK. Thank you for your fixing. :) index 4ddf497..f841d0e 100644 --- a/arch/x86/mm/srat.c +++ b/arch/x86/mm/srat.c @@ -141,11 +141,16 @@ static inline int save_add_info(void) {return 1;} static inline int save_add_info(void) {return 0;} #endif +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP +extern struct movablemem_map movablemem_map; +#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ Well. a) we shouldn't put extern declarations in C files - put them in headers so we can be assured that all compilation units agree on the type. OK, got it. :) b) the ifdefs are unneeded - a unused extern declaration is OK (as long as the type itself is always defined!) I think struct movablemem_map is defined in mm.h, protected by CONFIG_HAVE_MEMBLOCK_NODE_MAP. So the declaration needs to be protected by CONFIG_HAVE_MEMBLOCK_NODE_MAP. c) movablemem_map is already declared in memblock.h. Hum, yes, it is defined in mm.h, included by memblock.h :) So I zapped the above three lines. @@ -178,9 +185,57 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) node_set(node, numa_nodes_parsed); - printk(KERN_INFO SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n, + printk(KERN_INFO SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx] %s\n, node, pxm, - (unsigned long long) start, (unsigned long long) end - 1); + (unsigned long long) start, (unsigned long long) end - 1, + hotpluggable ? Hot Pluggable: ); + +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP + int overlap; + unsigned long start_pfn, end_pfn; no, we don't put declarations of locals in the middle of C statements like this: arch/x86/mm/srat.c: In function 'acpi_numa_memory_affinity_init': arch/x86/mm/srat.c:185: warning: ISO C90 forbids mixed declarations and code Did your compiler not emit this warning? Sorry, I think it did, but I missed it. THanks for fixing that. :) I fixed this by moving the code into a new function handle_movablemem. Feel free to suggest a more appropriate name! From: Andrew Mortona...@linux-foundation.org Subject: acpi-memory-hotplug-extend-movablemem_map-ranges-to-the-end-of-node-fix clean up code, fix build warning Cc: Brown, Lenlen.br...@intel.com Cc: H. Peter Anvinh...@zytor.com Cc: Ingo Molnarmi...@elte.hu Cc: Jiang Liujiang@huawei.com Cc: Jianguo Wuwujian...@huawei.com Cc: KOSAKI Motohirokosaki.motoh...@jp.fujitsu.com Cc: Kamezawa Hiroyukikamezawa.hir...@jp.fujitsu.com Cc: Lai Jiangshanla...@cn.fujitsu.com Cc: Len Brownl...@kernel.org Cc: Tang Chentangc...@cn.fujitsu.com Cc: Thomas Gleixnert...@linutronix.de Cc: Wu Jianguowujian...@huawei.com Cc: Yasuaki Ishimatsuisimatu.yasu...@jp.fujitsu.com Signed-off-by: Andrew Mortona...@linux-foundation.org --- arch/x86/mm/srat.c | 93 ++- 1 file changed, 49 insertions(+), 44 deletions(-) diff -puN arch/x86/mm/srat.c~acpi-memory-hotplug-extend-movablemem_map-ranges-to-the-end-of-node-fix arch/x86/mm/srat.c --- a/arch/x86/mm/srat.c~acpi-memory-hotplug-extend-movablemem_map-ranges-to-the-end-of-node-fix +++ a/arch/x86/mm/srat.c @@ -142,50 +142,8 @@ static inline int save_add_info(void) {r #endif #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP -extern struct movablemem_map movablemem_map; -#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ - -/* Callback for parsing of the Proximity Domain- Memory Area mappings */ -int __init -acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) +static void __init handle_movablemem(int node, u64 start, u64 end) { - u64 start, end; - u32 hotpluggable; - int node, pxm; - - if (srat_disabled()) - goto out_err; - if (ma-header.length != sizeof(struct acpi_srat_mem_affinity)) - goto out_err_bad_srat; - if ((ma-flags ACPI_SRAT_MEM_ENABLED) == 0) - goto out_err; - hotpluggable = ma-flags ACPI_SRAT_MEM_HOT_PLUGGABLE; - if (hotpluggable !save_add_info()) - goto out_err; - - start = ma-base_address; - end = start + ma-length; - pxm = ma-proximity_domain; - if (acpi_srat_revision= 1) - pxm= 0xff; - - node = setup_node(pxm); - if (node 0) { - printk(KERN_ERR SRAT: Too many proximity domains.\n); - goto out_err_bad_srat; - } - - if (numa_add_memblk(node, start, end) 0) - goto out_err_bad_srat; - - node_set(node, numa_nodes_parsed); - - printk(KERN_INFO SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx] %s\n, - node, pxm, - (unsigned long long) start, (unsigned long long) end - 1, - hotpluggable ? Hot Pluggable: ); - -#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP int overlap; unsigned long
Re: [PATCH 2/3] acpi, memory-hotplug: Extend movablemem_map ranges to the end of node.
On Fri, 25 Jan 2013 17:42:08 +0800 Tang Chen wrote: > When implementing movablemem_map boot option, we introduced an array > movablemem_map.map[] to store the memory ranges to be set as ZONE_MOVABLE. > > Since ZONE_MOVABLE is the latst zone of a node, if user didn't specify > the whole node memory range, we need to extend it to the node end so that > we can use it to prevent memblock from allocating memory in the ranges > user didn't specify. > > We now implement movablemem_map boot option like this: > /* > * For movablemem_map=nn[KMG]@ss[KMG]: > * > * SRAT:|_| |_| |_| |_| .. > * node id:0 1 1 2 > * user specified:|__| |___| > * movablemem_map:|___| |_||__| .. > * > * Using movablemem_map, we can prevent memblock from allocating > memory > * on ZONE_MOVABLE at boot time. > * > * NOTE: In this case, SRAT info will be ingored. > */ > The patch generates a bunch of rejects, partly due to linux-next changes but I think I fixed everything up OK. > index 4ddf497..f841d0e 100644 > --- a/arch/x86/mm/srat.c > +++ b/arch/x86/mm/srat.c > @@ -141,11 +141,16 @@ static inline int save_add_info(void) {return 1;} > static inline int save_add_info(void) {return 0;} > #endif > > +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP > +extern struct movablemem_map movablemem_map; > +#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ Well. a) we shouldn't put extern declarations in C files - put them in headers so we can be assured that all compilation units agree on the type. b) the ifdefs are unneeded - a unused extern declaration is OK (as long as the type itself is always defined!) c) movablemem_map is already declared in memblock.h. So I zapped the above three lines. > @@ -178,9 +185,57 @@ acpi_numa_memory_affinity_init(struct > acpi_srat_mem_affinity *ma) > > node_set(node, numa_nodes_parsed); > > - printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n", > + printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx] %s\n", > node, pxm, > -(unsigned long long) start, (unsigned long long) end - 1); > +(unsigned long long) start, (unsigned long long) end - 1, > +hotpluggable ? "Hot Pluggable": ""); > + > +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP > + int overlap; > + unsigned long start_pfn, end_pfn; no, we don't put declarations of locals in the middle of C statements like this: arch/x86/mm/srat.c: In function 'acpi_numa_memory_affinity_init': arch/x86/mm/srat.c:185: warning: ISO C90 forbids mixed declarations and code Did your compiler not emit this warning? I fixed this by moving the code into a new function "handle_movablemem". Feel free to suggest a more appropriate name! From: Andrew Morton Subject: acpi-memory-hotplug-extend-movablemem_map-ranges-to-the-end-of-node-fix clean up code, fix build warning Cc: "Brown, Len" Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Jiang Liu Cc: Jianguo Wu Cc: KOSAKI Motohiro Cc: Kamezawa Hiroyuki Cc: Lai Jiangshan Cc: Len Brown Cc: Tang Chen Cc: Thomas Gleixner Cc: Wu Jianguo Cc: Yasuaki Ishimatsu Signed-off-by: Andrew Morton --- arch/x86/mm/srat.c | 93 ++- 1 file changed, 49 insertions(+), 44 deletions(-) diff -puN arch/x86/mm/srat.c~acpi-memory-hotplug-extend-movablemem_map-ranges-to-the-end-of-node-fix arch/x86/mm/srat.c --- a/arch/x86/mm/srat.c~acpi-memory-hotplug-extend-movablemem_map-ranges-to-the-end-of-node-fix +++ a/arch/x86/mm/srat.c @@ -142,50 +142,8 @@ static inline int save_add_info(void) {r #endif #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP -extern struct movablemem_map movablemem_map; -#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ - -/* Callback for parsing of the Proximity Domain <-> Memory Area mappings */ -int __init -acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) +static void __init handle_movablemem(int node, u64 start, u64 end) { - u64 start, end; - u32 hotpluggable; - int node, pxm; - - if (srat_disabled()) - goto out_err; - if (ma->header.length != sizeof(struct acpi_srat_mem_affinity)) - goto out_err_bad_srat; - if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0) - goto out_err; - hotpluggable = ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE; - if (hotpluggable && !save_add_info()) - goto out_err; - - start = ma->base_address; - end = start + ma->length; - pxm = ma->proximity_domain; - if (acpi_srat_revision <= 1) - pxm &= 0xff; - - node = setup_node(pxm); - if (node < 0) { - printk(KERN_ERR "SRAT: Too many proximity domains.\n"); - goto out_err_bad_srat; - } -
[PATCH 2/3] acpi, memory-hotplug: Extend movablemem_map ranges to the end of node.
When implementing movablemem_map boot option, we introduced an array movablemem_map.map[] to store the memory ranges to be set as ZONE_MOVABLE. Since ZONE_MOVABLE is the latst zone of a node, if user didn't specify the whole node memory range, we need to extend it to the node end so that we can use it to prevent memblock from allocating memory in the ranges user didn't specify. We now implement movablemem_map boot option like this: /* * For movablemem_map=nn[KMG]@ss[KMG]: * * SRAT:|_| |_| |_| |_| .. * node id:0 1 1 2 * user specified:|__| |___| * movablemem_map:|___| |_||__| .. * * Using movablemem_map, we can prevent memblock from allocating memory * on ZONE_MOVABLE at boot time. * * NOTE: In this case, SRAT info will be ingored. */ Signed-off-by: Tang Chen --- arch/x86/mm/srat.c | 61 +-- include/linux/mm.h |5 mm/page_alloc.c| 34 +++- 3 files changed, 95 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/srat.c b/arch/x86/mm/srat.c index 4ddf497..f841d0e 100644 --- a/arch/x86/mm/srat.c +++ b/arch/x86/mm/srat.c @@ -141,11 +141,16 @@ static inline int save_add_info(void) {return 1;} static inline int save_add_info(void) {return 0;} #endif +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP +extern struct movablemem_map movablemem_map; +#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ + /* Callback for parsing of the Proximity Domain <-> Memory Area mappings */ int __init acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) { u64 start, end; + u32 hotpluggable; int node, pxm; if (srat_disabled()) @@ -157,8 +162,10 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0) return -1; - if ((ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) && !save_add_info()) + hotpluggable = ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE; + if (hotpluggable && !save_add_info()) return -1; + start = ma->base_address; end = start + ma->length; pxm = ma->proximity_domain; @@ -178,9 +185,57 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) node_set(node, numa_nodes_parsed); - printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n", + printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx] %s\n", node, pxm, - (unsigned long long) start, (unsigned long long) end - 1); + (unsigned long long) start, (unsigned long long) end - 1, + hotpluggable ? "Hot Pluggable": ""); + +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP + int overlap; + unsigned long start_pfn, end_pfn; + + start_pfn = PFN_DOWN(start); + end_pfn = PFN_UP(end); + + /* +* For movablecore_map=nn[KMG]@ss[KMG]: +* +* SRAT:|_| |_| |_| |_| .. +* node id:0 1 1 2 +* user specified:|__| |___| +* movablemem_map:|___| |_||__| .. +* +* Using movablemem_map, we can prevent memblock from allocating memory +* on ZONE_MOVABLE at boot time. +*/ + overlap = movablemem_map_overlap(start_pfn, end_pfn); + if (overlap >= 0) { + /* +* If part of this range is in movablemem_map, we need to +* add the range after it to extend the range to the end +* of the node, because from the min address specified to +* the end of the node will be ZONE_MOVABLE. +*/ + start_pfn = max(start_pfn, + movablemem_map.map[overlap].start_pfn); + insert_movablemem_map(start_pfn, end_pfn); + + /* +* Set the nodemask, so that if the address range on one node +* is not continuse, we can add the subsequent ranges on the +* same node into movablemem_map. +*/ + node_set(node, movablemem_map.numa_nodes_hotplug); + } else { + if (node_isset(node, movablemem_map.numa_nodes_hotplug)) + /* +* Insert the range if we already have movable ranges +* on the same node. +*/ + insert_movablemem_map(start_pfn, end_pfn); + } +#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ + return 0; } diff --git a/include/linux/mm.h b/include/linux/mm.h index 7cef651..e88077a 100644 ---
[PATCH 2/3] acpi, memory-hotplug: Extend movablemem_map ranges to the end of node.
When implementing movablemem_map boot option, we introduced an array movablemem_map.map[] to store the memory ranges to be set as ZONE_MOVABLE. Since ZONE_MOVABLE is the latst zone of a node, if user didn't specify the whole node memory range, we need to extend it to the node end so that we can use it to prevent memblock from allocating memory in the ranges user didn't specify. We now implement movablemem_map boot option like this: /* * For movablemem_map=nn[KMG]@ss[KMG]: * * SRAT:|_| |_| |_| |_| .. * node id:0 1 1 2 * user specified:|__| |___| * movablemem_map:|___| |_||__| .. * * Using movablemem_map, we can prevent memblock from allocating memory * on ZONE_MOVABLE at boot time. * * NOTE: In this case, SRAT info will be ingored. */ Signed-off-by: Tang Chen tangc...@cn.fujitsu.com --- arch/x86/mm/srat.c | 61 +-- include/linux/mm.h |5 mm/page_alloc.c| 34 +++- 3 files changed, 95 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/srat.c b/arch/x86/mm/srat.c index 4ddf497..f841d0e 100644 --- a/arch/x86/mm/srat.c +++ b/arch/x86/mm/srat.c @@ -141,11 +141,16 @@ static inline int save_add_info(void) {return 1;} static inline int save_add_info(void) {return 0;} #endif +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP +extern struct movablemem_map movablemem_map; +#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ + /* Callback for parsing of the Proximity Domain - Memory Area mappings */ int __init acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) { u64 start, end; + u32 hotpluggable; int node, pxm; if (srat_disabled()) @@ -157,8 +162,10 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) if ((ma-flags ACPI_SRAT_MEM_ENABLED) == 0) return -1; - if ((ma-flags ACPI_SRAT_MEM_HOT_PLUGGABLE) !save_add_info()) + hotpluggable = ma-flags ACPI_SRAT_MEM_HOT_PLUGGABLE; + if (hotpluggable !save_add_info()) return -1; + start = ma-base_address; end = start + ma-length; pxm = ma-proximity_domain; @@ -178,9 +185,57 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) node_set(node, numa_nodes_parsed); - printk(KERN_INFO SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n, + printk(KERN_INFO SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx] %s\n, node, pxm, - (unsigned long long) start, (unsigned long long) end - 1); + (unsigned long long) start, (unsigned long long) end - 1, + hotpluggable ? Hot Pluggable: ); + +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP + int overlap; + unsigned long start_pfn, end_pfn; + + start_pfn = PFN_DOWN(start); + end_pfn = PFN_UP(end); + + /* +* For movablecore_map=nn[KMG]@ss[KMG]: +* +* SRAT:|_| |_| |_| |_| .. +* node id:0 1 1 2 +* user specified:|__| |___| +* movablemem_map:|___| |_||__| .. +* +* Using movablemem_map, we can prevent memblock from allocating memory +* on ZONE_MOVABLE at boot time. +*/ + overlap = movablemem_map_overlap(start_pfn, end_pfn); + if (overlap = 0) { + /* +* If part of this range is in movablemem_map, we need to +* add the range after it to extend the range to the end +* of the node, because from the min address specified to +* the end of the node will be ZONE_MOVABLE. +*/ + start_pfn = max(start_pfn, + movablemem_map.map[overlap].start_pfn); + insert_movablemem_map(start_pfn, end_pfn); + + /* +* Set the nodemask, so that if the address range on one node +* is not continuse, we can add the subsequent ranges on the +* same node into movablemem_map. +*/ + node_set(node, movablemem_map.numa_nodes_hotplug); + } else { + if (node_isset(node, movablemem_map.numa_nodes_hotplug)) + /* +* Insert the range if we already have movable ranges +* on the same node. +*/ + insert_movablemem_map(start_pfn, end_pfn); + } +#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ + return 0; } diff --git a/include/linux/mm.h b/include/linux/mm.h index 7cef651..e88077a 100644 ---
Re: [PATCH 2/3] acpi, memory-hotplug: Extend movablemem_map ranges to the end of node.
On Fri, 25 Jan 2013 17:42:08 +0800 Tang Chen tangc...@cn.fujitsu.com wrote: When implementing movablemem_map boot option, we introduced an array movablemem_map.map[] to store the memory ranges to be set as ZONE_MOVABLE. Since ZONE_MOVABLE is the latst zone of a node, if user didn't specify the whole node memory range, we need to extend it to the node end so that we can use it to prevent memblock from allocating memory in the ranges user didn't specify. We now implement movablemem_map boot option like this: /* * For movablemem_map=nn[KMG]@ss[KMG]: * * SRAT:|_| |_| |_| |_| .. * node id:0 1 1 2 * user specified:|__| |___| * movablemem_map:|___| |_||__| .. * * Using movablemem_map, we can prevent memblock from allocating memory * on ZONE_MOVABLE at boot time. * * NOTE: In this case, SRAT info will be ingored. */ The patch generates a bunch of rejects, partly due to linux-next changes but I think I fixed everything up OK. index 4ddf497..f841d0e 100644 --- a/arch/x86/mm/srat.c +++ b/arch/x86/mm/srat.c @@ -141,11 +141,16 @@ static inline int save_add_info(void) {return 1;} static inline int save_add_info(void) {return 0;} #endif +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP +extern struct movablemem_map movablemem_map; +#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ Well. a) we shouldn't put extern declarations in C files - put them in headers so we can be assured that all compilation units agree on the type. b) the ifdefs are unneeded - a unused extern declaration is OK (as long as the type itself is always defined!) c) movablemem_map is already declared in memblock.h. So I zapped the above three lines. @@ -178,9 +185,57 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) node_set(node, numa_nodes_parsed); - printk(KERN_INFO SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n, + printk(KERN_INFO SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx] %s\n, node, pxm, -(unsigned long long) start, (unsigned long long) end - 1); +(unsigned long long) start, (unsigned long long) end - 1, +hotpluggable ? Hot Pluggable: ); + +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP + int overlap; + unsigned long start_pfn, end_pfn; no, we don't put declarations of locals in the middle of C statements like this: arch/x86/mm/srat.c: In function 'acpi_numa_memory_affinity_init': arch/x86/mm/srat.c:185: warning: ISO C90 forbids mixed declarations and code Did your compiler not emit this warning? I fixed this by moving the code into a new function handle_movablemem. Feel free to suggest a more appropriate name! From: Andrew Morton a...@linux-foundation.org Subject: acpi-memory-hotplug-extend-movablemem_map-ranges-to-the-end-of-node-fix clean up code, fix build warning Cc: Brown, Len len.br...@intel.com Cc: H. Peter Anvin h...@zytor.com Cc: Ingo Molnar mi...@elte.hu Cc: Jiang Liu jiang@huawei.com Cc: Jianguo Wu wujian...@huawei.com Cc: KOSAKI Motohiro kosaki.motoh...@jp.fujitsu.com Cc: Kamezawa Hiroyuki kamezawa.hir...@jp.fujitsu.com Cc: Lai Jiangshan la...@cn.fujitsu.com Cc: Len Brown l...@kernel.org Cc: Tang Chen tangc...@cn.fujitsu.com Cc: Thomas Gleixner t...@linutronix.de Cc: Wu Jianguo wujian...@huawei.com Cc: Yasuaki Ishimatsu isimatu.yasu...@jp.fujitsu.com Signed-off-by: Andrew Morton a...@linux-foundation.org --- arch/x86/mm/srat.c | 93 ++- 1 file changed, 49 insertions(+), 44 deletions(-) diff -puN arch/x86/mm/srat.c~acpi-memory-hotplug-extend-movablemem_map-ranges-to-the-end-of-node-fix arch/x86/mm/srat.c --- a/arch/x86/mm/srat.c~acpi-memory-hotplug-extend-movablemem_map-ranges-to-the-end-of-node-fix +++ a/arch/x86/mm/srat.c @@ -142,50 +142,8 @@ static inline int save_add_info(void) {r #endif #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP -extern struct movablemem_map movablemem_map; -#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ - -/* Callback for parsing of the Proximity Domain - Memory Area mappings */ -int __init -acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) +static void __init handle_movablemem(int node, u64 start, u64 end) { - u64 start, end; - u32 hotpluggable; - int node, pxm; - - if (srat_disabled()) - goto out_err; - if (ma-header.length != sizeof(struct acpi_srat_mem_affinity)) - goto out_err_bad_srat; - if ((ma-flags ACPI_SRAT_MEM_ENABLED) == 0) - goto out_err; - hotpluggable = ma-flags ACPI_SRAT_MEM_HOT_PLUGGABLE; - if (hotpluggable !save_add_info()) - goto out_err; - - start = ma-base_address; - end = start + ma-length; - pxm