From 5977aad8f7486552c94c5cc93ea9bb110e1cb5d0 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Thu, 20 Dec 2018 10:58:01 -0700 Subject: [PATCH] thread: Eliminate use of pthread_self and thread_ids SPDK threads are no longer mapped 1:1 to system threads. They are instead identified by the memory address of the spdk_thread object. Change-Id: I417f8376cebd2ee94f624f4436e6394b51486063 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/c/437999 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto --- include/spdk_internal/mock.h | 2 -- lib/thread/thread.c | 2 -- lib/ut_mock/mock.c | 2 -- mk/spdk.mock.unittest.mk | 3 +-- test/common/lib/ut_multithread.c | 4 +--- 5 files changed, 2 insertions(+), 11 deletions(-) diff --git a/include/spdk_internal/mock.h b/include/spdk_internal/mock.h index 212cf0c48..64d89d293 100644 --- a/include/spdk_internal/mock.h +++ b/include/spdk_internal/mock.h @@ -116,6 +116,4 @@ DECLARE_WRAPPER(pthread_mutex_init, int, DECLARE_WRAPPER(pthread_mutexattr_init, int, (pthread_mutexattr_t *attr)); -DECLARE_WRAPPER(pthread_self, pthread_t, (void)); - #endif /* SPDK_INTERNAL_MOCK_H */ diff --git a/lib/thread/thread.c b/lib/thread/thread.c index d111b7958..4dc980559 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -103,7 +103,6 @@ struct spdk_poller { }; struct spdk_thread { - pthread_t thread_id; spdk_thread_pass_msg msg_fn; spdk_start_poller start_poller_fn; spdk_stop_poller stop_poller_fn; @@ -210,7 +209,6 @@ spdk_allocate_thread(spdk_thread_pass_msg msg_fn, return NULL; } - thread->thread_id = pthread_self(); thread->msg_fn = msg_fn; thread->start_poller_fn = start_poller_fn; thread->stop_poller_fn = stop_poller_fn; diff --git a/lib/ut_mock/mock.c b/lib/ut_mock/mock.c index 6d141b406..8bee1c4ac 100644 --- a/lib/ut_mock/mock.c +++ b/lib/ut_mock/mock.c @@ -41,5 +41,3 @@ DEFINE_WRAPPER(pthread_mutex_init, int, DEFINE_WRAPPER(pthread_mutexattr_init, int, (pthread_mutexattr_t *attr), (attr)) - -DEFINE_WRAPPER(pthread_self, pthread_t, (void), ()) diff --git a/mk/spdk.mock.unittest.mk b/mk/spdk.mock.unittest.mk index dff2c9690..e151596be 100644 --- a/mk/spdk.mock.unittest.mk +++ b/mk/spdk.mock.unittest.mk @@ -33,5 +33,4 @@ LDFLAGS += \ -Wl,--wrap,calloc \ -Wl,--wrap,pthread_mutexattr_init \ - -Wl,--wrap,pthread_mutex_init \ - -Wl,--wrap,pthread_self + -Wl,--wrap,pthread_mutex_init diff --git a/test/common/lib/ut_multithread.c b/test/common/lib/ut_multithread.c index e262b45b9..51420bba3 100644 --- a/test/common/lib/ut_multithread.c +++ b/test/common/lib/ut_multithread.c @@ -60,17 +60,15 @@ struct ut_thread *g_ut_threads; #define INVALID_THREAD 0x1000 -static uintptr_t g_thread_id = INVALID_THREAD; +static uint64_t g_thread_id = INVALID_THREAD; static void set_thread(uintptr_t thread_id) { g_thread_id = thread_id; if (thread_id == INVALID_THREAD) { - MOCK_CLEAR(pthread_self); spdk_set_thread(NULL); } else { - MOCK_SET(pthread_self, (pthread_t)thread_id); spdk_set_thread(g_ut_threads[thread_id].thread); }