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: shrink pages should check all
Date: Fri, 6 Jun 2008 14:43:57 -0700 [thread overview]
Message-ID: <200806061443.57488.yhlu.kernel@gmail.com> (raw)
In-Reply-To: <200806031935.05202.yhlu.kernel@gmail.com>
we are uing register_e820_active_regions instead of add_active_range directly.
so end_pfn could be different between the value in early_node_map to node_end_pfn.
need to make shrink_active_range more smart.
shrink_active_range is only used x86 32 bit, or need to move back in some file
in arch/x86?
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Index: linux-2.6/arch/x86/mm/discontig_32.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/discontig_32.c
+++ linux-2.6/arch/x86/mm/discontig_32.c
@@ -279,7 +279,7 @@ static unsigned long calculate_numa_rema
node_end_pfn[nid] -= size;
node_remap_start_pfn[nid] = node_end_pfn[nid];
- shrink_active_range(nid, old_end_pfn, node_end_pfn[nid]);
+ shrink_active_range(nid, node_end_pfn[nid]);
}
printk("Reserving total of %ld pages for numa KVA remap\n",
reserve_pages);
Index: linux-2.6/include/linux/mm.h
===================================================================
--- linux-2.6.orig/include/linux/mm.h
+++ linux-2.6/include/linux/mm.h
@@ -997,8 +997,7 @@ extern void free_area_init_node(int nid,
extern void free_area_init_nodes(unsigned long *max_zone_pfn);
extern void add_active_range(unsigned int nid, unsigned long start_pfn,
unsigned long end_pfn);
-extern void shrink_active_range(unsigned int nid, unsigned long old_end_pfn,
- unsigned long new_end_pfn);
+extern void shrink_active_range(unsigned int nid, unsigned long new_end_pfn);
extern void push_node_boundaries(unsigned int nid, unsigned long start_pfn,
unsigned long end_pfn);
extern void remove_all_active_ranges(void);
Index: linux-2.6/mm/page_alloc.c
===================================================================
--- linux-2.6.orig/mm/page_alloc.c
+++ linux-2.6/mm/page_alloc.c
@@ -3592,25 +3592,51 @@ void __init add_active_range(unsigned in
/**
* shrink_active_range - Shrink an existing registered range of PFNs
* @nid: The node id the range is on that should be shrunk
- * @old_end_pfn: The old end PFN of the range
* @new_end_pfn: The new PFN of the range
*
* i386 with NUMA use alloc_remap() to store a node_mem_map on a local node.
- * The map is kept at the end physical page range that has already been
- * registered with add_active_range(). This function allows an arch to shrink
- * an existing registered range.
+ * The map is kept near the end physical page range that has already been
+ * registered. This function allows an arch to shrink an existing registered
+ * range.
*/
-void __init shrink_active_range(unsigned int nid, unsigned long old_end_pfn,
- unsigned long new_end_pfn)
+void __init shrink_active_range(unsigned int nid, unsigned long new_end_pfn)
{
- int i;
+ int i,j;
+ int removed = 0;
/* Find the old active region end and shrink */
- for_each_active_range_index_in_nid(i, nid)
- if (early_node_map[i].end_pfn == old_end_pfn) {
+ for_each_active_range_index_in_nid(i, nid) {
+ if (early_node_map[i].start_pfn >= new_end_pfn) {
+ /* clear it */
+ early_node_map[i].end_pfn = 0;
+ removed = 1;
+ continue;
+ }
+ if (early_node_map[i].end_pfn > new_end_pfn) {
early_node_map[i].end_pfn = new_end_pfn;
- break;
+ continue;
+ }
+ }
+
+ if (!removed)
+ return;
+
+ /* remove the blank ones */
+ for (i = nr_nodemap_entries - 1; i > 0; i--) {
+ if (early_node_map[i].nid != nid)
+ continue;
+ if (early_node_map[i].end_pfn)
+ continue;
+ /* we found it, get rid of it */
+ for (j = i; j < nr_nodemap_entries - 1; j++) {
+ early_node_map[j].nid = early_node_map[j+1].nid;
+ early_node_map[j].start_pfn = early_node_map[j+1].start_pfn;
+ early_node_map[j].end_pfn = early_node_map[j+1].end_pfn;
}
+ j = nr_nodemap_entries - 1;
+ memset(&early_node_map[j], 0, sizeof(early_node_map[j]));
+ nr_nodemap_entries--;
+ }
}
/**
next prev parent reply other threads:[~2008-06-06 21:44 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 ` [PATCH] x86: numa32 make sure get kva space Yinghai Lu
2008-06-04 10:26 ` 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 ` Yinghai Lu [this message]
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=200806061443.57488.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).