Commit 04033955 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

lib/event: Use local cpuset instance in spdk_app_start()



Following the recent effort, use local instance of cpuset instead
of using cpuset pointer and allocating dynamically to it in
spdk_app_start().  This change will avoid potential out of memory
failure for application startup too.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I22b529da13e893db16296167f2d8d4c296dec31f
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478580


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
parent 87a4630b
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -578,7 +578,7 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_msg_fn start_fn,
	struct spdk_conf	*config = NULL;
	int			rc;
	char			*tty;
	struct spdk_cpuset	*tmp_cpumask;
	struct spdk_cpuset	tmp_cpumask = {};

	if (!opts) {
		SPDK_ERRLOG("opts should not be NULL\n");
@@ -651,19 +651,11 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_msg_fn start_fn,
		return 1;
	}

	tmp_cpumask = spdk_cpuset_alloc();
	if (tmp_cpumask == NULL) {
		SPDK_ERRLOG("spdk_cpuset_alloc() failed\n");
		return 1;
	}

	spdk_cpuset_zero(tmp_cpumask);
	spdk_cpuset_set_cpu(tmp_cpumask, spdk_env_get_current_core(), true);
	spdk_cpuset_set_cpu(&tmp_cpumask, spdk_env_get_current_core(), true);

	/* Now that the reactors have been initialized, we can create an
	 * initialization thread. */
	g_app_thread = spdk_thread_create("app_thread", tmp_cpumask);
	spdk_cpuset_free(tmp_cpumask);
	g_app_thread = spdk_thread_create("app_thread", &tmp_cpumask);
	if (!g_app_thread) {
		SPDK_ERRLOG("Unable to create an spdk_thread for initialization\n");
		return 1;