X-Git-Url: https://pd.if.org/git/?p=nbds;a=blobdiff_plain;f=runtime%2Fmem.c;h=5b0aa6759d6a2ada833776d3d48f1af266313d92;hp=7ffda4378208bb60daa78d29577bace2b634bfd3;hb=5aa9223647fbb52fa8941d92c8896ebaf148b41c;hpb=7d658a03f83e64690d0c71b4733dd3f9a2c60208 diff --git a/runtime/mem.c b/runtime/mem.c index 7ffda43..5b0aa67 100644 --- a/runtime/mem.c +++ b/runtime/mem.c @@ -14,8 +14,6 @@ #include "rlocal.h" #include "lwt.h" -#define RECYCLE_PAGES - #define MAX_SCALE 31 // allocate blocks up to 4GB (arbitrary, could be bigger) #ifndef NBD32 #define MIN_SCALE 3 // smallest allocated block is 8 bytes @@ -89,7 +87,7 @@ static void *get_new_region (int block_scale) { if (region_size < PAGE_SIZE) { region_size = PAGE_SIZE; } - void *region = mmap(NULL, region_size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0); + void *region = mmap(NULL, region_size, PROT_READ|PROT_WRITE, MAP_NORESERVE|MAP_ANON|MAP_PRIVATE, -1, 0); TRACE("m1", "get_new_region: mmapped new region %p (size %p)", region, region_size); if (region == (void *)-1) { perror("get_new_region: mmap"); @@ -133,9 +131,8 @@ void mem_init (void) { // Allocate space for the page headers. This could be a big chunk of memory on 64 bit systems, // but it just takes up virtual address space. Physical space used by the headers is still // proportional to the amount of memory the user mallocs. - headers_ = (header_t *)malloc(HEADERS_SIZE); + headers_ = mmap(NULL, HEADERS_SIZE, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0); TRACE("m1", "mem_init: header page %p", headers_, 0); - memset(headers_, 0, HEADERS_SIZE); // initialize spsc queues for (int i = 0; i < MAX_NUM_THREADS; ++i) {