From dcd1fb796cc1b6f162d4ccd84aa6ca8cdb9d4333 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Wed, 7 Sep 2022 17:24:00 +0200 Subject: [PATCH] example/perf: move allocating ns_worker Next patch in series will add another caller for the allocate_ns_worker. Change-Id: I60281b519265b27d661c2b1ca94e09dc68dbbf57 Signed-off-by: Tomasz Zawadzki Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14414 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Reviewed-by: Dong Yi Reviewed-by: Jacek Kalwas Reviewed-by: Aleksey Marchuk --- examples/nvme/perf/perf.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/examples/nvme/perf/perf.c b/examples/nvme/perf/perf.c index c3e6aa697..b63ffcf66 100644 --- a/examples/nvme/perf/perf.c +++ b/examples/nvme/perf/perf.c @@ -2829,12 +2829,30 @@ unregister_controllers(void) } } +static int +allocate_ns_worker(struct ns_entry *entry, struct worker_thread *worker) +{ + struct ns_worker_ctx *ns_ctx; + + ns_ctx = calloc(1, sizeof(struct ns_worker_ctx)); + if (!ns_ctx) { + return -1; + } + + printf("Associating %s with lcore %d\n", entry->name, worker->lcore); + ns_ctx->stats.min_tsc = UINT64_MAX; + ns_ctx->entry = entry; + ns_ctx->histogram = spdk_histogram_data_alloc(); + TAILQ_INSERT_TAIL(&worker->ns_ctx, ns_ctx, link); + + return 0; +} + static int associate_workers_with_ns(void) { struct ns_entry *entry = TAILQ_FIRST(&g_namespaces); struct worker_thread *worker = TAILQ_FIRST(&g_workers); - struct ns_worker_ctx *ns_ctx; int i, count; /* Each core contains single worker, and namespaces are associated as follows: @@ -2849,17 +2867,10 @@ associate_workers_with_ns(void) break; } - ns_ctx = calloc(1, sizeof(struct ns_worker_ctx)); - if (!ns_ctx) { + if (allocate_ns_worker(entry, worker) != 0) { return -1; } - printf("Associating %s with lcore %d\n", entry->name, worker->lcore); - ns_ctx->stats.min_tsc = UINT64_MAX; - ns_ctx->entry = entry; - ns_ctx->histogram = spdk_histogram_data_alloc(); - TAILQ_INSERT_TAIL(&worker->ns_ctx, ns_ctx, link); - worker = TAILQ_NEXT(worker, link); if (worker == NULL) { worker = TAILQ_FIRST(&g_workers);