public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Mannthey <kmannth@us.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org, discuss@x86-64.org,
	Keith Mannthey <kmannth@us.ibm.com>,
	ak@suse.de, lhms-devel@lists.sourceforge.net,
	kamezawa.hiroyu@jp.fujitsu.com
Subject: [PATCH 4/10] hot-add-mem x86_64: Enable SPARSEMEM in srat.c
Date: Fri, 4 Aug 2006 07:14:09 -0600	[thread overview]
Message-ID: <20060804131409.21401.58904.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20060804131351.21401.4877.sendpatchset@localhost.localdomain>

From: Keith Mannthey <kmannth@us.ibm.com>

 Enable x86_64 srat.c to share code between both reserve and sparsemem based add memory
paths.  Both paths need the hot-add area node locality infomration (nodes_add).  This 
code refactors the code path to allow this. 

Signed-off-by: Keith Mannthey<kmannth@us.ibm.com>
---
 srat.c |   51 +++++++++++++++++++++++++++++----------------------
 1 files changed, 29 insertions(+), 22 deletions(-)

Files orig/arch/x86_64/mm/.srat.c.swp and current/arch/x86_64/mm/.srat.c.swp differ
diff -urN orig/arch/x86_64/mm/srat.c current/arch/x86_64/mm/srat.c
--- orig/arch/x86_64/mm/srat.c	2006-08-04 00:41:17.000000000 -0400
+++ current/arch/x86_64/mm/srat.c	2006-08-04 01:02:25.000000000 -0400
@@ -21,12 +21,6 @@
 #include <asm/numa.h>
 #include <asm/e820.h>
 
-#if (defined(CONFIG_ACPI_HOTPLUG_MEMORY) || \
-	defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)) \
-		&& !defined(CONFIG_MEMORY_HOTPLUG)
-#define RESERVE_HOTADD 1
-#endif
-
 static struct acpi_table_slit *acpi_slit;
 
 static nodemask_t nodes_parsed __initdata;
@@ -34,9 +28,6 @@
 static struct bootnode nodes_add[MAX_NUMNODES] __initdata;
 static int found_add_area __initdata;
 int hotadd_percent __initdata = 0;
-#ifndef RESERVE_HOTADD
-#define hotadd_percent 0	/* Ignore all settings */
-#endif
 
 /* Too small nodes confuse the VM badly. Usually they result
    from BIOS bugs. */
@@ -157,7 +148,7 @@
 	       pxm, pa->apic_id, node);
 }
 
-#ifdef RESERVE_HOTADD
+#ifdef CONFIG_MEMORY_HOTPLUG_RESERVE
 /*
  * Protect against too large hotadd areas that would fill up memory.
  */
@@ -200,15 +191,37 @@
 	return 1;
 }
 
+static int update_end_of_memory(unsigned long end)
+{
+	found_add_area = 1;
+	if ((end >> PAGE_SHIFT) > end_pfn)
+		end_pfn = end >> PAGE_SHIFT;
+	return 1;
+}
+
+static inline int save_add_info(void)
+{
+	return hotadd_percent > 0;
+}
+#else
+int update_end_of_memory(unsigned long end) {return 0;}
+static int hotadd_enough_memory(struct bootnode *nd) {return 1;}
+#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
+static inline int save_add_info(void) {return 1;}
+#else
+static inline int save_add_info(void) {return 0;}
+#endif 
+#endif 
 /*
- * It is fine to add this area to the nodes data it will be used later
+ * Update nodes_add and decide if to include add are in the zone.  
+ * Both SPARSE and RESERVE need nodes_add infomation.
  * This code supports one contigious hot add area per node.
  */
 static int reserve_hotadd(int node, unsigned long start, unsigned long end)
 {
 	unsigned long s_pfn = start >> PAGE_SHIFT;
 	unsigned long e_pfn = end >> PAGE_SHIFT;
-	int changed = 0;
+	int ret = 0, changed = 0;
 	struct bootnode *nd = &nodes_add[node];
 
 	/* I had some trouble with strange memory hotadd regions breaking
@@ -235,7 +248,6 @@
 
 	/* Looks good */
 
- 	found_add_area = 1;
 	if (nd->start == nd->end) {
  		nd->start = start;
  		nd->end = end;
@@ -253,14 +265,12 @@
 			printk(KERN_ERR "SRAT: Hotplug zone not continuous. Partly ignored\n");
  	}
 
- 	if ((nd->end >> PAGE_SHIFT) > end_pfn)
- 		end_pfn = nd->end >> PAGE_SHIFT;
+	ret = update_end_of_memory(nd->end);
 
 	if (changed)
 	 	printk(KERN_INFO "SRAT: hot plug zone found %Lx - %Lx\n", nd->start, nd->end);
-	return 0;
+	return ret;
 }
