Commit 216e3b90 authored by Jim Harris's avatar Jim Harris
Browse files

ublk: don't restrict spdk_thread to single core



Specify a cpumask that includes all of the cores
specified by the user for the ublk coremask.  With
static scheduler this will still always put only
one spdk_thread on each core.  But for dynamic
scheduler it allows spdk_threads to go on any core
in the core mask.

Note this also now matches how nvmf assigns its
spdk_threads.

While here, refactor the loop a bit to avoid
unnecessary indentation.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I662a6f466af02f7535fac8ad318d7ce3eef724de
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17871


Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent dfae1900
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -415,7 +415,6 @@ ublk_create_target(const char *cpumask_str)
	uint32_t i;
	char thread_name[32];
	struct spdk_cpuset cpuset = {};
	struct spdk_cpuset thd_cpuset = {};
	struct ublk_thread_ctx *thread_ctx;

	if (g_ublk_tgt.active == true) {
@@ -449,16 +448,15 @@ ublk_create_target(const char *cpumask_str)
	}

	SPDK_ENV_FOREACH_CORE(i) {
		if (spdk_cpuset_get_cpu(&cpuset, i)) {
			spdk_cpuset_zero(&thd_cpuset);
			spdk_cpuset_set_cpu(&thd_cpuset, i, true);
		if (!spdk_cpuset_get_cpu(&cpuset, i)) {
			continue;
		}
		snprintf(thread_name, sizeof(thread_name), "ublk_thread%u", i);
		thread_ctx = &g_ublk_tgt.thread_ctx[g_num_ublk_threads];
			thread_ctx->ublk_thread = spdk_thread_create(thread_name, &thd_cpuset);
		thread_ctx->ublk_thread = spdk_thread_create(thread_name, &cpuset);
		spdk_thread_send_msg(thread_ctx->ublk_thread, ublk_poller_register, thread_ctx);
		g_num_ublk_threads++;
	}
	}
	g_ublk_tgt.active = true;
	SPDK_NOTICELOG("UBLK target created successfully\n");