bdev/ocf: Improve OCF mpools
- Reduce the size of initial memory needed by OCF. Number of allocator buffers equal to 16383 is tested to work on 24 caches running IO of io_size=512 and io_depth=512, which should be more than enough for any real life scenario. This reduces initial OCF memory usage from 726 MiB to 392 MiB. - Fix string handling for the name of the mempool. Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com> Change-Id: I40063ab1897c479c25904ae4096c5dae3351f73b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10843 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
2089c410ca
commit
c39647df83
@ -36,8 +36,6 @@
|
|||||||
|
|
||||||
#include "mpool.h"
|
#include "mpool.h"
|
||||||
|
|
||||||
#define MEMPOOL_SIZE 24
|
|
||||||
|
|
||||||
struct env_mpool {
|
struct env_mpool {
|
||||||
env_allocator *allocator[env_mpool_max];
|
env_allocator *allocator[env_mpool_max];
|
||||||
/* Handles to memory pools */
|
/* Handles to memory pools */
|
||||||
@ -58,10 +56,10 @@ struct env_mpool {
|
|||||||
struct env_mpool *env_mpool_create(uint32_t hdr_size, uint32_t elem_size,
|
struct env_mpool *env_mpool_create(uint32_t hdr_size, uint32_t elem_size,
|
||||||
int flags, int mpool_max, bool fallback,
|
int flags, int mpool_max, bool fallback,
|
||||||
const uint32_t limits[env_mpool_max],
|
const uint32_t limits[env_mpool_max],
|
||||||
const char *name_perfix, bool zero)
|
const char *name_prefix, bool zero)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char name[MEMPOOL_SIZE] = {};
|
char name[OCF_ALLOCATOR_NAME_MAX] = {};
|
||||||
int ret;
|
int ret;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
@ -76,7 +74,7 @@ struct env_mpool *env_mpool_create(uint32_t hdr_size, uint32_t elem_size,
|
|||||||
mpool->fallback = fallback;
|
mpool->fallback = fallback;
|
||||||
|
|
||||||
for (i = 0; i < min(env_mpool_max, mpool_max + 1); i++) {
|
for (i = 0; i < min(env_mpool_max, mpool_max + 1); i++) {
|
||||||
ret = snprintf(name, sizeof(name), "%s_%u", name, (1 << i));
|
ret = snprintf(name, sizeof(name), "%s_%u", name_prefix, (1 << i));
|
||||||
if (ret < 0 || ret >= (int)sizeof(name)) {
|
if (ret < 0 || ret >= (int)sizeof(name)) {
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,16 @@
|
|||||||
* in itself depends on the workload
|
* in itself depends on the workload
|
||||||
* It is a big number because OCF uses allocators
|
* It is a big number because OCF uses allocators
|
||||||
* for every request it sends and receives
|
* for every request it sends and receives
|
||||||
|
*
|
||||||
|
* The value of 16383 is tested to work on 24 caches
|
||||||
|
* running IO of io_size=512 and io_depth=512, which
|
||||||
|
* should be more than enough for any real life scenario.
|
||||||
|
* Increase this value if needed. It will result in
|
||||||
|
* more memory being used initially on SPDK app start,
|
||||||
|
* when compiled with OCF support.
|
||||||
*/
|
*/
|
||||||
#define ENV_ALLOCATOR_NBUFS 32767
|
#define ENV_ALLOCATOR_NBUFS 16383
|
||||||
|
|
||||||
#define GET_ELEMENTS_COUNT(_limit) (_limit < 0 ? ENV_ALLOCATOR_NBUFS : _limit)
|
#define GET_ELEMENTS_COUNT(_limit) (_limit < 0 ? ENV_ALLOCATOR_NBUFS : _limit)
|
||||||
|
|
||||||
/* Use unique index for env allocators */
|
/* Use unique index for env allocators */
|
||||||
@ -76,9 +84,10 @@ env_allocator *
|
|||||||
env_allocator_create_extended(uint32_t size, const char *name, int limit, bool zero)
|
env_allocator_create_extended(uint32_t size, const char *name, int limit, bool zero)
|
||||||
{
|
{
|
||||||
env_allocator *allocator;
|
env_allocator *allocator;
|
||||||
char qualified_name[128] = {0};
|
char qualified_name[OCF_ALLOCATOR_NAME_MAX] = {0};
|
||||||
|
|
||||||
snprintf(qualified_name, 128, "ocf_env_%d", env_atomic_inc_return(&g_env_allocator_index));
|
snprintf(qualified_name, OCF_ALLOCATOR_NAME_MAX, "ocf_env_%d:%s",
|
||||||
|
env_atomic_inc_return(&g_env_allocator_index), name);
|
||||||
|
|
||||||
allocator = calloc(1, sizeof(*allocator));
|
allocator = calloc(1, sizeof(*allocator));
|
||||||
if (!allocator) {
|
if (!allocator) {
|
||||||
|
@ -178,7 +178,7 @@ static inline uint64_t env_get_free_memory(void)
|
|||||||
|
|
||||||
/* *** ALLOCATOR *** */
|
/* *** ALLOCATOR *** */
|
||||||
|
|
||||||
#define OCF_ALLOCATOR_NAME_MAX 128
|
#define OCF_ALLOCATOR_NAME_MAX 24
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct spdk_mempool *mempool;
|
struct spdk_mempool *mempool;
|
||||||
|
@ -407,7 +407,7 @@ vbdev_ocf_volume_get_max_io_size(ocf_volume_t volume)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct ocf_volume_properties vbdev_volume_props = {
|
static struct ocf_volume_properties vbdev_volume_props = {
|
||||||
.name = "SPDK block device",
|
.name = "SPDK_block_device",
|
||||||
.io_priv_size = sizeof(struct ocf_io_ctx),
|
.io_priv_size = sizeof(struct ocf_io_ctx),
|
||||||
.volume_priv_size = sizeof(struct vbdev_ocf_base *),
|
.volume_priv_size = sizeof(struct vbdev_ocf_base *),
|
||||||
.caps = {
|
.caps = {
|
||||||
|
Loading…
Reference in New Issue
Block a user