VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / mm / bootmem.c
index 6eb3f1e..966135b 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/mmzone.h>
+#include <linux/module.h>
 #include <asm/dma.h>
 #include <asm/io.h>
 
@@ -27,6 +28,10 @@ unsigned long max_low_pfn;
 unsigned long min_low_pfn;
 unsigned long max_pfn;
 
+EXPORT_SYMBOL(max_pfn);                /* This is exported so
+                                * dma_get_required_mask(), which uses
+                                * it, can be an inline function */
+
 /* return the number of _pages_ that will be allocated for the boot bitmap */
 unsigned long __init bootmem_bootmap_pages (unsigned long pages)
 {
@@ -82,14 +87,11 @@ static void __init reserve_bootmem_core(bootmem_data_t *bdata, unsigned long add
                                                        PAGE_SIZE-1)/PAGE_SIZE;
        unsigned long end = (addr + size + PAGE_SIZE-1)/PAGE_SIZE;
 
-       if (!size) BUG();
+       BUG_ON(!size);
+       BUG_ON(sidx >= eidx);
+       BUG_ON((addr >> PAGE_SHIFT) >= bdata->node_low_pfn);
+       BUG_ON(end > bdata->node_low_pfn);
 
-       if (sidx >= eidx)
-               BUG();
-       if ((addr >> PAGE_SHIFT) >= bdata->node_low_pfn)
-               BUG();
-       if (end > bdata->node_low_pfn)
-               BUG();
        for (i = sidx; i < eidx; i++)
                if (test_and_set_bit(i, bdata->node_bootmem_map)) {
 #ifdef CONFIG_DEBUG_BOOTMEM
@@ -110,9 +112,8 @@ static void __init free_bootmem_core(bootmem_data_t *bdata, unsigned long addr,
        unsigned long eidx = (addr + size - bdata->node_boot_start)/PAGE_SIZE;
        unsigned long end = (addr + size)/PAGE_SIZE;
 
-       if (!size) BUG();
-       if (end > bdata->node_low_pfn)
-               BUG();
+       BUG_ON(!size);
+       BUG_ON(end > bdata->node_low_pfn);
 
        if (addr < bdata->last_success)
                bdata->last_success = addr;
@@ -124,7 +125,7 @@ static void __init free_bootmem_core(bootmem_data_t *bdata, unsigned long addr,
        sidx = start - (bdata->node_boot_start/PAGE_SIZE);
 
        for (i = sidx; i < eidx; i++) {
-               if (!test_and_clear_bit(i, bdata->node_bootmem_map))
+               if (unlikely(!test_and_clear_bit(i, bdata->node_bootmem_map)))
                        BUG();
        }
 }
@@ -140,7 +141,7 @@ static void __init free_bootmem_core(bootmem_data_t *bdata, unsigned long addr,
  *
  * alignment has to be a power of 2 value.
  *
- * NOTE:  This function is _not_ reenetrant.
+ * NOTE:  This function is _not_ reentrant.
  */
 static void * __init
 __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
@@ -152,7 +153,6 @@ __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
 
        if(!size) {
                printk("__alloc_bootmem_core(): zero-sized request\n");
-               dump_stack();
                BUG();
        }
        BUG_ON(align & (align-1));
@@ -260,7 +260,7 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat)
        unsigned long idx;
        unsigned long *map; 
 
-       if (!bdata->node_bootmem_map) BUG();
+       BUG_ON(!bdata->node_bootmem_map);
 
        count = 0;
        /* first extant page of the node */
@@ -376,11 +376,6 @@ void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsign
        if (ptr)
                return (ptr);
 
-       /*
-        * Whoops, we cannot satisfy the allocation request.
-        */
-       printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
-       panic("Out of memory");
-       return NULL;
+       return __alloc_bootmem(size, align, goal);
 }