Commit 5977aad8 authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/437999


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 9bef42f2
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -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 */
+0 −2
Original line number Diff line number Diff line
@@ -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;
+0 −2
Original line number Diff line number Diff line
@@ -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), ())
+1 −2
Original line number Diff line number Diff line
@@ -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
+1 −3
Original line number Diff line number Diff line
@@ -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);
	}