X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=smalloc.c;h=28f82633b23661c9e49f80612ac2c6d550c4fa8e;hp=b7502dc9616a25b0292947c51be0b4daf2022487;hb=adf57099338307b3a4a129475a12aad31e35ade3;hpb=5ec10eaad3b09875b91e19a20bbdfa06f2117562 diff --git a/smalloc.c b/smalloc.c index b7502dc9..28f82633 100644 --- a/smalloc.c +++ b/smalloc.c @@ -16,11 +16,13 @@ #undef ENABLE_RESIZE /* define to enable pool resizing */ #define MP_SAFE /* define to made allocator thread safe */ -#define INITIAL_SIZE 65536 /* new pool size */ +#define INITIAL_SIZE 1048576 /* new pool size */ #define MAX_POOLS 32 /* maximum number of pools to setup */ +unsigned int smalloc_pool_size = INITIAL_SIZE; + #ifdef ENABLE_RESIZE -#define MAX_SIZE 8 * INITIAL_SIZE +#define MAX_SIZE 8 * smalloc_pool_size static unsigned int resize_error; #endif @@ -218,7 +220,7 @@ fail: #endif } -static int add_pool(struct pool *pool) +static int add_pool(struct pool *pool, unsigned int alloc_size) { struct mem_hdr *hdr; void *ptr; @@ -229,7 +231,11 @@ static int add_pool(struct pool *pool) if (fd < 0) goto out_close; - pool->size = INITIAL_SIZE; + if (alloc_size > smalloc_pool_size) + pool->size = alloc_size; + else + pool->size = smalloc_pool_size; + if (ftruncate(fd, pool->size) < 0) goto out_unlink; @@ -273,7 +279,7 @@ void sinit(void) #ifdef MP_SAFE lock = fio_mutex_rw_init(); #endif - ret = add_pool(&mp[0]); + ret = add_pool(&mp[0], INITIAL_SIZE); assert(!ret); } @@ -456,7 +462,7 @@ void *smalloc(unsigned int size) else { i = nr_pools; global_read_unlock(); - if (add_pool(&mp[nr_pools])) + if (add_pool(&mp[nr_pools], size)) goto out; global_read_lock(); }