]> err.no Git - linux-2.6/commitdiff
mm, x86: shrink_active_range() should check all
authorYinghai Lu <yhlu.kernel@gmail.com>
Mon, 9 Jun 2008 02:39:16 +0000 (19:39 -0700)
committerIngo Molnar <mingo@elte.hu>
Tue, 10 Jun 2008 09:31:44 +0000 (11:31 +0200)
Now we are using 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.

So we need to make shrink_active_range() smarter.

shrink_active_range() is a generic MM function in mm/page_alloc.c but
it is only used on 32-bit x86. Should we move it back to some file in
arch/x86?

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/mm/discontig_32.c
include/linux/mm.h
mm/page_alloc.c

index a89ccf3d4c140195eab26940b8c971a0f22d69d5..489605bab85ad6c0636ba6c4d67ec8fe0133bb68 100644 (file)
@@ -282,7 +282,7 @@ static unsigned long calculate_numa_remap_pages(void)
 
                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 c31a9cd2a30e03a2672b8fa299c4d6a24a3fa186..7cbd949f25169036fdbbdb21c6b71eb0707297cf 100644 (file)
@@ -997,8 +997,7 @@ extern void free_area_init_node(int nid, pg_data_t *pgdat,
 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 502223c3c2c6dd9ed015bd5879823bdec34f782d..2154086840762d382574cba64c596751cbdd2eb3 100644 (file)
@@ -3579,25 +3579,49 @@ void __init add_active_range(unsigned int nid, unsigned long start_pfn,
 /**
  * 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++)
+                       memcpy(&early_node_map[j], &early_node_map[j+1],
+                               sizeof(early_node_map[j]));
+               j = nr_nodemap_entries - 1;
+               memset(&early_node_map[j], 0, sizeof(early_node_map[j]));
+               nr_nodemap_entries--;
+       }
 }
 
 /**