From: Jens Axboe Date: Sun, 25 Sep 2016 19:56:59 +0000 (-0600) Subject: init: re-call sinit() if we change the smallc pool size X-Git-Tag: fio-2.15~31 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=5f9454a2b5007a40f3c9479ce751ca35e0d21d76;p=fio.git init: re-call sinit() if we change the smallc pool size Just adds more pools, but that should be fine at init time. Signed-off-by: Jens Axboe --- diff --git a/init.c b/init.c index 5482c665..f7cb46d3 100644 --- a/init.c +++ b/init.c @@ -2309,6 +2309,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type) case 'a': smalloc_pool_size = atoi(optarg); smalloc_pool_size <<= 10; + sinit(); break; case 't': if (check_str_time(optarg, &def_timeout, 1)) { diff --git a/smalloc.c b/smalloc.c index 6f647c06..3ca29ff1 100644 --- a/smalloc.c +++ b/smalloc.c @@ -26,7 +26,9 @@ #define SMALLOC_BPL (SMALLOC_BPB * SMALLOC_BPI) #define INITIAL_SIZE 16*1024*1024 /* new pool size */ -#define MAX_POOLS 8 /* maximum number of pools to setup */ +#define INITIAL_POOLS 8 /* maximum number of pools to setup */ + +#define MAX_POOLS 16 #define SMALLOC_PRE_RED 0xdeadbeefU #define SMALLOC_POST_RED 0x5aa55aa5U @@ -149,12 +151,15 @@ static int find_next_zero(int word, int start) return ffz(word) + start; } -static int add_pool(struct pool *pool, unsigned int alloc_size) +static bool add_pool(struct pool *pool, unsigned int alloc_size) { int bitmap_blocks; int mmap_flags; void *ptr; + if (nr_pools == MAX_POOLS) + return false; + #ifdef SMALLOC_REDZONE alloc_size += sizeof(unsigned int); #endif @@ -191,21 +196,22 @@ static int add_pool(struct pool *pool, unsigned int alloc_size) goto out_fail; nr_pools++; - return 0; + return true; out_fail: log_err("smalloc: failed adding pool\n"); if (pool->map) munmap(pool->map, pool->mmap_size); - return 1; + return false; } void sinit(void) { - int i, ret; + bool ret; + int i; - for (i = 0; i < MAX_POOLS; i++) { - ret = add_pool(&mp[i], smalloc_pool_size); - if (ret) + for (i = 0; i < INITIAL_POOLS; i++) { + ret = add_pool(&mp[nr_pools], smalloc_pool_size); + if (!ret) break; }