Commit 3f4b2c67 authored by Yifan Bian's avatar Yifan Bian Committed by Konrad Sztyber
Browse files

lib/thread: add func to not reschedule spdk_thread



spdk_thread_bind is used to bind it to its current CPU core.
spdk_thread_is_bound will return whether spdk_thread is bound.

Signed-off-by: default avatarYifan Bian <yifan.bian@intel.com>
Signed-off-by: default avatarLiu, Xiaodong <xiaodong.liu@intel.com>
Change-Id: I7b63c824257df8bee5e2cc8810f46539b42e3b8d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15102


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 9fe36c0d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -61,6 +61,11 @@ receive and send the I/O management commands.
New `spdk_nvmf_transport_create_async` was added, it accepts a callback and callback argument.
`spdk_nvmf_transport_create` is marked deprecated.

### thread

Added two new APIs `spdk_thread_bind` and `spdk_thread_is_bound` to bind or unbind spdk_thread
to its current CPU core, and check bound status.

### part

New API `spdk_bdev_part_construct_ext` is added and allows the bdev's UUID to be specified.
+19 −0
Original line number Diff line number Diff line
@@ -248,6 +248,25 @@ struct spdk_thread *spdk_thread_get_app_thread(void);
 */
void spdk_set_thread(struct spdk_thread *thread);

/**
 * Bind or unbind spdk_thread to its current CPU core.
 *
 * If spdk_thread is bound, it couldn't be rescheduled to other CPU cores until it is unbound.
 *
 * \param thread The thread to bind or not.
 * \param bind true for bind, false for unbind.
 */
void spdk_thread_bind(struct spdk_thread *thread, bool bind);

/**
 * Returns whether the thread is bound to its current CPU core.
 *
 * \param thread The thread to query.
 *
 * \return true if bound, false otherwise
 */
bool spdk_thread_is_bound(struct spdk_thread *thread);

/**
 * Mark the thread as exited, failing all future spdk_thread_send_msg(),
 * spdk_poller_register(), and spdk_get_io_channel() calls. May only be called
+1 −1
Original line number Diff line number Diff line
@@ -871,7 +871,7 @@ reactor_post_process_lw_thread(struct spdk_reactor *reactor, struct spdk_lw_thre
		return true;
	}

	if (spdk_unlikely(lw_thread->resched)) {
	if (spdk_unlikely(lw_thread->resched && !spdk_thread_is_bound(thread))) {
		lw_thread->resched = false;
		_reactor_remove_lw_thread(reactor, lw_thread);
		_reactor_schedule_thread(thread);
+2 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
	spdk_thread_get_ctx;
	spdk_thread_get_cpumask;
	spdk_thread_set_cpumask;
	spdk_thread_bind;
	spdk_thread_is_bound;
	spdk_thread_get_from_ctx;
	spdk_thread_poll;
	spdk_thread_next_poller_expiration;
+15 −0
Original line number Diff line number Diff line
@@ -144,6 +144,9 @@ struct spdk_thread {

	int32_t				lock_count;

	/* spdk_thread is bound to current CPU core. */
	bool				is_bound;

	/* Indicates whether this spdk_thread currently runs in interrupt. */
	bool				in_interrupt;
	bool				poller_unregistered;
@@ -588,6 +591,18 @@ spdk_thread_get_app_thread(void)
	return g_app_thread;
}

void
spdk_thread_bind(struct spdk_thread *thread, bool bind)
{
	thread->is_bound = bind;
}

bool
spdk_thread_is_bound(struct spdk_thread *thread)
{
	return thread->is_bound;
}

void
spdk_set_thread(struct spdk_thread *thread)
{
Loading