Commit 5d0b5e2c authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

thread: Add cpumask parameter to spdk_thread_create



Allow users to optionally specify an affinity mask when
creating a thread. This isn't currently used, but we want
the API to be in its final form for the next release.

Change-Id: I7bd05e921ece6d8d5f61775bd14286f6a58f267f
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/451683


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 14bf912d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ spdk_fio_init_thread(struct thread_data *td)
	fio_thread->td = td;
	td->io_ops_data = fio_thread;

	fio_thread->thread = spdk_thread_create("fio_thread");
	fio_thread->thread = spdk_thread_create("fio_thread", NULL);
	if (!fio_thread->thread) {
		free(fio_thread);
		SPDK_ERRLOG("failed to allocate thread\n");
+5 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@

#include "spdk/stdinc.h"

#include "spdk/cpuset.h"
#include "spdk/queue.h"

#ifdef __cplusplus
@@ -196,10 +197,13 @@ void spdk_thread_lib_fini(void);
 * \param name Human-readable name for the thread; can be retrieved with spdk_thread_get_name().
 * The string is copied, so the pointed-to data only needs to be valid during the
 * spdk_thread_create() call. May be NULL to specify no name.
 * \param cpumask Optional mask of CPU cores on which to schedule this thread. This is only
 * a suggestion to the scheduler. The value is copied, so cpumask may be released when
 * this function returns. May be NULL if no mask is required.
 *
 * \return a pointer to the allocated thread on success or NULL on failure..
 */
struct spdk_thread *spdk_thread_create(const char *name);
struct spdk_thread *spdk_thread_create(const char *name, struct spdk_cpuset *cpumask);

/**
 * Release any resources related to the given thread and destroy it. Execution
+1 −1
Original line number Diff line number Diff line
@@ -638,7 +638,7 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_msg_fn start_fn,

	/* Now that the reactors have been initialized, we can create an
	 * initialization thread. */
	g_app_thread = spdk_thread_create("app_thread");
	g_app_thread = spdk_thread_create("app_thread", NULL);
	if (!g_app_thread) {
		SPDK_ERRLOG("Unable to create an spdk_thread for initialization\n");
		goto app_start_log_close_err;
+1 −1
Original line number Diff line number Diff line
@@ -323,7 +323,7 @@ spdk_reactors_start(void)

			/* For now, for each reactor spawn one thread. */
			snprintf(thread_name, sizeof(thread_name), "reactor_%u", reactor->lcore);
			spdk_thread_create(thread_name);
			spdk_thread_create(thread_name, NULL);
		}
		spdk_cpuset_set_cpu(g_spdk_app_core_mask, i, true);
	}
+1 −1
Original line number Diff line number Diff line
@@ -584,7 +584,7 @@ void SpdkInitializeThread(void)
	struct spdk_thread *thread;

	if (g_fs != NULL) {
		thread = spdk_thread_create("spdk_rocksdb");
		thread = spdk_thread_create("spdk_rocksdb", NULL);
		spdk_set_thread(thread);
		g_sync_args.channel = spdk_fs_alloc_thread_ctx(g_fs);
	}
Loading