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 <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14414
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: Jacek Kalwas <jacek.kalwas@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
Tomasz Zawadzki 2022-09-07 17:24:00 +02:00
parent b6e9e1abb4
commit dcd1fb796c

View File

@ -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 static int
associate_workers_with_ns(void) associate_workers_with_ns(void)
{ {
struct ns_entry *entry = TAILQ_FIRST(&g_namespaces); struct ns_entry *entry = TAILQ_FIRST(&g_namespaces);
struct worker_thread *worker = TAILQ_FIRST(&g_workers); struct worker_thread *worker = TAILQ_FIRST(&g_workers);
struct ns_worker_ctx *ns_ctx;
int i, count; int i, count;
/* Each core contains single worker, and namespaces are associated as follows: /* Each core contains single worker, and namespaces are associated as follows:
@ -2849,17 +2867,10 @@ associate_workers_with_ns(void)
break; break;
} }
ns_ctx = calloc(1, sizeof(struct ns_worker_ctx)); if (allocate_ns_worker(entry, worker) != 0) {
if (!ns_ctx) {
return -1; 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); worker = TAILQ_NEXT(worker, link);
if (worker == NULL) { if (worker == NULL) {
worker = TAILQ_FIRST(&g_workers); worker = TAILQ_FIRST(&g_workers);