Skip to contentSkip to conversation

# x86/mpparse: cc1a9d8: mm, x86: shrink_active_range() should check all

PATCH Ingo Molnar 1 participant 1 message Jun 13, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Andrew,

this is a FYI about ongoing work on 32-bit NUMA loose ends by Yinghai Lu (which has been sub-par for an eternity). The commits below are in tip/x86/mpparse and they touch mm/page_alloc.c's shrink_active_range() function.

This is an API that is only used by x86 - we could move it to arch/x86 but i think it makes general sense so it's fine in mm/page_alloc.c. It should not impact any other MM work in a material way. Would be nice to carry these changes in x86/mpparse - they are still being tested.

Can you see any problem with these commits and the approach?

Ingo

--------------------->

# x86/mpparse: e8c27ac: x86, numa, 32-bit: print out debug info on all kvas

Quoted 1 line

From e8c27ac9191ab9e6506ae5cbe70d87ac50f8e960 Mon Sep 17 00:00:00 2001

From: Yinghai Lu <[email protected]>
Date: Sun, 1 Jun 2008 13:15:22 -0700
Subject: [PATCH] x86, numa, 32-bit: print out debug info on all kvas

also fix the print out of node_remap_end_vaddr

mm/page_alloc.c +5 -0
index 6383557..502223c 100644
@@ -3486,6 +3486,11 @@ void __paginginit free_area_init_node(int nid, struct pglist_data *pgdat,
 	calculate_node_totalpages(pgdat, zones_size, zholes_size);
 
 	alloc_node_mem_map(pgdat);
+#ifdef CONFIG_FLAT_NODE_MEM_MAP
+	printk(KERN_DEBUG "free_area_init_node: node %d, pgdat %08lx, node_mem_map %08lx\n",
+		nid, (unsigned long)pgdat,
+		(unsigned long)pgdat->node_mem_map);
+#endif
 
 	free_area_init_core(pgdat, zones_size, zholes_size);
 }

# x86/mpparse: cc1a9d8: mm, x86: shrink_active_range() should check all

Quoted 1 line

From cc1a9d86ce989083703c4bdc11b75a87e1cc404a Mon Sep 17 00:00:00 2001

From: Yinghai Lu <[email protected]>
Date: Sun, 8 Jun 2008 19:39:16 -0700
Subject: [PATCH] mm, x86: shrink_active_range() should check all

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?

mm/page_alloc.c +34 -10

59 lines not on this page · raw message

# x86/mpparse: 4937fa9: x86: replace shrink pages with remove_active_ranges

Quoted 1 line

From 4937fa962cb6eed0909de0ee5dbf41396e8b8ca6 Mon Sep 17 00:00:00 2001

From: Yinghai Lu <[email protected]>
Date: Thu, 12 Jun 2008 13:05:38 -0700
Subject: [PATCH] x86: replace shrink pages with remove_active_ranges

in case we have kva before ramdisk on node, we still need to use those ranges.

This fixes 32-bit NUMA crashes with less than 960 MB of RAM.

mm/page_alloc.c +20 -6
index 2154086..e35ad52 100644
@@ -3577,30 +3577,44 @@ void __init add_active_range(unsigned int nid, unsigned long start_pfn,
 }
 
 /**
- * shrink_active_range - Shrink an existing registered range of PFNs
+ * remove_active_range - Shrink an existing registered range of PFNs
  * @nid: The node id the range is on that should be shrunk
- * @new_end_pfn: The new PFN of the range
+ * @start_pfn: The new PFN of the range
+ * @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 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 new_end_pfn)
+void __init remove_active_range(unsigned int nid, unsigned long start_pfn,
+				unsigned long end_pfn)
 {
 	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].start_pfn >= new_end_pfn) {
+		if (early_node_map[i].start_pfn >= start_pfn &&
+		    early_node_map[i].end_pfn <= end_pfn) {
 			/* clear it */
+			early_node_map[i].start_pfn = 0;
 			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;
+		if (early_node_map[i].start_pfn < start_pfn &&
+		    early_node_map[i].end_pfn > start_pfn) {
+			unsigned long temp_end_pfn = early_node_map[i].end_pfn;
+			early_node_map[i].end_pfn = start_pfn;
+			if (temp_end_pfn > end_pfn)
+				add_active_range(nid, end_pfn, temp_end_pfn);
+			continue;
+		}
+		if (early_node_map[i].start_pfn >= start_pfn &&
+		    early_node_map[i].end_pfn > end_pfn &&
+		    early_node_map[i].start_pfn < end_pfn) {
+			early_node_map[i].start_pfn = end_pfn;
 			continue;
 		}
 	}