lib/idxd: batch perf improvement

Small but noticable on perf top. We were using a list to track
valid batches and checking it on every submission.  Instead just
put a valid channel ptr in the batch struct and clear it when the
batch is freed. There was no other reason for the list.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: Ia26ceee578be4a82f4fd8abb2358ff18c56271a4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9149
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
paul luse 2021-08-11 01:05:08 -04:00 committed by Tomasz Zawadzki
parent 75eed7b52e
commit 31079d2d94
2 changed files with 5 additions and 17 deletions

View File

@ -131,7 +131,6 @@ spdk_idxd_get_channel(struct spdk_idxd_device *idxd)
chan->idxd = idxd;
TAILQ_INIT(&chan->ops_pool);
TAILQ_INIT(&chan->batches);
TAILQ_INIT(&chan->batch_pool);
TAILQ_INIT(&chan->ops_outstanding);
@ -156,7 +155,6 @@ spdk_idxd_put_channel(struct spdk_idxd_io_channel *chan)
chan->idxd->num_channels--;
pthread_mutex_unlock(&chan->idxd->num_channels_lock);
assert(TAILQ_EMPTY(&chan->batches));
spdk_free(chan->ops_base);
spdk_free(chan->desc_base);
while ((batch = TAILQ_FIRST(&chan->batch_pool))) {
@ -684,8 +682,8 @@ spdk_idxd_batch_create(struct spdk_idxd_io_channel *chan)
if (!TAILQ_EMPTY(&chan->batch_pool)) {
batch = TAILQ_FIRST(&chan->batch_pool);
batch->index = 0;
batch->chan = chan;
TAILQ_REMOVE(&chan->batch_pool, batch, link);
TAILQ_INSERT_TAIL(&chan->batches, batch, link);
} else {
/* The application needs to handle this. */
return NULL;
@ -697,24 +695,15 @@ spdk_idxd_batch_create(struct spdk_idxd_io_channel *chan)
static bool
_is_batch_valid(struct idxd_batch *batch, struct spdk_idxd_io_channel *chan)
{
bool found = false;
struct idxd_batch *cur_batch;
TAILQ_FOREACH(cur_batch, &chan->batches, link) {
if (cur_batch == batch) {
found = true;
break;
}
}
return found;
return batch->chan == chan;
}
static void
_free_batch(struct idxd_batch *batch, struct spdk_idxd_io_channel *chan)
{
SPDK_DEBUGLOG(idxd, "Free batch %p\n", batch);
TAILQ_REMOVE(&chan->batches, batch, link);
batch->index = 0;
batch->chan = NULL;
TAILQ_INSERT_TAIL(&chan->batch_pool, batch, link);
}

View File

@ -79,6 +79,7 @@ struct idxd_batch {
struct idxd_hw_desc *user_desc;
struct idxd_ops *user_ops;
uint8_t index;
struct spdk_idxd_io_channel *chan;
TAILQ_ENTRY(idxd_batch) link;
};
@ -107,9 +108,7 @@ struct spdk_idxd_io_channel {
TAILQ_HEAD(op_head, idxd_ops) ops_outstanding;
void *ops_base;
/* Lists of batches, free and in use. */
TAILQ_HEAD(, idxd_batch) batch_pool;
TAILQ_HEAD(, idxd_batch) batches;
void *batch_base;
};