Commit 08e4ced1 authored by Vitaliy Mysak's avatar Vitaliy Mysak Committed by Jim Harris
Browse files

bdev/ocf: synchronize env_allocator creation



Make modyfication of global allocator index tread safe
  by using atomic operation

This patch also changes mempool size to be 2^n - 1
  which makes it more efficient

Change-Id: I5b7426f2feef31471d3a4e6c6d2c7f7474200d68
Signed-off-by: default avatarVitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/442695


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 885bc995
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -38,16 +38,16 @@
#include "spdk_internal/log.h"

/* Number of buffers for mempool
 * Need to be power of two
 * Need to be power of two - 1 for better memory utilization
 * It depends on memory usage of OCF which
 * in itself depends on the workload
 * It is a big number because OCF uses allocators
 * for every request it sends and recieves
 */
#define ENV_ALLOCATOR_NBUFS 32768
#define ENV_ALLOCATOR_NBUFS 32767

/* Use unique index for env allocators */
static int g_env_allocator_index = 0;
static env_atomic g_env_allocator_index = 0;

void *
env_allocator_new(env_allocator *allocator)
@@ -61,7 +61,7 @@ env_allocator_create(uint32_t size, const char *name)
	env_allocator *allocator;
	char qualified_name[128] = {0};

	snprintf(qualified_name, 128, "ocf_env_%d", g_env_allocator_index++);
	snprintf(qualified_name, 128, "ocf_env_%d", env_atomic_inc_return(&g_env_allocator_index));

	allocator = spdk_mempool_create(qualified_name,
					ENV_ALLOCATOR_NBUFS, size,