Skip to contentSkip to conversation

Speed bootmem up for simulators

PATCH New Andi Kleen 1 participant 1 message Jan 30, 2002 Memory management

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 Speed bootmem up for simulators

Hi Linus,

This is a old patch from the x86-64 tree. It just optimizes the final memory freeing pass to be a bit more efficient. It probably doesn't make much difference on any CPU, but it is a big time win in a slow CPU simulator with huge memory where the freeing can take minutes sometimes.

It is just an obvious optimization for the freeing loop.

Patch against 2.5.3. Please apply.

Thanks,

-Andi

mm/bootmem.c renamed from mm/bootmem.c-BOOTMEM +13 -2
@@ -247,19 +247,30 @@
 	bootmem_data_t *bdata = pgdat->bdata;
 	unsigned long i, count, total = 0;
 	unsigned long idx;
+	unsigned long *map; 
 
 	if (!bdata->node_bootmem_map) BUG();
 
 	count = 0;
 	idx = bdata->node_low_pfn - (bdata->node_boot_start >> PAGE_SHIFT);
-	for (i = 0; i < idx; i++, page++) {
-		if (!test_bit(i, bdata->node_bootmem_map)) {
+	map = bdata->node_bootmem_map;
+	for (i = 0; i < idx; ) {
+		unsigned long v = ~map[i / BITS_PER_LONG];
+		if (v) { 
+			unsigned long m;
+			for (m = 1; m && i < idx; m<<=1, page++, i++) { 
+				if (v & m) {
 			count++;
 			ClearPageReserved(page);
 			set_page_count(page, 1);
 			__free_page(page);
 		}
 	}
+		} else {
+			i+=BITS_PER_LONG;
+			page+=BITS_PER_LONG; 
+		} 	
+	}	
 	total += count;
 
 	/*