From f614a7014c2359e1bc46a2ca611eee952a12574d Mon Sep 17 00:00:00 2001 From: paul luse Date: Thu, 17 Oct 2019 22:23:42 +0000 Subject: [PATCH] module/crypto: reduce session mempool size The initial implemenation of the module used a unique crypto session per operation. Later an optimization was made to use shared session, 1 for encrypt and 1 for decrypt. The size of the session pool and assocaited cache were not adjusted at the time. This patch reduces the session pool size to just 2 and uses 0 for session pool cache size. Signed-off-by: paul luse Change-Id: Ief3e867ec6bf4ff9c90d8ea60427ed8b85345275 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471692 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker --- module/bdev/crypto/vbdev_crypto.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/module/bdev/crypto/vbdev_crypto.c b/module/bdev/crypto/vbdev_crypto.c index 4bdf47459..8490028c1 100644 --- a/module/bdev/crypto/vbdev_crypto.c +++ b/module/bdev/crypto/vbdev_crypto.c @@ -106,8 +106,8 @@ static pthread_mutex_t g_device_qp_lock = PTHREAD_MUTEX_INITIALIZER; */ #define NUM_MBUFS 32768 #define POOL_CACHE_SIZE 256 -#define NUM_SESSIONS 1024 -#define SESS_MEMPOOL_CACHE_SIZE 256 +#define NUM_SESSIONS 2 +#define SESS_MEMPOOL_CACHE_SIZE 0 /* This is the max number of IOs we can supply to any crypto device QP at one time. * It can vary between drivers. @@ -323,7 +323,6 @@ vbdev_crypto_init_crypto_drivers(void) struct vbdev_dev *tmp_dev; unsigned int max_sess_size = 0, sess_size; uint16_t num_lcores = rte_lcore_count(); - uint32_t cache_size; /* Only the first call, via RPC or module init should init the crypto drivers. */ if (g_session_mp != NULL) { @@ -357,10 +356,10 @@ vbdev_crypto_init_crypto_drivers(void) } } - cache_size = spdk_min(RTE_MEMPOOL_CACHE_MAX_SIZE, NUM_SESSIONS / 2 / num_lcores); #if RTE_VERSION >= RTE_VERSION_NUM(19, 02, 0, 0) - g_session_mp_priv = rte_mempool_create("session_mp_priv", NUM_SESSIONS, max_sess_size, cache_size, - 0, NULL, NULL, NULL, NULL, SOCKET_ID_ANY, 0); + g_session_mp_priv = rte_mempool_create("session_mp_priv", NUM_SESSIONS, max_sess_size, + SESS_MEMPOOL_CACHE_SIZE, 0, NULL, NULL, NULL, + NULL, SOCKET_ID_ANY, 0); if (g_session_mp_priv == NULL) { SPDK_ERRLOG("Cannot create private session pool max size 0x%x\n", max_sess_size); return -ENOMEM; @@ -368,10 +367,11 @@ vbdev_crypto_init_crypto_drivers(void) g_session_mp = rte_cryptodev_sym_session_pool_create( "session_mp", - NUM_SESSIONS, 0, cache_size, 0, + NUM_SESSIONS, 0, SESS_MEMPOOL_CACHE_SIZE, 0, SOCKET_ID_ANY); #else - g_session_mp = rte_mempool_create("session_mp", NUM_SESSIONS, max_sess_size, cache_size, + g_session_mp = rte_mempool_create("session_mp", NUM_SESSIONS, max_sess_size, + SESS_MEMPOOL_CACHE_SIZE, 0, NULL, NULL, NULL, NULL, SOCKET_ID_ANY, 0); #endif if (g_session_mp == NULL) {