reactor: extract reactor_post_process_lw_thread
Change-Id: I2761db384f78529525b7f1eb3c9c959a7b885ede Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4756 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
c5d1e7f171
commit
7d19e50a54
@ -309,6 +309,32 @@ _set_thread_name(const char *thread_name)
|
|||||||
static int _reactor_schedule_thread(struct spdk_thread *thread);
|
static int _reactor_schedule_thread(struct spdk_thread *thread);
|
||||||
static uint64_t g_rusage_period;
|
static uint64_t g_rusage_period;
|
||||||
|
|
||||||
|
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;
|
||||||
|
TAILQ_REMOVE(&reactor->threads, lw_thread, link);
|
||||||
|
assert(reactor->thread_count > 0);
|
||||||
|
reactor->thread_count--;
|
||||||
|
_reactor_schedule_thread(thread);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spdk_unlikely(spdk_thread_is_exited(thread) &&
|
||||||
|
spdk_thread_is_idle(thread))) {
|
||||||
|
TAILQ_REMOVE(&reactor->threads, lw_thread, link);
|
||||||
|
assert(reactor->thread_count > 0);
|
||||||
|
reactor->thread_count--;
|
||||||
|
spdk_thread_destroy(thread);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_reactor_run(struct spdk_reactor *reactor)
|
_reactor_run(struct spdk_reactor *reactor)
|
||||||
{
|
{
|
||||||
@ -331,23 +357,7 @@ _reactor_run(struct spdk_reactor *reactor)
|
|||||||
}
|
}
|
||||||
reactor->tsc_last = now;
|
reactor->tsc_last = now;
|
||||||
|
|
||||||
if (spdk_unlikely(lw_thread->resched)) {
|
reactor_post_process_lw_thread(reactor, lw_thread);
|
||||||
lw_thread->resched = false;
|
|
||||||
TAILQ_REMOVE(&reactor->threads, lw_thread, link);
|
|
||||||
assert(reactor->thread_count > 0);
|
|
||||||
reactor->thread_count--;
|
|
||||||
_reactor_schedule_thread(thread);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (spdk_unlikely(spdk_thread_is_exited(thread) &&
|
|
||||||
spdk_thread_is_idle(thread))) {
|
|
||||||
TAILQ_REMOVE(&reactor->threads, lw_thread, link);
|
|
||||||
assert(reactor->thread_count > 0);
|
|
||||||
reactor->thread_count--;
|
|
||||||
spdk_thread_destroy(thread);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_framework_context_switch_monitor_enabled) {
|
if (g_framework_context_switch_monitor_enabled) {
|
||||||
|
Loading…
Reference in New Issue
Block a user