Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161640Ab3DEJje (ORCPT ); Fri, 5 Apr 2013 05:39:34 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:56998 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1161341Ab3DEJhU (ORCPT ); Fri, 5 Apr 2013 05:37:20 -0400 X-IronPort-AV: E=Sophos;i="4.87,413,1363104000"; d="scan'208";a="7001887" From: Tang Chen 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 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> X-Mailer: git-send-email 1.7.10.1 In-Reply-To: <1365154801-473-1-git-send-email-tangchen@cn.fujitsu.com> References: <1365154801-473-1-git-send-email-tangchen@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/04/05 17:36:10, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/04/05 17:36:12, Serialize complete at 2013/04/05 17:36:12 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6292 Lines: 194 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/