-#endif
 
 /* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
 void __init
@@ -279,7 +289,7 @@
 	}
 	if (ma->flags.enabled == 0)
 		return;
- 	if (ma->flags.hot_pluggable && hotadd_percent == 0)
+ 	if (ma->flags.hot_pluggable && !save_add_info())
 		return;
 	start = ma->base_addr_lo | ((u64)ma->base_addr_hi << 32);
 	end = start + (ma->length_lo | ((u64)ma->length_hi << 32));
@@ -318,15 +328,13 @@
 	printk(KERN_INFO "SRAT: Node %u PXM %u %Lx-%Lx\n", node, pxm,
 	       nd->start, nd->end);
 
-#ifdef RESERVE_HOTADD
- 	if (ma->flags.hot_pluggable && reserve_hotadd(node, start, end) < 0) {
+ 	if (ma->flags.hot_pluggable && !reserve_hotadd(node, start, end) < 0) {
 		/* Ignore hotadd region. Undo damage */
 		printk(KERN_NOTICE "SRAT: Hotplug region ignored\n");
 		*nd = oldnode;
 		if ((nd->start | nd->end) == 0)
 			node_clear(node, nodes_parsed);
 	}
-#endif
 }
 
 /* Sanity check to catch more bad SRATs (they are amazingly common).
@@ -342,7 +350,6 @@
 		unsigned long e = nodes[i].end >> PAGE_SHIFT;
 		pxmram += e - s;
 		pxmram -= e820_hole_size(s, e);
-		pxmram -= nodes_add[i].end - nodes_add[i].start;
 		if ((long)pxmram < 0)
 			pxmram = 0;
 	}

  parent reply	other threads:[~2006-08-04 13:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-04 13:13 [PATCH 1/10] hot-add-mem x86_64: acpi motherboard fix Keith Mannthey
2006-08-04 13:13 ` [PATCH 2/10] hot-add-mem x86_64: fixup externs Keith Mannthey
2006-08-04 13:14 ` [PATCH 3/10] hot-add-mem x86_64: Kconfig changes Keith Mannthey
2006-08-04 13:14 ` Keith Mannthey [this message]
2006-08-04 15:17   ` [Lhms-devel] [PATCH 4/10] hot-add-mem x86_64: Enable SPARSEMEM in srat.c Mika Penttilä
2006-08-04 19:36     ` keith mannthey
2006-08-04 17:42   ` Dave Hansen
2006-08-04 13:14 ` [PATCH 5/10] hot-add-mem x86_64: memory_add_physaddr_to_nid enable Keith Mannthey
2006-08-04 13:14 ` [PATCH 7/10] hot-add-mem x86_64: x86_64 kernel mapping fix Keith Mannthey
2006-08-04 13:14 ` [PATCH 8/10] hot-add-mem x86_64: use CONFIG_MEMORY_HOTPLUG_SPARSE Keith Mannthey
2006-08-04 13:14 ` [PATCH 9/10] hot-add-mem x86_64: use CONFIG_MEMORY_HOTPLUG_RESERVE Keith Mannthey
2006-08-07 17:41   ` keith mannthey
2006-08-04 13:14 ` [PATCH 10/10] hot-add-mem x86_64: valid add range check Keith Mannthey
2006-08-05  5:39 ` [PATCH 1/10] hot-add-mem x86_64: acpi motherboard fix KAMEZAWA Hiroyuki
2006-08-05  5:51 ` KAMEZAWA Hiroyuki
2006-08-07 18:39   ` keith mannthey
2006-08-08  0:31     ` [Lhms-devel] " KAMEZAWA Hiroyuki
2006-08-08  0:56       ` keith mannthey
2006-08-08  2:08         ` KAMEZAWA Hiroyuki
2006-08-08  2:15           ` keith mannthey

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=20060804131409.21401.58904.sendpatchset@localhost.localdomain \
    --to=kmannth@us.ibm.com \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=discuss@x86-64.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=lhms-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.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