From: Peter Dinda Date: Mon, 31 Aug 2015 20:44:28 +0000 (-0500) Subject: Assorted cleanup of memory-related user-level stuff X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=f240f8a3c11478abe180bd906c746c68eb8c3a3c;p=palacios.git Assorted cleanup of memory-related user-level stuff - adjust guest memory access library to handle truncated output describing VMs with too many base regions (can happen with cache part) - adjust memory allocation utility to handle fractional amounts (tiny chunks are best for cache part) while not allowing the amounts to be too tiny - seperate concept of memory block size and base region size when configuring palacios - cachepart needs a base region size that is generally smaller than the memory block size because there are other page allocations (e.g., vmcb bitmasks) that are larger than one page - removal of debug cruft in cachepart --- diff --git a/linux_usr/v3_guest_mem.c b/linux_usr/v3_guest_mem.c index b0798a6..fa398e9 100644 --- a/linux_usr/v3_guest_mem.c +++ b/linux_usr/v3_guest_mem.c @@ -22,6 +22,7 @@ struct v3_guest_mem_map * v3_guest_mem_get_map(char *vmdev) uint64_t start, end, num; uint64_t guest_cur; uint64_t num_regions; + uint64_t num_regions_shown; if (!(f=fopen(GUEST_FILE,"r"))) { @@ -48,10 +49,15 @@ struct v3_guest_mem_map * v3_guest_mem_get_map(char *vmdev) fprintf(stderr,"Could not find number of regions for %s\n",vmdev); return 0; } - if (sscanf(buf,"Regions: %llu",&num_regions)==1) { + if (sscanf(buf,"Regions: %llu (%llu shown)",&num_regions,&num_regions_shown)==2) { break; } } + + if (num_regions != num_regions_shown) { + fprintf(stderr,"Cannot see all regions for %s\n",vmdev); + return 0; + } struct v3_guest_mem_map *m = (struct v3_guest_mem_map *) malloc(sizeof(struct v3_guest_mem_map)+num_regions*sizeof(struct v3_guest_mem_block)); diff --git a/linux_usr/v3_mem.c b/linux_usr/v3_mem.c index b30b344..1d987fc 100644 --- a/linux_usr/v3_mem.c +++ b/linux_usr/v3_mem.c @@ -17,6 +17,12 @@ #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*4096) #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 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" diff --git a/palacios/src/palacios/vmm_cachepart.c b/palacios/src/palacios/vmm_cachepart.c index ceab364..e68c5dc 100644 --- a/palacios/src/palacios/vmm_cachepart.c +++ b/palacios/src/palacios/vmm_cachepart.c @@ -92,25 +92,6 @@ int v3_deinit_cachepart() return 0; } -/* -static int bitcount(uint64_t x) -{ - int c=0; - - while (x) { - c+=x&0x1; - x>>=1; - } - return c; -} - -static int is_pow2(x) -{ - int c = bitcount(x); - - return c==0 || c==1; -} -*/ static uint64_t log2(uint64_t x) { @@ -252,8 +233,6 @@ int v3_init_cachepart_vm(struct v3_vm_info *vm, struct v3_xml *config) vm->resource_control.pg_filter_state = &vm->cachepart_state; - // V3_Sleep(50000000); - return 0; } @@ -276,7 +255,6 @@ int v3_deinit_cachepart_core(struct guest_info *core) return 0; } -static unsigned count=0; int v3_cachepart_filter(void *paddr, v3_cachepart_t *c) { @@ -285,13 +263,6 @@ int v3_cachepart_filter(void *paddr, v3_cachepart_t *c) PrintDebug(VM_NONE,VCORE_NONE,"cachepart: %p is color 0x%llx required colors: [0x%llx,0x%llx] %s\n",paddr,color,c->min_color,c->max_color, color>=c->min_color && color<=c->max_color ? "ACCEPT" : "REJECT"); - /* - if (count<10) { - V3_Sleep(5000000); - count++; - } - */ - return color>=c->min_color && color<=c->max_color; } diff --git a/v3_config_v3vee.pl b/v3_config_v3vee.pl index ae2a86f..8cf9235 100755 --- a/v3_config_v3vee.pl +++ b/v3_config_v3vee.pl @@ -85,7 +85,7 @@ $compmemblocksize = $memblocksize; $maxalloc = 4194304; -print "What is your kernel's maximum contiguous page allocation size in bytes (typicaly (MAX_ORDER-1)*4096) [$maxalloc] : "; +print "What is your kernel's maximum contiguous page allocation size in bytes (typically 2^(MAX_ORDER-1)*4096) [$maxalloc] : "; $maxalloc = get_user($maxalloc); @@ -110,6 +110,17 @@ if ($hotremove eq "n") { print "Desired memory block size? [$maxalloc or less, power of 2] : "; $memblocksize = get_user($maxalloc); } while ($memblocksize>$maxalloc && !powerof2($memblocksize)); + do { + print "You are not using hot-remove, so we can adjust the allocation size\n"; + print "Typically, you want this as large as possible (up to what your\n"; + print "kernel allows, but for special purposes, for example cache\n"; + print "partitioning, you want this to be as small as possible (just\n"; + print "larger than the largest contiguous allocation your guests will need.)\n"; + print "Desired allocation size? [$maxalloc or less, power of 2] : "; + $allocsize = get_user($maxalloc); + } while ($allocsize>$maxalloc && !powerof2($allocsize)); +} else { + $allocsize=$memblocksize; } $mem = 1024; @@ -155,6 +166,7 @@ Parameters Compiled Memory Block Size: $compmemblocksize Override Memory Block Size: $override_memblocksize Actual Memory Block Size: $memblocksize + Allocation Block Size: $allocsize Allow Devmem: $devmem Support QEMU devices: $qemu QEMU directory: $qemudir @@ -219,7 +231,7 @@ if (defined($numa{numcores})) { -$chunk = $memblocksize / (1024 * 1024) ; +$chunk = $allocsize / (1024 * 1024) ; $numchunks = $mem / $chunk; $chunkspernode = $numchunks / $numnodes;