From 040339550c055dabf41c2b80501b5e172feacf79 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 20 Dec 2019 03:05:07 -0500 Subject: [PATCH] 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: Shuhei Matsumoto Change-Id: I22b529da13e893db16296167f2d8d4c296dec31f Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478580 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker Community-CI: SPDK CI Jenkins --- lib/event/app.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/event/app.c b/lib/event/app.c index e04c6f188..ac05626c2 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -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;