Commit 0859c837 authored by yidong0635's avatar yidong0635 Committed by Tomasz Zawadzki
Browse files

reactor: Construct a function to do common code.



remove lw_thread in a static function.

Signed-off-by: default avataryidong0635 <dongx.yi@intel.com>
Change-Id: Iade1cb6c88e8aba4ca92c22d2596b8b3dea01ff5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6311


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarXiaodong Liu <xiaodong.liu@intel.com>
parent 92e49c00
Loading
Loading
Loading
Loading
+20 −29
Original line number Diff line number Diff line
@@ -819,14 +819,12 @@ _reactors_scheduler_gather_metrics(void *arg1, void *arg2)
static int _reactor_schedule_thread(struct spdk_thread *thread);
static uint64_t g_rusage_period;

static bool
reactor_post_process_lw_thread(struct spdk_reactor *reactor, struct spdk_lw_thread *lw_thread)
static void
_reactor_remove_lw_thread(struct spdk_reactor *reactor, struct spdk_lw_thread *lw_thread)
{
	struct spdk_thread	*thread = spdk_thread_get_from_ctx(lw_thread);
	int efd;

	if (spdk_unlikely(lw_thread->resched)) {
		lw_thread->resched = false;
	TAILQ_REMOVE(&reactor->threads, lw_thread, link);
	assert(reactor->thread_count > 0);
	reactor->thread_count--;
@@ -836,6 +834,16 @@ reactor_post_process_lw_thread(struct spdk_reactor *reactor, struct spdk_lw_thre
		efd = spdk_thread_get_interrupt_fd(thread);
		spdk_fd_group_remove(reactor->fgrp, efd);
	}
}

static bool
reactor_post_process_lw_thread(struct spdk_reactor *reactor, struct spdk_lw_thread *lw_thread)
{
	struct spdk_thread *thread = spdk_thread_get_from_ctx(lw_thread);

	if (spdk_unlikely(lw_thread->resched)) {
		lw_thread->resched = false;
		_reactor_remove_lw_thread(reactor, lw_thread);
		_reactor_schedule_thread(thread);
		return true;
	}
@@ -843,15 +851,7 @@ reactor_post_process_lw_thread(struct spdk_reactor *reactor, struct spdk_lw_thre
	if (spdk_unlikely(spdk_thread_is_exited(thread) &&
			  spdk_thread_is_idle(thread))) {
		if (reactor->flags.is_scheduling == false) {
			TAILQ_REMOVE(&reactor->threads, lw_thread, link);
			assert(reactor->thread_count > 0);
			reactor->thread_count--;

			/* Operate thread intr if running with full interrupt ability */
			if (spdk_interrupt_mode_is_enabled()) {
				efd = spdk_thread_get_interrupt_fd(thread);
				spdk_fd_group_remove(reactor->fgrp, efd);
			}
			_reactor_remove_lw_thread(reactor, lw_thread);
			spdk_thread_destroy(thread);
			return true;
		}
@@ -963,16 +963,7 @@ reactor_run(void *arg)
			thread = spdk_thread_get_from_ctx(lw_thread);
			spdk_set_thread(thread);
			if (spdk_thread_is_exited(thread)) {
				TAILQ_REMOVE(&reactor->threads, lw_thread, link);
				assert(reactor->thread_count > 0);
				reactor->thread_count--;

				/* Operate thread intr if running with full interrupt ability */
				if (spdk_interrupt_mode_is_enabled()) {
					int efd = spdk_thread_get_interrupt_fd(thread);

					spdk_fd_group_remove(reactor->fgrp, efd);
				}
				_reactor_remove_lw_thread(reactor, lw_thread);
				spdk_thread_destroy(thread);
			} else {
				spdk_thread_poll(thread, 0, 0);