]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - mm/bootmem.c
mm: fix free_all_bootmem_core alignment check
[linux-2.6-omap-h63xx.git] / mm / bootmem.c
index e8fb927392b9ac02b4ad16878847551d103a1b43..319a79bce7cd5e23314a91aca0fa87701934f7fe 100644 (file)
@@ -36,6 +36,8 @@ static LIST_HEAD(bdata_list);
 unsigned long saved_max_pfn;
 #endif
 
+bootmem_data_t bootmem_node_data[MAX_NUMNODES] __initdata;
+
 /* return the number of _pages_ that will be allocated for the boot bitmap */
 unsigned long __init bootmem_bootmap_pages(unsigned long pages)
 {
@@ -91,6 +93,7 @@ static unsigned long __init init_bootmem_core(pg_data_t *pgdat,
        bootmem_data_t *bdata = pgdat->bdata;
        unsigned long mapsize;
 
+       mminit_validate_memmodel_limits(&start, &end);
        bdata->node_bootmem_map = phys_to_virt(PFN_PHYS(mapstart));
        bdata->node_boot_start = PFN_PHYS(start);
        bdata->node_low_pfn = end;
@@ -374,7 +377,7 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat)
        struct page *page;
        unsigned long pfn;
        bootmem_data_t *bdata = pgdat->bdata;
-       unsigned long i, count, total = 0;
+       unsigned long i, count;
        unsigned long idx;
        unsigned long *map; 
        int gofast = 0;
@@ -386,10 +389,13 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat)
        pfn = PFN_DOWN(bdata->node_boot_start);
        idx = bdata->node_low_pfn - pfn;
        map = bdata->node_bootmem_map;
-       /* Check physaddr is O(LOG2(BITS_PER_LONG)) page aligned */
-       if (bdata->node_boot_start == 0 ||
-           ffs(bdata->node_boot_start) - PAGE_SHIFT > ffs(BITS_PER_LONG))
+       /*
+        * Check if we are aligned to BITS_PER_LONG pages.  If so, we might
+        * be able to free page orders of that size at once.
+        */
+       if (!(pfn & (BITS_PER_LONG-1)))
                gofast = 1;
+
        for (i = 0; i < idx; ) {
                unsigned long v = ~map[i / BITS_PER_LONG];
 
@@ -417,23 +423,19 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat)
                }
                pfn += BITS_PER_LONG;
        }
-       total += count;
 
        /*
         * Now free the allocator bitmap itself, it's not
         * needed anymore:
         */
        page = virt_to_page(bdata->node_bootmem_map);
-       count = 0;
        idx = (get_mapsize(bdata) + PAGE_SIZE-1) >> PAGE_SHIFT;
-       for (i = 0; i < idx; i++, page++) {
+       for (i = 0; i < idx; i++, page++)
                __free_pages_bootmem(page, 0);
-               count++;
-       }
-       total += count;
+       count += i;
        bdata->node_bootmem_map = NULL;
 
-       return total;
+       return count;
 }
 
 unsigned long __init init_bootmem_node(pg_data_t *pgdat, unsigned long freepfn,
@@ -442,15 +444,17 @@ unsigned long __init init_bootmem_node(pg_data_t *pgdat, unsigned long freepfn,
        return init_bootmem_core(pgdat, freepfn, startpfn, endpfn);
 }
 
-void __init reserve_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
+int __init reserve_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
                                 unsigned long size, int flags)
 {
        int ret;
 
        ret = can_reserve_bootmem_core(pgdat->bdata, physaddr, size, flags);
        if (ret < 0)
-               return;
+               return -ENOMEM;
        reserve_bootmem_core(pgdat->bdata, physaddr, size, flags);
+
+       return 0;
 }
 
 void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,