Commit 87b21afd authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

examples: use "main" instead of "master"



While here, replace use of "slave workers" in some
comments with "secondary workers".

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent fe137c89
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -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;
	}
+16 −16
Original line number Diff line number Diff line
@@ -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();

+10 −10
Original line number Diff line number Diff line
@@ -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();

+12 −12
Original line number Diff line number Diff line
@@ -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();

+10 −10
Original line number Diff line number Diff line
@@ -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();

Loading