example/nvmf: Create only a single SPDK thread on the master core at startup
Stop creating the default lightweight thread per POSIX thread. Additionally, substitute the created master thread into g_init_thread directly as a preparation to the next patch. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I09643491e6b5aaf91d9958481f05e264a2ac5f7d Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2542 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
f7ebaeaa59
commit
10190302d2
@ -309,7 +309,6 @@ nvmf_init_threads(void)
|
|||||||
uint32_t i;
|
uint32_t i;
|
||||||
char thread_name[32];
|
char thread_name[32];
|
||||||
struct nvmf_reactor *nvmf_reactor;
|
struct nvmf_reactor *nvmf_reactor;
|
||||||
struct spdk_thread *thread;
|
|
||||||
struct spdk_cpuset cpumask;
|
struct spdk_cpuset cpumask;
|
||||||
uint32_t master_core = spdk_env_get_current_core();
|
uint32_t master_core = spdk_env_get_current_core();
|
||||||
|
|
||||||
@ -357,20 +356,14 @@ nvmf_init_threads(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some SPDK libraries assume that there is at least some number of lightweight
|
/* Spawn a lightweight thread only on the current core to manage this application. */
|
||||||
* threads that exist from the beginning of time. That assumption is currently
|
spdk_cpuset_zero(&cpumask);
|
||||||
* being removed from the SPDK libraries, but until that work is completed spawn
|
spdk_cpuset_set_cpu(&cpumask, master_core, true);
|
||||||
* one lightweight thread per reactor here.
|
snprintf(thread_name, sizeof(thread_name), "nvmf_master_thread");
|
||||||
*/
|
g_init_thread = spdk_thread_create(thread_name, &cpumask);
|
||||||
SPDK_ENV_FOREACH_CORE(i) {
|
if (!g_init_thread) {
|
||||||
spdk_cpuset_zero(&cpumask);
|
fprintf(stderr, "failed to create spdk thread\n");
|
||||||
spdk_cpuset_set_cpu(&cpumask, i, true);
|
return -1;
|
||||||
snprintf(thread_name, sizeof(thread_name), "spdk_thread_%u", i);
|
|
||||||
thread = spdk_thread_create(thread_name, &cpumask);
|
|
||||||
if (!thread) {
|
|
||||||
fprintf(stderr, "failed to create spdk thread\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout, "nvmf threads initlize successfully\n");
|
fprintf(stdout, "nvmf threads initlize successfully\n");
|
||||||
@ -896,7 +889,6 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct spdk_env_opts opts;
|
struct spdk_env_opts opts;
|
||||||
struct nvmf_lw_thread *lw_thread;
|
|
||||||
|
|
||||||
spdk_env_opts_init(&opts);
|
spdk_env_opts_init(&opts);
|
||||||
opts.name = "nvmf-example";
|
opts.name = "nvmf-example";
|
||||||
@ -919,8 +911,6 @@ int main(int argc, char **argv)
|
|||||||
* that continues initialization. This is how we bootstrap the
|
* that continues initialization. This is how we bootstrap the
|
||||||
* program so that all code from here on is running on an SPDK thread.
|
* program so that all code from here on is running on an SPDK thread.
|
||||||
*/
|
*/
|
||||||
lw_thread = TAILQ_FIRST(&g_master_reactor->threads);
|
|
||||||
g_init_thread = spdk_thread_get_from_ctx(lw_thread);
|
|
||||||
assert(g_init_thread != NULL);
|
assert(g_init_thread != NULL);
|
||||||
|
|
||||||
rc = nvmf_setup_signal_handlers();
|
rc = nvmf_setup_signal_handlers();
|
||||||
|
Loading…
Reference in New Issue
Block a user