From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx117.postini.com [74.125.245.117]) by kanga.kvack.org (Postfix) with SMTP id E2A866B0069 for ; Fri, 5 Apr 2013 05:37:24 -0400 (EDT) From: Tang Chen Subject: [PATCH 06/11] X86, numa, acpi, memory-hotplug: Add hotpluggable ranges to movablemem_map. Date: Fri, 5 Apr 2013 17:39:56 +0800 Message-Id: <1365154801-473-7-git-send-email-tangchen@cn.fujitsu.com> In-Reply-To: <1365154801-473-1-git-send-email-tangchen@cn.fujitsu.com> References: <1365154801-473-1-git-send-email-tangchen@cn.fujitsu.com> Sender: owner-linux-mm@kvack.org List-ID: To: rob@landley.net, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, yinghai@kernel.org, akpm@linux-foundation.org, wency@cn.fujitsu.com, trenn@suse.de, liwanp@linux.vnet.ibm.com, mgorman@suse.de, walken@google.com, riel@redhat.com, khlebnikov@openvz.org, tj@kernel.org, minchan@kernel.org, m.szyprowski@samsung.com, mina86@mina86.com, laijs@cn.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com, linfeng@cn.fujitsu.com, kosaki.motohiro@jp.fujitsu.com, jiang.liu@huawei.com, guz.fnst@cn.fujitsu.com Cc: x86@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org When parsing SRAT, we are able to know which memory ranges are hotpluggable, and we add them to movablemem_map. So movablemem_map could be used to prevent memblock from allocating memory in area which will be set as ZONE_MOVABLE later. Signed-off-by: Tang Chen --- arch/x86/mm/numa.c | 39 ++++++++++++++++++++++ include/linux/mm.h | 4 ++ mm/page_alloc.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+), 0 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 26d1800..73e7934 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -725,6 +725,43 @@ static void __init early_x86_numa_init_mapping(void) } #endif +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP +/** + * early_mem_hotplug_init - Add hotpluggable memory ranges to movablemem_map. + * + * This function scan numa_meminfo.blk[], and add all the hotpluggable memory + * ranges to movablemem_map. movablemem_map can be used to prevent memblock + * from allocating memory in area which will be set as ZONE_MOVABLE later, so + * this function should be called after memory mapping is initialized because + * we will put pagetable pages in local node even if the memory of that node is + * hotpluggable. + * + * If users specify movablemem_map=acpi, then: + * + * SRAT: |_____| |_____| |_________| |_________| ...... + * node id: 0 1 1 2 + * hotpluggable: n y y n + * movablemem_map: |_____| |_________| + */ +static void __init early_mem_hotplug_init() +{ + int i; + + if (!movablemem_map.acpi) + return; + + for (i = 0; i < numa_meminfo.nr_blks; i++) { + if (numa_meminfo.blk[i].hotpluggable) + movablemem_map_add_region(numa_meminfo.blk[i].start, + numa_meminfo.blk[i].end); + } +} +#else /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ +static inline void early_mem_hotplug_init() +{ +} +#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ + void __init early_initmem_init(void) { early_x86_numa_init(); @@ -734,6 +771,8 @@ void __init early_initmem_init(void) load_cr3(swapper_pg_dir); __flush_tlb_all(); + early_mem_hotplug_init(); + early_memtest(0, max_pfn_mapped<= ARRAY_SIZE(movablemem_map.map)) { + pr_err("movablemem_map: too many entries; " + "ignoring [mem %#010llx-%#010llx]\n", + (unsigned long long) start, + (unsigned long long) (start + size - 1)); + return; + } + + start_pfn = PFN_DOWN(start); + end_pfn = PFN_UP(start + size); + insert_movablemem_map(start_pfn, end_pfn); +} + +/** * cmdline_parse_movablemem_map - Parse boot option movablemem_map. * @p: The boot option of the following format: * movablemem_map=acpi -- 1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org