Commit fa6aec49 authored by Anisa Su's avatar Anisa Su Committed by Konrad Sztyber
Browse files

lib/thread: register thread owner type for scheduler trace events



Change-Id: I0074148ab2a151e38a17fe8cb770fd3ef19ec543
Signed-off-by: default avatarAnisa Su <anisa.su@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25067


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
parent 1876d41a
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -580,6 +580,15 @@ void spdk_for_each_thread(spdk_msg_fn fn, void *ctx, spdk_msg_fn cpl);
 */
void spdk_thread_set_interrupt_mode(bool enable_interrupt);

/**
 * Get trace id.
 *
 * \param thread Thread to get trace_id from.
 *
 * \return Trace id of the specified thread.
 */
uint16_t spdk_thread_get_trace_id(struct spdk_thread *thread);

/**
 * Register a poller on the current thread.
 *
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 10
SO_MINOR := 1
SO_MINOR := 2

C_SRCS = thread.c iobuf.c
LIBNAME = thread
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
	spdk_thread_send_critical_msg;
	spdk_for_each_thread;
	spdk_thread_set_interrupt_mode;
        spdk_thread_get_trace_id;
	spdk_poller_register;
	spdk_poller_register_named;
	spdk_poller_unregister;
+19 −0
Original line number Diff line number Diff line
@@ -152,10 +152,20 @@ struct spdk_thread {
	bool				poller_unregistered;
	struct spdk_fd_group		*fgrp;

	uint16_t			trace_id;

	uint8_t				reserved[6];

	/* User context allocated at the end */
	uint8_t				ctx[0];
};

/*
 * Assert that spdk_thread struct is 8 byte aligned to ensure
 * the user ctx is also 8-byte aligned.
 */
SPDK_STATIC_ASSERT((sizeof(struct spdk_thread)) % 8 == 0, "Incorrect size");

static pthread_mutex_t g_devlist_mutex = PTHREAD_MUTEX_INITIALIZER;

static spdk_new_thread_fn g_new_thread_fn = NULL;
@@ -302,6 +312,7 @@ thread_trace(void)
		}
	};

	spdk_trace_register_owner_type(OWNER_TYPE_THREAD, 't');
	spdk_trace_register_description_ext(opts, SPDK_COUNTOF(opts));
}
SPDK_TRACE_REGISTER_FN(thread_trace, "thread", TRACE_GROUP_THREAD)
@@ -549,6 +560,8 @@ spdk_thread_create(const char *name, const struct spdk_cpuset *cpumask)
		snprintf(thread->name, sizeof(thread->name), "%p", thread);
	}

	thread->trace_id = spdk_trace_register_owner(OWNER_TYPE_THREAD, thread->name);

	pthread_mutex_lock(&g_devlist_mutex);
	if (g_thread_id == 0) {
		SPDK_ERRLOG("Thread ID rolled over. Further thread creation is not allowed.\n");
@@ -1981,6 +1994,12 @@ spdk_thread_get_next_io_channel(struct spdk_io_channel *prev)
	return RB_NEXT(io_channel_tree, &thread->io_channels, prev);
}

uint16_t
spdk_thread_get_trace_id(struct spdk_thread *thread)
{
	return thread->trace_id;
}

struct call_thread {
	struct spdk_thread *cur_thread;
	spdk_msg_fn fn;