All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yhlu.kernel@gmail.com>
To: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] x86: numa32 make sure get kva space
Date: Tue, 3 Jun 2008 19:32:30 -0700	[thread overview]
Message-ID: <200806031932.31376.yhlu.kernel@gmail.com> (raw)
In-Reply-To: <200806031025.55026.yhlu.kernel@gmail.com>


when 1/3 user/kernel is used, and less memory is installed, or have big hole
below 4g, max_low_pfn is still using 3g-128m

try to go down from max_low_pfn until get it. otherwise will panic.

need to make 32bit code to use register_e820_active_regions...later

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

diff --git a/arch/x86/mm/discontig_32.c b/arch/x86/mm/discontig_32.c
index e119c53..e8d9a0a 100644
--- a/arch/x86/mm/discontig_32.c
+++ b/arch/x86/mm/discontig_32.c
@@ -306,6 +306,7 @@ unsigned long __init setup_memory(void)
 {
 	int nid;
 	unsigned long system_start_pfn, system_max_low_pfn;
+	long kva_target_pfn;
 
 	/*
 	 * When mapping a NUMA machine we allocate the node_mem_map arrays
@@ -322,11 +323,17 @@ unsigned long __init setup_memory(void)
 	system_start_pfn = min_low_pfn = PFN_UP(init_pg_tables_end);
 
 	system_max_low_pfn = max_low_pfn = find_max_low_pfn();
-	kva_start_pfn = round_down(max_low_pfn - kva_pages, PTRS_PER_PTE);
-	kva_start_pfn = find_e820_area(kva_start_pfn<<PAGE_SHIFT,
-				max_low_pfn<<PAGE_SHIFT,
-				kva_pages<<PAGE_SHIFT,
-				PTRS_PER_PTE<<PAGE_SHIFT) >> PAGE_SHIFT;
+	kva_target_pfn = round_down(max_low_pfn - kva_pages, PTRS_PER_PTE);
+	do {
+		kva_start_pfn = find_e820_area(kva_target_pfn<<PAGE_SHIFT,
+					max_low_pfn<<PAGE_SHIFT,
+					kva_pages<<PAGE_SHIFT,
+					PTRS_PER_PTE<<PAGE_SHIFT) >> PAGE_SHIFT;
+		kva_target_pfn -= PTRS_PER_PTE;
+	} while (kva_start_pfn == -1UL && kva_target_pfn > min_low_pfn);
+
+	if (kva_start_pfn == -1UL)
+		panic("Can not get kva space\n");
 
 	printk("kva_start_pfn ~ %ld find_max_low_pfn() ~ %ld\n",
 		kva_start_pfn, max_low_pfn);

  reply	other threads:[~2008-06-04  2:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-03 17:25 [PATCH] x86: early check if one system is numaq v2 Yinghai Lu
2008-06-04  2:32 ` Yinghai Lu [this message]
2008-06-04 10:26   ` [PATCH] x86: numa32 make sure get kva space Ingo Molnar
2008-06-04  2:34 ` [PATCH] x86: move e820_register_active to e820.c Yinghai Lu
2008-06-04  2:35   ` [PATCH] x86: 32 bit use e820_register_active_regions Yinghai Lu
2008-06-04  7:39     ` [PATCH] x86: e820 merge parse mem/memmap Yinghai Lu
2008-06-04 10:27     ` [PATCH] x86: 32 bit use e820_register_active_regions Ingo Molnar
2008-06-04 20:21     ` [PATCH] x86: e820 max_arch_pfn typo fix for 64 bit Yinghai Lu
2008-06-04 22:47       ` H. Peter Anvin
2008-06-06 21:43     ` [PATCH] x86: shrink pages should check all Yinghai Lu
2008-06-07  1:53       ` [PATCH] x86: numa32 use find_e820_area to find KVA ram on node Yinghai Lu
2008-06-10  9:53         ` Ingo Molnar
2008-06-07  1:54       ` [PATCH] x86: fix fail with 64g above system with numa32 Yinghai Lu
2008-06-10  9:53         ` Ingo Molnar
2008-06-09  2:39       ` [PATCH] x86: shrink pages should check all v2 Yinghai Lu
2008-06-09 10:15         ` Ingo Molnar
2008-06-10 19:55     ` [PATCH] x86: e820 merge parse mem/memmap Yinghai Lu
2008-06-04 10:26   ` [PATCH] x86: move e820_register_active to e820.c Ingo Molnar
2008-06-04 10:25 ` [PATCH] x86: early check if one system is numaq v2 Ingo Molnar

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=200806031932.31376.yhlu.kernel@gmail.com \
    --to=yhlu.kernel@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.