From d09b5674a4edafb2ffed57dfef185e7bd9ecaa95 Mon Sep 17 00:00:00 2001 From: paul luse Date: Thu, 5 Aug 2021 10:58:31 -0400 Subject: [PATCH] lib/idxd: reduce size of per channel batch pool Was set at a pretty high number during early development. Instead of a #define, lets use the same math we use to determine the size of the operation and descriptor pools as that's the max number of batches that will be needed. Signed-off-by: paul luse Change-Id: Ide5311b4b6c931010413d0f82baed0e05d5fcde7 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9099 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- lib/idxd/idxd.c | 8 +++++--- lib/idxd/idxd.h | 5 ----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/idxd/idxd.c b/lib/idxd/idxd.c index a54ea416f..71cb7a053 100644 --- a/lib/idxd/idxd.c +++ b/lib/idxd/idxd.c @@ -95,7 +95,7 @@ spdk_idxd_get_channel(struct spdk_idxd_device *idxd) { struct spdk_idxd_io_channel *chan; struct idxd_batch *batch; - int i; + int i, num_batches; assert(idxd != NULL); @@ -105,7 +105,9 @@ spdk_idxd_get_channel(struct spdk_idxd_device *idxd) return NULL; } - chan->batch_base = calloc(NUM_BATCHES_PER_CHANNEL, sizeof(struct idxd_batch)); + num_batches = idxd->queues[idxd->wq_id].wqcfg.wq_size / idxd->chan_per_device; + + chan->batch_base = calloc(num_batches, sizeof(struct idxd_batch)); if (chan->batch_base == NULL) { SPDK_ERRLOG("Failed to allocate batch pool\n"); free(chan); @@ -134,7 +136,7 @@ spdk_idxd_get_channel(struct spdk_idxd_device *idxd) TAILQ_INIT(&chan->ops_outstanding); batch = chan->batch_base; - for (i = 0 ; i < NUM_BATCHES_PER_CHANNEL ; i++) { + for (i = 0 ; i < num_batches ; i++) { TAILQ_INSERT_TAIL(&chan->batch_pool, batch, link); batch++; } diff --git a/lib/idxd/idxd.h b/lib/idxd/idxd.h index 39da4928f..65dae94e7 100644 --- a/lib/idxd/idxd.h +++ b/lib/idxd/idxd.h @@ -65,11 +65,6 @@ static inline void movdir64b(void *dst, const void *src) /* The following sets up a max desc count per batch of 16 */ #define LOG2_WQ_MAX_BATCH 4 /* 2^4 = 16 */ #define DESC_PER_BATCH (1 << LOG2_WQ_MAX_BATCH) -/* We decide how many batches we want to support based on what max queue - * depth makes sense resource wise. There is a small price to pay with - * larger numbers wrt polling for completions. - */ -#define NUM_BATCHES_PER_CHANNEL 0x400 #define MIN_USER_DESC_COUNT 2 #define LOG2_WQ_MAX_XFER 30 /* 2^30 = 1073741824 */