Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754077Ab3FNVgA (ORCPT ); Fri, 14 Jun 2013 17:36:00 -0400 Received: from terminus.zytor.com ([198.137.202.10]:34447 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754002Ab3FNVcZ (ORCPT ); Fri, 14 Jun 2013 17:32:25 -0400 Date: Fri, 14 Jun 2013 14:32:14 -0700 From: tip-bot for Yinghai Lu Message-ID: Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org, yinghai@kernel.org, tangchen@cn.fujitsu.com, tglx@linutronix.de, hpa@linux.intel.com Reply-To: mingo@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, yinghai@kernel.org, tangchen@cn.fujitsu.com, tglx@linutronix.de, hpa@linux.intel.com In-Reply-To: <1371128589-8953-11-git-send-email-tangchen@cn.fujitsu.com> References: <1371128589-8953-11-git-send-email-tangchen@cn.fujitsu.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] x86, mm, numa: Move two functions calling on successful path later Git-Commit-ID: f5127d18677d45bdd17bb3d34e21c2a3f6b0eef6 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (terminus.zytor.com [127.0.0.1]); Fri, 14 Jun 2013 14:32:20 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4866 Lines: 161 Commit-ID: f5127d18677d45bdd17bb3d34e21c2a3f6b0eef6 Gitweb: http://git.kernel.org/tip/f5127d18677d45bdd17bb3d34e21c2a3f6b0eef6 Author: Yinghai Lu AuthorDate: Thu, 13 Jun 2013 21:02:57 +0800 Committer: H. Peter Anvin CommitDate: Fri, 14 Jun 2013 14:04:53 -0700 x86, mm, numa: Move two functions calling on successful path later We need to have numa info ready before init_mem_mappingi(), so that we can call init_mem_mapping per node, and alse trim node memory ranges to big alignment. Currently, parsing numa info needs to allocate some buffer and need to be called after init_mem_mapping. So try to split parsing numa info procedure into two steps: - The first step will be called before init_mem_mapping, and it should not need allocate buffers. - The second step will cantain all the buffer related code and be executed later. At last we will have early_initmem_init() and initmem_init(). This patch implements only the first step. setup_node_data() and numa_init_array() are only called for successful path, so we can move these two callings to x86_numa_init(). That will also make numa_init() smaller and more readable. -v2: remove online_node_map clear in numa_init(), as it is only set in setup_node_data() at last in successful path. Signed-off-by: Yinghai Lu Link: http://lkml.kernel.org/r/1371128589-8953-11-git-send-email-tangchen@cn.fujitsu.com Reviewed-by: Tang Chen Tested-by: Tang Chen Signed-off-by: H. Peter Anvin --- arch/x86/mm/numa.c | 69 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index a71c4e2..07ae800 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -477,7 +477,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi) static int __init numa_register_memblks(struct numa_meminfo *mi) { unsigned long uninitialized_var(pfn_align); - int i, nid; + int i; /* Account for nodes with cpus and no memory */ node_possible_map = numa_nodes_parsed; @@ -506,24 +506,6 @@ static int __init numa_register_memblks(struct numa_meminfo *mi) if (!numa_meminfo_cover_memory(mi)) return -EINVAL; - /* Finally register nodes. */ - for_each_node_mask(nid, node_possible_map) { - u64 start = PFN_PHYS(max_pfn); - u64 end = 0; - - for (i = 0; i < mi->nr_blks; i++) { - if (nid != mi->blk[i].nid) - continue; - start = min(mi->blk[i].start, start); - end = max(mi->blk[i].end, end); - } - - if (start < end) - setup_node_data(nid, start, end); - } - - /* Dump memblock with node info and return. */ - memblock_dump_all(); return 0; } @@ -559,7 +541,6 @@ static int __init numa_init(int (*init_func)(void)) nodes_clear(numa_nodes_parsed); nodes_clear(node_possible_map); - nodes_clear(node_online_map); memset(&numa_meminfo, 0, sizeof(numa_meminfo)); WARN_ON(memblock_set_node(0, ULLONG_MAX, MAX_NUMNODES)); numa_reset_distance(); @@ -577,15 +558,6 @@ static int __init numa_init(int (*init_func)(void)) if (ret < 0) return ret; - for (i = 0; i < nr_cpu_ids; i++) { - int nid = early_cpu_to_node(i); - - if (nid == NUMA_NO_NODE) - continue; - if (!node_online(nid)) - numa_clear_node(i); - } - numa_init_array(); return 0; } @@ -618,7 +590,7 @@ static int __init dummy_numa_init(void) * last fallback is dummy single node config encomapssing whole memory and * never fails. */ -void __init x86_numa_init(void) +static void __init early_x86_numa_init(void) { if (!numa_off) { #ifdef CONFIG_X86_NUMAQ @@ -638,6 +610,43 @@ void __init x86_numa_init(void) numa_init(dummy_numa_init); } +void __init x86_numa_init(void) +{ + int i, nid; + struct numa_meminfo *mi = &numa_meminfo; + + early_x86_numa_init(); + + /* Finally register nodes. */ + for_each_node_mask(nid, node_possible_map) { + u64 start = PFN_PHYS(max_pfn); + u64 end = 0; + + for (i = 0; i < mi->nr_blks; i++) { + if (nid != mi->blk[i].nid) + continue; + start = min(mi->blk[i].start, start); + end = max(mi->blk[i].end, end); + } + + if (start < end) + setup_node_data(nid, start, end); /* online is set */ + } + + /* Dump memblock with node info */ + memblock_dump_all(); + + for (i = 0; i < nr_cpu_ids; i++) { + int nid = early_cpu_to_node(i); + + if (nid == NUMA_NO_NODE) + continue; + if (!node_online(nid)) + numa_clear_node(i); + } + numa_init_array(); +} + static __init int find_near_online_node(int node) { int n, val; -- 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/