patch-2.3.99-pre4 linux/mm/page_alloc.c

Next file: linux/mm/slab.c
Previous file: linux/mm/numa.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre3/linux/mm/page_alloc.c linux/mm/page_alloc.c
@@ -100,12 +100,16 @@
 
 	if (page->buffers)
 		BUG();
+	if (page->mapping)
+		BUG();
 	if (page-mem_map >= max_mapnr)
 		BUG();
 	if (PageSwapCache(page))
 		BUG();
 	if (PageLocked(page))
 		BUG();
+	if (PageDecrAfter(page))
+		BUG();
 
 	zone = page->zone;
 
@@ -487,12 +491,13 @@
  *   - clear the memory bitmaps
  */
 void __init free_area_init_core(int nid, pg_data_t *pgdat, struct page **gmap,
-	unsigned long *zones_size, unsigned long zone_start_paddr)
+	unsigned long *zones_size, unsigned long zone_start_paddr, 
+	unsigned long *zholes_size)
 {
 	struct page *p, *lmem_map;
 	unsigned long i, j;
 	unsigned long map_size;
-	unsigned long totalpages, offset;
+	unsigned long totalpages, offset, realtotalpages;
 	unsigned int cumulative = 0;
 
 	pgdat->node_next = pgdat_list;
@@ -503,7 +508,12 @@
 		unsigned long size = zones_size[i];
 		totalpages += size;
 	}
-	printk("On node %d totalpages: %lu\n", nid, totalpages);
+	realtotalpages = totalpages;
+	if (zholes_size)
+		for (i = 0; i < MAX_NR_ZONES; i++)
+			realtotalpages -= zholes_size[i];
+			
+	printk("On node %d totalpages: %lu\n", nid, realtotalpages);
 
 	/*
 	 * Select nr of pages we try to keep free for important stuff
@@ -512,7 +522,7 @@
 	 * This is fairly arbitrary, but based on some behaviour
 	 * analysis.
 	 */
-	i = totalpages >> 7;
+	i = realtotalpages >> 7;
 	if (i < 10)
 		i = 10;
 	if (i > 256)
@@ -553,21 +563,24 @@
 	for (j = 0; j < MAX_NR_ZONES; j++) {
 		zone_t *zone = pgdat->node_zones + j;
 		unsigned long mask;
-		unsigned long size;
+		unsigned long size, realsize;
 
-		size = zones_size[j];
+		realsize = size = zones_size[j];
+		if (zholes_size)
+			realsize -= zholes_size[j];
 
 		printk("zone(%lu): %lu pages.\n", j, size);
 		zone->size = size;
 		zone->name = zone_names[j];
 		zone->lock = SPIN_LOCK_UNLOCKED;
 		zone->zone_pgdat = pgdat;
+		zone->free_pages = 0;
 		if (!size)
 			continue;
 
 		zone->offset = offset;
 		cumulative += size;
-		mask = (size / zone_balance_ratio[j]);
+		mask = (realsize / zone_balance_ratio[j]);
 		if (mask < zone_balance_min[j])
 			mask = zone_balance_min[j];
 		else if (mask > zone_balance_max[j])
@@ -611,7 +624,7 @@
 
 void __init free_area_init(unsigned long *zones_size)
 {
-	free_area_init_core(0, NODE_DATA(0), &mem_map, zones_size, 0);
+	free_area_init_core(0, NODE_DATA(0), &mem_map, zones_size, 0, 0);
 }
 
 static int __init setup_mem_frac(char *str)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)