[PATCH] Speed bootmem up for simulators

From: Andi Kleen (ak@muc.de)
Date: Wed Jan 30 2002 - 18:35:07 EST


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

--- linux-2.5.3-work/mm/bootmem.c-BOOTMEM Tue Jan 15 17:53:36 2002
+++ linux-2.5.3-work/mm/bootmem.c Wed Jan 30 23:21:35 2002
@@ -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;
 
         /*
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jan 31 2002 - 21:01:27 EST