examples: use "main" instead of "master"
While here, replace use of "slave workers" in some comments with "secondary workers". Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I2169c108da18d449a66a29daa77a3f9c3145d4b2 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5352 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
fe137c8970
commit
87b21afd65
@ -520,8 +520,8 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int rc;
|
||||
struct worker_thread *worker, *master_worker;
|
||||
unsigned master_core;
|
||||
struct worker_thread *worker, *main_worker;
|
||||
unsigned main_core;
|
||||
|
||||
if (parse_args(argc, argv) != 0) {
|
||||
return 1;
|
||||
@ -562,22 +562,22 @@ main(int argc, char **argv)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Launch all of the slave workers */
|
||||
master_core = spdk_env_get_current_core();
|
||||
master_worker = NULL;
|
||||
/* Launch all of the secondary workers */
|
||||
main_core = spdk_env_get_current_core();
|
||||
main_worker = NULL;
|
||||
worker = g_workers;
|
||||
while (worker != NULL) {
|
||||
if (worker->core != master_core) {
|
||||
if (worker->core != main_core) {
|
||||
spdk_env_thread_launch_pinned(worker->core, work_fn, worker);
|
||||
} else {
|
||||
assert(master_worker == NULL);
|
||||
master_worker = worker;
|
||||
assert(main_worker == NULL);
|
||||
main_worker = worker;
|
||||
}
|
||||
worker = worker->next;
|
||||
}
|
||||
|
||||
assert(master_worker != NULL);
|
||||
rc = work_fn(master_worker);
|
||||
assert(main_worker != NULL);
|
||||
rc = work_fn(main_worker);
|
||||
if (rc != 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ static TAILQ_HEAD(, ns_entry) g_namespaces = TAILQ_HEAD_INITIALIZER(g_namespaces
|
||||
static int g_num_namespaces;
|
||||
static TAILQ_HEAD(, worker_thread) g_workers = TAILQ_HEAD_INITIALIZER(g_workers);
|
||||
static int g_num_workers = 0;
|
||||
static uint32_t g_master_core;
|
||||
static uint32_t g_main_core;
|
||||
|
||||
static int g_abort_interval = 1;
|
||||
|
||||
@ -479,7 +479,7 @@ work_fn(void *arg)
|
||||
spdk_nvme_qpair_process_completions(ns_ctx->qpair, 0);
|
||||
}
|
||||
|
||||
if (worker->lcore == g_master_core) {
|
||||
if (worker->lcore == g_main_core) {
|
||||
TAILQ_FOREACH(ctrlr_ctx, &worker->ctrlr_ctx, link) {
|
||||
/* Hold mutex to guard ctrlr_ctx->current_queue_depth. */
|
||||
pthread_mutex_lock(&ctrlr_ctx->mutex);
|
||||
@ -511,7 +511,7 @@ work_fn(void *arg)
|
||||
}
|
||||
} while (unfinished_ctx > 0);
|
||||
|
||||
if (worker->lcore == g_master_core) {
|
||||
if (worker->lcore == g_main_core) {
|
||||
do {
|
||||
unfinished_ctx = 0;
|
||||
|
||||
@ -918,14 +918,14 @@ unregister_controllers(void)
|
||||
}
|
||||
|
||||
static int
|
||||
associate_master_worker_with_ctrlr(void)
|
||||
associate_main_worker_with_ctrlr(void)
|
||||
{
|
||||
struct ctrlr_entry *entry;
|
||||
struct worker_thread *worker;
|
||||
struct ctrlr_worker_ctx *ctrlr_ctx;
|
||||
|
||||
TAILQ_FOREACH(worker, &g_workers, link) {
|
||||
if (worker->lcore == g_master_core) {
|
||||
if (worker->lcore == g_main_core) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -957,7 +957,7 @@ get_ctrlr_worker_ctx(struct spdk_nvme_ctrlr *ctrlr)
|
||||
struct ctrlr_worker_ctx *ctrlr_ctx;
|
||||
|
||||
TAILQ_FOREACH(worker, &g_workers, link) {
|
||||
if (worker->lcore == g_master_core) {
|
||||
if (worker->lcore == g_main_core) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1022,7 +1022,7 @@ associate_workers_with_ns(void)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int rc;
|
||||
struct worker_thread *worker, *master_worker;
|
||||
struct worker_thread *worker, *main_worker;
|
||||
struct spdk_env_opts opts;
|
||||
|
||||
rc = parse_args(argc, argv);
|
||||
@ -1070,7 +1070,7 @@ int main(int argc, char **argv)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (associate_master_worker_with_ctrlr() != 0) {
|
||||
if (associate_main_worker_with_ctrlr() != 0) {
|
||||
rc = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1082,20 +1082,20 @@ int main(int argc, char **argv)
|
||||
|
||||
printf("Initialization complete. Launching workers.\n");
|
||||
|
||||
/* Launch all of the slave workers */
|
||||
g_master_core = spdk_env_get_current_core();
|
||||
master_worker = NULL;
|
||||
/* Launch all of the secondary workers */
|
||||
g_main_core = spdk_env_get_current_core();
|
||||
main_worker = NULL;
|
||||
TAILQ_FOREACH(worker, &g_workers, link) {
|
||||
if (worker->lcore != g_master_core) {
|
||||
if (worker->lcore != g_main_core) {
|
||||
spdk_env_thread_launch_pinned(worker->lcore, work_fn, worker);
|
||||
} else {
|
||||
assert(master_worker == NULL);
|
||||
master_worker = worker;
|
||||
assert(main_worker == NULL);
|
||||
main_worker = worker;
|
||||
}
|
||||
}
|
||||
|
||||
assert(master_worker != NULL);
|
||||
rc = work_fn(master_worker);
|
||||
assert(main_worker != NULL);
|
||||
rc = work_fn(main_worker);
|
||||
|
||||
spdk_env_thread_wait_all();
|
||||
|
||||
|
@ -1044,8 +1044,8 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int rc;
|
||||
struct worker_thread *worker, *master_worker;
|
||||
unsigned master_core;
|
||||
struct worker_thread *worker, *main_worker;
|
||||
unsigned main_core;
|
||||
char task_pool_name[30];
|
||||
uint32_t task_count;
|
||||
struct spdk_env_opts opts;
|
||||
@ -1099,20 +1099,20 @@ main(int argc, char **argv)
|
||||
|
||||
printf("Initialization complete. Launching workers.\n");
|
||||
|
||||
/* Launch all of the slave workers */
|
||||
master_core = spdk_env_get_current_core();
|
||||
master_worker = NULL;
|
||||
/* Launch all of the secondary workers */
|
||||
main_core = spdk_env_get_current_core();
|
||||
main_worker = NULL;
|
||||
TAILQ_FOREACH(worker, &g_workers, link) {
|
||||
if (worker->lcore != master_core) {
|
||||
if (worker->lcore != main_core) {
|
||||
spdk_env_thread_launch_pinned(worker->lcore, work_fn, worker);
|
||||
} else {
|
||||
assert(master_worker == NULL);
|
||||
master_worker = worker;
|
||||
assert(main_worker == NULL);
|
||||
main_worker = worker;
|
||||
}
|
||||
}
|
||||
|
||||
assert(master_worker != NULL);
|
||||
rc = work_fn(master_worker);
|
||||
assert(main_worker != NULL);
|
||||
rc = work_fn(main_worker);
|
||||
|
||||
spdk_env_thread_wait_all();
|
||||
|
||||
|
@ -221,7 +221,7 @@ static TAILQ_HEAD(, ns_entry) g_namespaces = TAILQ_HEAD_INITIALIZER(g_namespaces
|
||||
static int g_num_namespaces;
|
||||
static TAILQ_HEAD(, worker_thread) g_workers = TAILQ_HEAD_INITIALIZER(g_workers);
|
||||
static int g_num_workers = 0;
|
||||
static uint32_t g_master_core;
|
||||
static uint32_t g_main_core;
|
||||
|
||||
static uint64_t g_tsc_rate;
|
||||
|
||||
@ -1316,7 +1316,7 @@ work_fn(void *arg)
|
||||
|
||||
tsc_current = spdk_get_ticks();
|
||||
|
||||
if (worker->lcore == g_master_core && tsc_current > tsc_next_print) {
|
||||
if (worker->lcore == g_main_core && tsc_current > tsc_next_print) {
|
||||
tsc_next_print += g_tsc_rate;
|
||||
print_periodic_performance(warmup);
|
||||
}
|
||||
@ -1331,7 +1331,7 @@ work_fn(void *arg)
|
||||
ns_ctx->stats.min_tsc = UINT64_MAX;
|
||||
}
|
||||
|
||||
if (worker->lcore == g_master_core && isatty(STDOUT_FILENO)) {
|
||||
if (worker->lcore == g_main_core && isatty(STDOUT_FILENO)) {
|
||||
/* warmup stage prints a longer string to stdout, need to erase it */
|
||||
printf("%c[2K", 27);
|
||||
}
|
||||
@ -2309,7 +2309,7 @@ nvme_poll_ctrlrs(void *arg)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int rc;
|
||||
struct worker_thread *worker, *master_worker;
|
||||
struct worker_thread *worker, *main_worker;
|
||||
struct spdk_env_opts opts;
|
||||
pthread_t thread_id = 0;
|
||||
|
||||
@ -2384,20 +2384,20 @@ int main(int argc, char **argv)
|
||||
|
||||
printf("Initialization complete. Launching workers.\n");
|
||||
|
||||
/* Launch all of the slave workers */
|
||||
g_master_core = spdk_env_get_current_core();
|
||||
master_worker = NULL;
|
||||
/* Launch all of the secondary workers */
|
||||
g_main_core = spdk_env_get_current_core();
|
||||
main_worker = NULL;
|
||||
TAILQ_FOREACH(worker, &g_workers, link) {
|
||||
if (worker->lcore != g_master_core) {
|
||||
if (worker->lcore != g_main_core) {
|
||||
spdk_env_thread_launch_pinned(worker->lcore, work_fn, worker);
|
||||
} else {
|
||||
assert(master_worker == NULL);
|
||||
master_worker = worker;
|
||||
assert(main_worker == NULL);
|
||||
main_worker = worker;
|
||||
}
|
||||
}
|
||||
|
||||
assert(master_worker != NULL);
|
||||
rc = work_fn(master_worker);
|
||||
assert(main_worker != NULL);
|
||||
rc = work_fn(main_worker);
|
||||
|
||||
spdk_env_thread_wait_all();
|
||||
|
||||
|
@ -1066,8 +1066,8 @@ nvme_poll_ctrlrs(void *arg)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int rc;
|
||||
struct worker_thread *worker, *master_worker;
|
||||
unsigned master_core;
|
||||
struct worker_thread *worker, *main_worker;
|
||||
unsigned main_core;
|
||||
struct spdk_env_opts opts;
|
||||
pthread_t thread_id = 0;
|
||||
|
||||
@ -1125,20 +1125,20 @@ int main(int argc, char **argv)
|
||||
|
||||
printf("Initialization complete. Launching workers.\n");
|
||||
|
||||
/* Launch all of the slave workers */
|
||||
master_core = spdk_env_get_current_core();
|
||||
master_worker = NULL;
|
||||
/* Launch all of the secondary workers */
|
||||
main_core = spdk_env_get_current_core();
|
||||
main_worker = NULL;
|
||||
TAILQ_FOREACH(worker, &g_workers, link) {
|
||||
if (worker->lcore != master_core) {
|
||||
if (worker->lcore != main_core) {
|
||||
spdk_env_thread_launch_pinned(worker->lcore, work_fn, worker);
|
||||
} else {
|
||||
assert(master_worker == NULL);
|
||||
master_worker = worker;
|
||||
assert(main_worker == NULL);
|
||||
main_worker = worker;
|
||||
}
|
||||
}
|
||||
|
||||
assert(master_worker != NULL);
|
||||
rc = work_fn(master_worker);
|
||||
assert(main_worker != NULL);
|
||||
rc = work_fn(main_worker);
|
||||
|
||||
spdk_env_thread_wait_all();
|
||||
|
||||
|
@ -90,7 +90,7 @@ TAILQ_HEAD(, nvmf_reactor) g_reactors = TAILQ_HEAD_INITIALIZER(g_reactors);
|
||||
TAILQ_HEAD(, nvmf_target_poll_group) g_poll_groups = TAILQ_HEAD_INITIALIZER(g_poll_groups);
|
||||
static uint32_t g_num_poll_groups = 0;
|
||||
|
||||
static struct nvmf_reactor *g_master_reactor = NULL;
|
||||
static struct nvmf_reactor *g_main_reactor = NULL;
|
||||
static struct nvmf_reactor *g_next_reactor = NULL;
|
||||
static struct spdk_thread *g_init_thread = NULL;
|
||||
static struct spdk_thread *g_fini_thread = NULL;
|
||||
@ -332,7 +332,7 @@ nvmf_init_threads(void)
|
||||
char thread_name[32];
|
||||
struct nvmf_reactor *nvmf_reactor;
|
||||
struct spdk_cpuset cpumask;
|
||||
uint32_t master_core = spdk_env_get_current_core();
|
||||
uint32_t main_core = spdk_env_get_current_core();
|
||||
|
||||
/* Whenever SPDK creates a new lightweight thread it will call
|
||||
* nvmf_schedule_spdk_thread asking for the application to begin
|
||||
@ -371,9 +371,9 @@ nvmf_init_threads(void)
|
||||
|
||||
TAILQ_INSERT_TAIL(&g_reactors, nvmf_reactor, link);
|
||||
|
||||
if (i == master_core) {
|
||||
g_master_reactor = nvmf_reactor;
|
||||
g_next_reactor = g_master_reactor;
|
||||
if (i == main_core) {
|
||||
g_main_reactor = nvmf_reactor;
|
||||
g_next_reactor = g_main_reactor;
|
||||
} else {
|
||||
rc = spdk_env_thread_launch_pinned(i,
|
||||
nvmf_reactor_run,
|
||||
@ -387,8 +387,8 @@ nvmf_init_threads(void)
|
||||
|
||||
/* Spawn a lightweight thread only on the current core to manage this application. */
|
||||
spdk_cpuset_zero(&cpumask);
|
||||
spdk_cpuset_set_cpu(&cpumask, master_core, true);
|
||||
snprintf(thread_name, sizeof(thread_name), "nvmf_master_thread");
|
||||
spdk_cpuset_set_cpu(&cpumask, main_core, true);
|
||||
snprintf(thread_name, sizeof(thread_name), "nvmf_main_thread");
|
||||
g_init_thread = spdk_thread_create(thread_name, &cpumask);
|
||||
if (!g_init_thread) {
|
||||
fprintf(stderr, "failed to create spdk thread\n");
|
||||
@ -887,7 +887,7 @@ int main(int argc, char **argv)
|
||||
rc = nvmf_init_threads();
|
||||
assert(rc == 0);
|
||||
|
||||
/* Send a message to the thread assigned to the master reactor
|
||||
/* Send a message to the thread assigned to the main reactor
|
||||
* that continues initialization. This is how we bootstrap the
|
||||
* program so that all code from here on is running on an SPDK thread.
|
||||
*/
|
||||
@ -898,7 +898,7 @@ int main(int argc, char **argv)
|
||||
|
||||
spdk_thread_send_msg(g_init_thread, nvmf_target_app_start, NULL);
|
||||
|
||||
nvmf_reactor_run(g_master_reactor);
|
||||
nvmf_reactor_run(g_main_reactor);
|
||||
|
||||
spdk_env_thread_wait_all();
|
||||
nvmf_destroy_threads();
|
||||
|
Loading…
Reference in New Issue
Block a user