#include "mutex.h"
#include "arch/arch.h"
#include "os/os.h"
+#include "smalloc.h"
+#include "log.h"
#define SMALLOC_REDZONE /* define to detect memory corruption */
#define SMALLOC_POST_RED 0x5aa55aa5U
unsigned int smalloc_pool_size = INITIAL_SIZE;
-const int int_mask = sizeof(int) - 1;
+static const int int_mask = sizeof(int) - 1;
struct pool {
struct fio_mutex *lock; /* protects this pool */
static int add_pool(struct pool *pool, unsigned int alloc_size)
{
int bitmap_blocks;
+ int mmap_flags;
void *ptr;
#ifdef SMALLOC_REDZONE
pool->nr_blocks = bitmap_blocks;
pool->free_blocks = bitmap_blocks * SMALLOC_BPB;
- ptr = mmap(NULL, alloc_size, PROT_READ|PROT_WRITE,
- MAP_SHARED | OS_MAP_ANON, -1, 0);
+ mmap_flags = OS_MAP_ANON;
+#ifdef CONFIG_ESX
+ mmap_flags |= MAP_PRIVATE;
+#else
+ mmap_flags |= MAP_SHARED;
+#endif
+ ptr = mmap(NULL, alloc_size, PROT_READ|PROT_WRITE, mmap_flags, -1, 0);
+
if (ptr == MAP_FAILED)
goto out_fail;
nr_pools++;
return 0;
out_fail:
- fprintf(stderr, "smalloc: failed adding pool\n");
+ log_err("smalloc: failed adding pool\n");
if (pool->map)
munmap(pool->map, pool->mmap_size);
return 1;
unsigned int *postred = postred_ptr(hdr);
if (hdr->prered != SMALLOC_PRE_RED) {
- fprintf(stderr, "smalloc pre redzone destroyed!\n");
- fprintf(stderr, " ptr=%p, prered=%x, expected %x\n",
+ log_err("smalloc pre redzone destroyed!\n"
+ " ptr=%p, prered=%x, expected %x\n",
hdr, hdr->prered, SMALLOC_PRE_RED);
assert(0);
}
if (*postred != SMALLOC_POST_RED) {
- fprintf(stderr, "smalloc post redzone destroyed!\n");
- fprintf(stderr, " ptr=%p, postred=%x, expected %x\n",
+ log_err("smalloc post redzone destroyed!\n"
+ " ptr=%p, postred=%x, expected %x\n",
hdr, *postred, SMALLOC_POST_RED);
assert(0);
}