From 902c9e4de710a5b3640f3ffb33f869ee117fa91a Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Mon, 24 May 2021 13:08:32 -0400 Subject: [PATCH] lib/event: remove new_lcore from lw_thread There is no need to keep new_lcore field. lcore value is enough to determine the target core. Meanwhile _threads_reschedule() can see if the target core matches the one from core_info. Removed _spdk_lw_thread_set_core() since it did not serve much purpose. Signed-off-by: Tomasz Zawadzki Change-Id: I82c7cfebf1107b4a55b2af9b891052084a788907 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8046 Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Reviewed-by: Konrad Sztyber Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins --- include/spdk_internal/event.h | 1 - lib/event/gscheduler.c | 10 +--------- lib/event/reactor.c | 16 +++++----------- lib/event/scheduler_dynamic.c | 7 +++---- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/include/spdk_internal/event.h b/include/spdk_internal/event.h index ff9c7acf3..5684ffed8 100644 --- a/include/spdk_internal/event.h +++ b/include/spdk_internal/event.h @@ -64,7 +64,6 @@ struct spdk_lw_thread { TAILQ_ENTRY(spdk_lw_thread) link; uint64_t tsc_start; uint32_t lcore; - uint32_t new_lcore; bool resched; /* stats over a lifetime of a thread */ struct spdk_thread_stats total_stats; diff --git a/lib/event/gscheduler.c b/lib/event/gscheduler.c index ef96f8f4a..49bb7fc54 100644 --- a/lib/event/gscheduler.c +++ b/lib/event/gscheduler.c @@ -72,9 +72,8 @@ static void balance(struct spdk_scheduler_core_info *cores, int core_count, struct spdk_governor *governor) { struct spdk_scheduler_core_info *core; - struct spdk_lw_thread *thread; struct spdk_governor_capabilities capabilities; - uint32_t i, j; + uint32_t i; int rc; bool turbo_available = false; @@ -82,13 +81,6 @@ balance(struct spdk_scheduler_core_info *cores, int core_count, struct spdk_gove SPDK_ENV_FOREACH_CORE(i) { core = &cores[i]; - for (j = 0; j < core->threads_count; j++) { - thread = core->threads[j]; - - /* do not change thread lcore */ - thread->new_lcore = thread->lcore; - } - rc = governor->get_core_capabilities(core->lcore, &capabilities); if (rc < 0) { SPDK_ERRLOG("failed to get capabilities for core: %u\n", core->lcore); diff --git a/lib/event/reactor.c b/lib/event/reactor.c index e6d817993..6c9c2d4a8 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -698,8 +698,8 @@ _threads_reschedule(struct spdk_scheduler_core_info *cores_info) core = &cores_info[i]; for (j = 0; j < core->threads_count; j++) { lw_thread = core->threads[j]; - if (lw_thread->lcore != lw_thread->new_lcore) { - _spdk_lw_thread_set_core(lw_thread, lw_thread->new_lcore); + if (lw_thread->lcore != i) { + lw_thread->resched = true; } } } @@ -1276,7 +1276,9 @@ _reactor_request_thread_reschedule(struct spdk_thread *thread) lw_thread = spdk_thread_get_ctx(thread); - _spdk_lw_thread_set_core(lw_thread, SPDK_ENV_LCORE_ID_ANY); + assert(lw_thread != NULL); + lw_thread->resched = true; + lw_thread->lcore = SPDK_ENV_LCORE_ID_ANY; current_core = spdk_env_get_current_core(); reactor = spdk_reactor_get(current_core); @@ -1483,14 +1485,6 @@ reactor_interrupt_fini(struct spdk_reactor *reactor) reactor->fgrp = NULL; } -void -_spdk_lw_thread_set_core(struct spdk_lw_thread *thread, uint32_t lcore) -{ - assert(thread != NULL); - thread->lcore = lcore; - thread->resched = true; -} - static int _governor_get_capabilities(uint32_t lcore_id, struct spdk_governor_capabilities *capabilities) { diff --git a/lib/event/scheduler_dynamic.c b/lib/event/scheduler_dynamic.c index b0f65abf5..724ba15ed 100644 --- a/lib/event/scheduler_dynamic.c +++ b/lib/event/scheduler_dynamic.c @@ -154,7 +154,6 @@ balance(struct spdk_scheduler_core_info *cores_info, int cores_count, for (j = 0; j < core->threads_count; j++) { lw_thread = core->threads[j]; - lw_thread->new_lcore = lw_thread->lcore; thread = spdk_thread_get_from_ctx(lw_thread); cpumask = spdk_thread_get_cpumask(thread); @@ -173,7 +172,7 @@ balance(struct spdk_scheduler_core_info *cores_info, int cores_count, } if (spdk_cpuset_get_cpu(cpumask, target_lcore)) { - lw_thread->new_lcore = target_lcore; + lw_thread->lcore = target_lcore; cores_info[target_lcore].pending_threads_count++; core->pending_threads_count--; @@ -188,7 +187,7 @@ balance(struct spdk_scheduler_core_info *cores_info, int cores_count, } } else if (i != g_main_lcore && load < SCHEDULER_LOAD_LIMIT) { /* This thread is idle but not on the main core, so we need to move it to the main core */ - lw_thread->new_lcore = g_main_lcore; + lw_thread->lcore = g_main_lcore; cores_info[g_main_lcore].pending_threads_count++; core->pending_threads_count--; @@ -202,7 +201,7 @@ balance(struct spdk_scheduler_core_info *cores_info, int cores_count, target_lcore = _get_next_target_core(); if (spdk_cpuset_get_cpu(cpumask, target_lcore)) { - lw_thread->new_lcore = target_lcore; + lw_thread->lcore = target_lcore; cores_info[target_lcore].pending_threads_count++; core->pending_threads_count--;