nvmf/tcp, nvmf/rdma: default to dynamic buf_cache_size

The nvmf generic transport code creates a mempool of
I/O buffers, as well as its own per-thread cache
of those buffers.  The mempool was being created
with a non-zero mempool cache, effectively duplicating
work - we had a cache in the mempool and then another
in the transport layer.

So patch 019cbb9 removed the mempool cache, but the
tcp transport was significantly affected by it.  It
uses a default 32 buffers per thread cache which is
very small, it was actually mostly relying on the
mempool cache (which was 512).  Performance regression
tests caught this problem, and Karol verified that
specifying a higher buf_cache_size fixed the problem.

So change both the tcp and rdma transports to specify
UINT32_MAX as the default buf_cache_size.  If the
user does not override this when creating the transport,
it will be dynamically sized based on the size of
the buffer pool and the number of poll groups.

Fixes: 019cbb9 ("nvmf: disable data buf mempool cache")

Fixes issue #2934.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Idd43e99312d59940ca68402299e264cc187bfccd
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17203
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Jim Harris 2023-03-14 15:22:05 +00:00
parent 3092c61d26
commit 3b138377e2
2 changed files with 24 additions and 18 deletions

View File

@ -2362,7 +2362,7 @@ nvmf_rdma_request_process(struct spdk_nvmf_rdma_transport *rtransport,
#define SPDK_NVMF_RDMA_DEFAULT_MAX_IO_SIZE 131072
#define SPDK_NVMF_RDMA_MIN_IO_BUFFER_SIZE (SPDK_NVMF_RDMA_DEFAULT_MAX_IO_SIZE / SPDK_NVMF_MAX_SGL_ENTRIES)
#define SPDK_NVMF_RDMA_DEFAULT_NUM_SHARED_BUFFERS 4095
#define SPDK_NVMF_RDMA_DEFAULT_BUFFER_CACHE_SIZE 32
#define SPDK_NVMF_RDMA_DEFAULT_BUFFER_CACHE_SIZE UINT32_MAX
#define SPDK_NVMF_RDMA_DEFAULT_NO_SRQ false
#define SPDK_NVMF_RDMA_DIF_INSERT_OR_STRIP false
#define SPDK_NVMF_RDMA_ACCEPTOR_BACKLOG 100
@ -2607,14 +2607,17 @@ nvmf_rdma_create(struct spdk_nvmf_transport_opts *opts)
return NULL;
}
min_shared_buffers = spdk_env_get_core_count() * opts->buf_cache_size;
if (min_shared_buffers > opts->num_shared_buffers) {
SPDK_ERRLOG("There are not enough buffers to satisfy"
"per-poll group caches for each thread. (%" PRIu32 ")"
"supplied. (%" PRIu32 ") required\n", opts->num_shared_buffers, min_shared_buffers);
SPDK_ERRLOG("Please specify a larger number of shared buffers\n");
nvmf_rdma_destroy(&rtransport->transport, NULL, NULL);
return NULL;
/* If buf_cache_size == UINT32_MAX, we will dynamically pick a cache size later that we know will fit. */
if (opts->buf_cache_size < UINT32_MAX) {
min_shared_buffers = spdk_env_get_core_count() * opts->buf_cache_size;
if (min_shared_buffers > opts->num_shared_buffers) {
SPDK_ERRLOG("There are not enough buffers to satisfy"
"per-poll group caches for each thread. (%" PRIu32 ")"
"supplied. (%" PRIu32 ") required\n", opts->num_shared_buffers, min_shared_buffers);
SPDK_ERRLOG("Please specify a larger number of shared buffers\n");
nvmf_rdma_destroy(&rtransport->transport, NULL, NULL);
return NULL;
}
}
sge_count = opts->max_io_size / opts->io_unit_size;

View File

@ -42,7 +42,7 @@
#define SPDK_NVMF_TCP_DEFAULT_MAX_IO_SIZE 131072
#define SPDK_NVMF_TCP_DEFAULT_IO_UNIT_SIZE 131072
#define SPDK_NVMF_TCP_DEFAULT_NUM_SHARED_BUFFERS 511
#define SPDK_NVMF_TCP_DEFAULT_BUFFER_CACHE_SIZE 32
#define SPDK_NVMF_TCP_DEFAULT_BUFFER_CACHE_SIZE UINT32_MAX
#define SPDK_NVMF_TCP_DEFAULT_DIF_INSERT_OR_STRIP false
#define SPDK_NVMF_TCP_DEFAULT_ABORT_TIMEOUT_SEC 1
@ -702,14 +702,17 @@ nvmf_tcp_create(struct spdk_nvmf_transport_opts *opts)
return NULL;
}
min_shared_buffers = spdk_env_get_core_count() * opts->buf_cache_size;
if (min_shared_buffers > opts->num_shared_buffers) {
SPDK_ERRLOG("There are not enough buffers to satisfy "
"per-poll group caches for each thread. (%" PRIu32 ") "
"supplied. (%" PRIu32 ") required\n", opts->num_shared_buffers, min_shared_buffers);
SPDK_ERRLOG("Please specify a larger number of shared buffers\n");
free(ttransport);
return NULL;
/* If buf_cache_size == UINT32_MAX, we will dynamically pick a cache size later that we know will fit. */
if (opts->buf_cache_size < UINT32_MAX) {
min_shared_buffers = spdk_env_get_core_count() * opts->buf_cache_size;
if (min_shared_buffers > opts->num_shared_buffers) {
SPDK_ERRLOG("There are not enough buffers to satisfy "
"per-poll group caches for each thread. (%" PRIu32 ") "
"supplied. (%" PRIu32 ") required\n", opts->num_shared_buffers, min_shared_buffers);
SPDK_ERRLOG("Please specify a larger number of shared buffers\n");
free(ttransport);
return NULL;
}
}
ttransport->accept_poller = SPDK_POLLER_REGISTER(nvmf_tcp_accept, &ttransport->transport,