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.


Linux user updates for more recent distros (Ubuntu 14.04 as target)
[palacios.git] / linux_usr / v3_mem.c
index 82f33c2..4d08bd4 100644 (file)
 
 #include "v3_ctrl.h"
 
+// set to zero to ignore, or set
+// to a level likely given the largest contiguous
+// page allocation outside of the base regions
+// note that the seed pools provide 2-4 MB chunks
+// to start
+#define PALACIOS_MIN_ALLOC (64*4096ULL)
 
 #define SYS_PATH "/sys/devices/system/memory/"
 
@@ -153,24 +159,19 @@ int main(int argc, char * argv[]) {
     }
 
     if (op==ADD) {
-       mem_size_bytes = atoll(argv[optind]) * (1024 * 1024);
+       mem_size_bytes = (unsigned long long) (atof(argv[optind]) * (1024 * 1024));
 
-       if (mem_size_bytes > palacios_runtime_mem_block_size) { 
-           EPRINTF("Trying to add a larger single chunk of memory than Palacios can manage\n"
+       if (mem_size_bytes < palacios_runtime_mem_block_size ||
+           (PALACIOS_MIN_ALLOC!=0 && mem_size_bytes < PALACIOS_MIN_ALLOC)) {
+           EPRINTF("Trying to add a smaller single chunk of memory than Palacios needs\n"
                   "Your request:                        %llu bytes\n"
-                  "Palacios run-time memory block size: %llu bytes\n",
-                  mem_size_bytes, palacios_runtime_mem_block_size);
+                  "Palacios run-time memory block size: %llu bytes\n"
+                  "Palacios minimal contiguous alloc:   %llu bytes\n",
+                   mem_size_bytes, palacios_runtime_mem_block_size,
+                   PALACIOS_MIN_ALLOC);
            return -1;
        }
 
-       if (mem_size_bytes < palacios_runtime_mem_block_size) { 
-           EPRINTF("Trying to add a smaller single chunk of memory than Palacios can manage\n"
-                  "Your request:                        %llu bytes\n"
-                  "Palacios run-time memory block size: %llu bytes\n",
-                  mem_size_bytes, palacios_runtime_mem_block_size);
-           return -1;
-       }
-       
        if (request && mem_size_bytes > kernel_max_page_alloc_bytes) { 
            EPRINTF("Trying to request a larger single chunk of memory than the kernel can allocate\n"
                   "Your request:                        %llu bytes\n"
@@ -391,7 +392,7 @@ static int offline_memory(unsigned long long mem_size_bytes,
     
     
 
-    VPRINTF("Trying to find %dMB (%d bytes) of memory above %llu with limit32=%d\n", mem_size_bytes/(1024*1024), mem_size_bytes, mem_min_start, limit32);
+    VPRINTF("Trying to find %lluMB (%llu bytes) of memory above %llu with limit32=%d\n", mem_size_bytes/(1024*1024), mem_size_bytes, mem_min_start, limit32);
        
     /* Figure out the block size */
     {
@@ -655,7 +656,7 @@ static int offline_memory(unsigned long long mem_size_bytes,
                    return -1;
                }
 
-               status_buf[BUF_SIZE]=0;
+               status_buf[BUF_SIZE-1]=0;
                
                VPRINTF("Checking offlined block %d (%s)...", i + reg_start, fname);
                
@@ -665,11 +666,17 @@ static int offline_memory(unsigned long long mem_size_bytes,
                    int j = 0;
                    int major = (i + reg_start) / 8;
                    int minor = (i + reg_start) % 8;
+            char * pos;
 
                    bitmap[major] &= ~(0x1 << minor); // mark the block as not removable in bitmap
                    
                    mem_ready = 0; // Keep searching
                    
+            // remove trailing newline
+            if ((pos=strchr(status_buf, '\n')) != NULL) {
+                *pos = '\0';
+            }
+
                    EPRINTF("ERROR - block status is '%s'\n", status_buf);
 
                    // Unwind space
@@ -699,7 +706,7 @@ static int online_memory(unsigned long long base_addr,
     unsigned int block_size_bytes = 0;
     int bitmap_entries = 0;
     unsigned char * bitmap = NULL;
-    int num_blocks = 0;    
+    unsigned int num_blocks = 0;    
     int reg_start = 0;
     int mem_ready = 0;
     
@@ -737,7 +744,7 @@ static int online_memory(unsigned long long base_addr,
 
     reg_start = base_addr / block_size_bytes;
 
-    VPRINTF("That is %lu blocks of size %llu starting at block %d\n", num_blocks, block_size_bytes, reg_start);
+    VPRINTF("That is %u blocks of size %u starting at block %d\n", num_blocks, block_size_bytes, reg_start);
    
     
        
@@ -808,7 +815,7 @@ static int write_offlined()
 
     fclose(off);
     if (!(off=fopen(offname,"w+"))) {  // truncate
-       EPRINTF("Cannot open %s for writing!\n");
+       EPRINTF("Cannot open %s for writing!\n",offname);
        return -1;
     }