Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Error checking fixes, minor bug in keyed stream, minor bug in checkpoint
[palacios.git] / linux_module / buddy.c
index a68d786..26a7021 100644 (file)
@@ -155,7 +155,7 @@ int buddy_add_pool(struct buddy_memzone * zone,
 
     mp = palacios_alloc_extended(sizeof(struct buddy_mempool), GFP_KERNEL, zone->node_id);
 
-    if (IS_ERR(mp)) {
+    if (!mp) {
        ERROR("Could not allocate mempool\n");
        return -1;
     }
@@ -174,6 +174,13 @@ int buddy_add_pool(struct buddy_memzone * zone,
                                  BITS_TO_LONGS(mp->num_blocks) * sizeof(long), GFP_KERNEL, zone->node_id
                                  );
 
+    if (!(mp->tag_bits)) { 
+       ERROR("Could not allocate tag_bits\n");
+       palacios_free(mp);
+       return -1;
+    }
+       
+
     /* Initially mark all minimum-sized blocks as allocated */
     bitmap_zero(mp->tag_bits, mp->num_blocks);
 
@@ -387,7 +394,7 @@ buddy_alloc(struct buddy_memzone *zone, unsigned long order, int constraints)
 /**
  * Returns a block of memory to the buddy system memory allocator.
  */
-void
+int
 buddy_free(
        //!    Buddy system memory allocator object.
        struct buddy_memzone *  zone,
@@ -422,9 +429,9 @@ buddy_free(
     pool = find_mempool(zone, addr);
 
     if ((pool == NULL) || (order > pool->pool_order)) {
-      WARNING("Attempted to free an invalid page address (%p) - pool=%p order=%lu\n", (void *)addr,pool,order);
-      palacios_spinlock_unlock_irqrestore(&(zone->lock), flags);
-       return;
+       WARNING("Attempted to free an invalid page address (%p) - pool=%p order=%lu\n", (void *)addr,pool,order);
+       palacios_spinlock_unlock_irqrestore(&(zone->lock), flags);
+       return -1;
     }
 
 
@@ -434,7 +441,7 @@ buddy_free(
     if (is_available(pool, block)) {
        ERROR("Error: Freeing an available block\n");
        palacios_spinlock_unlock_irqrestore(&(zone->lock), flags);
-       return;
+       return -1;
     }
 
     pool->num_free_blocks += (1UL << (order - zone->min_order));
@@ -465,6 +472,8 @@ buddy_free(
     list_add(&(block->link), &(zone->avail[order]));
 
     palacios_spinlock_unlock_irqrestore(&(zone->lock), flags);
+
+    return 0;
 }