thread: spdk_free_thread now takes a thread parameter

Instead of implicitly grabbing the thread from the thread
local variable, make it explicit.

Change-Id: I733fad06181439e12b1e71a4829b84e7b64e2468
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/440595
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Ben Walker 2019-01-15 13:45:59 -07:00 committed by Darek Stojaczyk
parent aaa9a27851
commit 1068e22da5
8 changed files with 22 additions and 25 deletions

View File

@ -143,7 +143,7 @@ spdk_fio_cleanup_thread(struct spdk_fio_thread *fio_thread)
spdk_set_thread(fio_thread->thread);
spdk_free_thread();
spdk_free_thread(fio_thread->thread);
free(fio_thread->iocq);
free(fio_thread);
}

View File

@ -199,12 +199,15 @@ void spdk_thread_lib_fini(void);
struct spdk_thread *spdk_allocate_thread(const char *name);
/**
* Release any resources related to the calling thread for I/O channel allocation.
* Release any resources related to the given thread and destroy it. Execution
* continues on the current system thread after returning.
*
* All I/O channel references related to the calling thread must be released using
* \param thread The thread to destroy.
*
* All I/O channel references associated with the thread must be released using
* spdk_put_io_channel() prior to calling this function.
*/
void spdk_free_thread(void);
void spdk_free_thread(struct spdk_thread *thread);
/**
* Perform one iteration worth of processing on the thread. This includes

View File

@ -355,7 +355,7 @@ _spdk_reactor_run(void *arg)
spdk_set_thread(thread);
_spdk_reactor_context_switch_monitor_stop(reactor, NULL);
spdk_free_thread();
spdk_free_thread(thread);
return 0;
}

View File

@ -234,19 +234,16 @@ spdk_set_thread(struct spdk_thread *thread)
}
void
spdk_free_thread(void)
spdk_free_thread(struct spdk_thread *thread)
{
struct spdk_thread *thread;
struct spdk_io_channel *ch;
thread = _get_thread();
if (!thread) {
SPDK_ERRLOG("No thread allocated\n");
return;
}
SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Freeing thread %s\n", thread->name);
if (tls_thread == thread) {
tls_thread = NULL;
}
TAILQ_FOREACH(ch, &thread->io_channels, tailq) {
SPDK_ERRLOG("thread %s still has channel for io_device %s\n",
thread->name, ch->dev->name);
@ -265,8 +262,6 @@ spdk_free_thread(void)
}
free(thread);
tls_thread = NULL;
}
static inline uint32_t

View File

@ -103,7 +103,8 @@ free_threads(void)
for (i = 0; i < g_ut_num_threads; i++) {
set_thread(i);
spdk_free_thread();
spdk_free_thread(g_ut_threads[i].thread);
g_ut_threads[i].thread = NULL;
}
g_ut_num_threads = 0;

View File

@ -364,7 +364,7 @@ fs_delete_file_without_close(void)
static void
terminate_spdk_thread(void *arg)
{
spdk_free_thread();
spdk_free_thread(spdk_get_thread());
pthread_exit(NULL);
}
@ -395,8 +395,6 @@ spdk_thread(void *arg)
spdk_set_thread(thread);
}
spdk_free_thread();
return NULL;
}
@ -440,6 +438,6 @@ int main(int argc, char **argv)
free(g_dev_buffer);
send_request(terminate_spdk_thread, NULL);
pthread_join(spdk_tid, NULL);
spdk_free_thread();
spdk_free_thread(thread);
return num_failures;
}

View File

@ -266,7 +266,7 @@ test_nvmf_tcp_create(void)
transport = spdk_nvmf_tcp_create(&opts);
CU_ASSERT_PTR_NULL(transport);
spdk_free_thread();
spdk_free_thread(thread);
}
static void
@ -294,7 +294,7 @@ test_nvmf_tcp_destroy(void)
/* destroy transport */
CU_ASSERT(spdk_nvmf_tcp_destroy(transport) == 0);
spdk_free_thread();
spdk_free_thread(thread);
}
static void
@ -313,7 +313,7 @@ test_nvmf_tcp_poll_group_create(void)
CU_ASSERT_PTR_NOT_NULL(group);
spdk_nvmf_tcp_poll_group_destroy(group);
spdk_free_thread();
spdk_free_thread(thread);
}
static void

View File

@ -351,7 +351,7 @@ thread_name(void)
SPDK_CU_ASSERT_FATAL(thread != NULL);
name = spdk_thread_get_name(thread);
CU_ASSERT(name != NULL);
spdk_free_thread();
spdk_free_thread(thread);
/* Create thread named "test_thread" */
thread = spdk_allocate_thread("test_thread");
@ -361,7 +361,7 @@ thread_name(void)
name = spdk_thread_get_name(thread);
SPDK_CU_ASSERT_FATAL(name != NULL);
CU_ASSERT(strcmp(name, "test_thread") == 0);
spdk_free_thread();
spdk_free_thread(thread);
}
static uint64_t device1;