linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] sparsemem base: teach discontig about sparse ranges
@ 2005-03-14 21:15 Dave Hansen
  0 siblings, 0 replies; only message in thread
From: Dave Hansen @ 2005-03-14 21:15 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Dave Hansen, apw

discontig.c has some assumptions that mem_map[]s inside of a node are
contiguous.  Teach it to make sure that each region that it's brining
online is actually made up of valid ranges of ram.

Written-by: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 memhotplug-dave/arch/i386/mm/discontig.c |   14 ++++++++++++++
 memhotplug-dave/arch/i386/mm/init.c      |    2 +-
 memhotplug-dave/include/asm-i386/page.h  |    2 ++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff -puN arch/i386/mm/discontig.c~B-sparse-075-validate-remap-pages arch/i386/mm/discontig.c
--- memhotplug/arch/i386/mm/discontig.c~B-sparse-075-validate-remap-pages	2005-03-14 10:57:45.000000000 -0800
+++ memhotplug-dave/arch/i386/mm/discontig.c	2005-03-14 10:57:46.000000000 -0800
@@ -185,6 +185,7 @@ static unsigned long calculate_numa_rema
 {
 	int nid;
 	unsigned long size, reserve_pages = 0;
+	unsigned long pfn;
 
 	for_each_online_node(nid) {
 		if (nid == 0)
@@ -208,6 +209,19 @@ static unsigned long calculate_numa_rema
 		size = (size + LARGE_PAGE_BYTES - 1) / LARGE_PAGE_BYTES;
 		/* now the roundup is correct, convert to PAGE_SIZE pages */
 		size = size * PTRS_PER_PTE;
+
+		/*
+		 * Validate the region we are allocating only contains valid
+		 * pages.
+		 */
+		for (pfn = node_end_pfn[nid] - size;
+		     pfn < node_end_pfn[nid]; pfn++)
+			if (!page_is_ram(pfn))
+				break;
+
+		if (pfn != node_end_pfn[nid])
+			size = 0;
+
 		printk("Reserving %ld pages of KVA for lmem_map of node %d\n",
 				size, nid);
 		node_remap_size[nid] = size;
diff -puN arch/i386/mm/init.c~B-sparse-075-validate-remap-pages arch/i386/mm/init.c
--- memhotplug/arch/i386/mm/init.c~B-sparse-075-validate-remap-pages	2005-03-14 10:57:46.000000000 -0800
+++ memhotplug-dave/arch/i386/mm/init.c	2005-03-14 10:57:46.000000000 -0800
@@ -191,7 +191,7 @@ static inline int page_kills_ppro(unsign
 
 extern int is_available_memory(efi_memory_desc_t *);
 
-static inline int page_is_ram(unsigned long pagenr)
+int page_is_ram(unsigned long pagenr)
 {
 	int i;
 	unsigned long addr, end;
diff -puN include/asm-i386/page.h~B-sparse-075-validate-remap-pages include/asm-i386/page.h
--- memhotplug/include/asm-i386/page.h~B-sparse-075-validate-remap-pages	2005-03-14 10:57:46.000000000 -0800
+++ memhotplug-dave/include/asm-i386/page.h	2005-03-14 10:57:46.000000000 -0800
@@ -119,6 +119,8 @@ static __inline__ int get_order(unsigned
 
 extern int sysctl_legacy_va_layout;
 
+extern int page_is_ram(unsigned long pagenr);
+
 #endif /* __ASSEMBLY__ */
 
 #ifdef __ASSEMBLY__
_
--
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: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-03-14 21:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-14 21:15 [PATCH 1/4] sparsemem base: teach discontig about sparse ranges Dave Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox