public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
	"H. Peter Anvin" <hpa@zytor.com>
Cc: Tejun Heo <tj@kernel.org>, David Rientjes <rientjes@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] x86, numa: refactoring numa_register_memblks
Date: Wed, 16 Feb 2011 12:58:41 -0800	[thread overview]
Message-ID: <4D5C3A81.4070408@kernel.org> (raw)
In-Reply-To: <4D5C3A0F.3080107@kernel.org>


Don't hide init_memory_mapping and setup_bootmem into that __register__ function

those are really work.

Also We don't need to scan two times for setup_node_bootmem() becase we
are using mapped memblock for node_data already.

let num_register_memblks only take care of register them into early_node_map[]

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 arch/x86/mm/numa_64.c |   47 ++++++++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 21 deletions(-)

Index: linux-2.6/arch/x86/mm/numa_64.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_64.c
+++ linux-2.6/arch/x86/mm/numa_64.c
@@ -491,7 +491,7 @@ static bool __init numa_meminfo_cover_me
 
 static int __init numa_register_memblks(struct numa_meminfo *mi)
 {
-	int i, j, nid;
+	int i;
 
 	/* Account for nodes with cpus and no memory */
 	node_possible_map = numa_nodes_parsed;
@@ -515,33 +515,34 @@ static int __init numa_register_memblks(
 	if (!numa_meminfo_cover_memory(mi))
 		return -EINVAL;
 
-	init_memory_mapping_high();
+	return 0;
+}
+
+static void __init setup_numa_bootmem(struct numa_meminfo *mi)
+{
+	int i, nid;
 
 	/*
-	 * Finally register nodes.  Do it twice in case setup_node_bootmem
-	 * missed one due to missing bootmem.
+	 * Do not do that twice, not needed!
+	 *   We are using mapped memblock directly for node data
 	 */
-	for (i = 0; i < 2; i++) {
-		for_each_node_mask(nid, node_possible_map) {
-			u64 start = (u64)max_pfn << PAGE_SHIFT;
-			u64 end = 0;
-
-			if (node_online(nid))
-				continue;
+	for_each_node_mask(nid, node_possible_map) {
+		u64 start = (u64)max_pfn << PAGE_SHIFT;
+		u64 end = 0;
 
-			for (j = 0; j < mi->nr_blks; j++) {
-				if (nid != mi->blk[j].nid)
-					continue;
-				start = min(mi->blk[j].start, start);
-				end = max(mi->blk[j].end, end);
-			}
+		if (node_online(nid))
+			continue;
 
-			if (start < end)
-				setup_node_bootmem(nid, start, end);
+		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);
 		}
-	}
 
-	return 0;
+		if (start < end)
+			setup_node_bootmem(nid, start, end);
+	}
 }
 
 #ifdef CONFIG_NUMA_EMU
@@ -968,6 +969,10 @@ void __init initmem_init(void)
 		if (numa_register_memblks(&numa_meminfo) < 0)
 			continue;
 
+		init_memory_mapping_high();
+
+		setup_numa_bootmem(&numa_meminfo);
+
 		for (j = 0; j < nr_cpu_ids; j++) {
 			int nid = early_cpu_to_node(j);
 

  parent reply	other threads:[~2011-02-16 20:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-16 20:56 [PATCH] x86, numa: exit early on numa_reset_distance() Yinghai Lu
2011-02-16 20:57 ` [PATCH] x86, numa: seperate alloc_numa_distance from numa_reset_distance Yinghai Lu
2011-02-16 21:44   ` Cyrill Gorcunov
2011-02-16 22:29     ` Yinghai Lu
2011-02-16 22:47       ` Cyrill Gorcunov
2011-02-16 22:51   ` Tejun Heo
2011-02-16 20:58 ` Yinghai Lu [this message]
2011-02-16 22:43   ` [PATCH] x86, numa: refactoring numa_register_memblks Tejun Heo
2011-02-16 22:53     ` Yinghai Lu
2011-02-16 23:03       ` Tejun Heo
2011-02-16 22:30 ` [PATCH] x86, numa: put dummy_numa_init in init section Yinghai Lu
2011-02-16 22:44   ` Tejun Heo
     [not found]     ` <20110217130526.GB27911@elte.hu>
     [not found]       ` <20110217132435.GV19830@htj.dyndns.org>
     [not found]         ` <20110217135628.GB7018@elte.hu>
     [not found]           ` <4D5D48DA.6020908@kernel.org>
     [not found]             ` <20110217161649.GD14168@elte.hu>
2011-02-24  7:21               ` [PATCH -v2] x86: Rename e820_table_* to pgt_buf_* Yinghai Lu
2011-02-24 13:59                 ` [PATCH] " Tejun Heo
2011-02-16 22:31 ` [PATCH] x86, numa: cleanup x86_acpi_numa_init() Yinghai Lu
2011-02-16 22:49   ` Tejun Heo
2011-02-16 22:55     ` Yinghai Lu
2011-02-16 22:39 ` [PATCH] x86, numa: exit early on numa_reset_distance() Tejun Heo
2011-02-16 23:08   ` Yinghai Lu
2011-02-16 23:15     ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D5C3A81.4070408@kernel.org \
    --to=yinghai@kernel.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rientjes@google.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox