lib/event: change last_stats to only describe last scheduling period

So far the schedulers had to calculate the diff of
current_stats - last_stats on their own to get tsc
from last scheduling period.

Renamed the current_stats to total_stats, but kept the meaning
as stats describing tsc for lifetime of a thread.

Instead change the meaning of the last_stats to describe
the tsc of only last scheduling period and change its name
to current_stats.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I1a165ff7c1afe659b432c3127a351a96878d1f3d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7843
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Tomasz Zawadzki 2021-05-07 11:30:00 -04:00
parent 2cd948c4a6
commit d9f5da13e4
4 changed files with 15 additions and 12 deletions

View File

@ -66,8 +66,10 @@ struct spdk_lw_thread {
uint32_t lcore;
uint32_t new_lcore;
bool resched;
/* stats over a lifetime of a thread */
struct spdk_thread_stats total_stats;
/* stats during the last scheduling period */
struct spdk_thread_stats current_stats;
struct spdk_thread_stats last_stats;
};
/**

View File

@ -674,18 +674,19 @@ static void
_init_thread_stats(struct spdk_reactor *reactor, struct spdk_lw_thread *lw_thread)
{
struct spdk_thread *thread = spdk_thread_get_from_ctx(lw_thread);
struct spdk_thread_stats last_stats;
struct spdk_thread_stats prev_total_stats;
/* Save last stats before replacing them. */
last_stats = lw_thread->current_stats;
/* Read total_stats before updating it to calculate stats during the last scheduling period. */
prev_total_stats = lw_thread->total_stats;
lw_thread->lcore = reactor->lcore;
spdk_set_thread(thread);
spdk_thread_get_stats(&lw_thread->current_stats);
spdk_thread_get_stats(&lw_thread->total_stats);
spdk_set_thread(NULL);
lw_thread->last_stats = last_stats;
lw_thread->current_stats.busy_tsc = lw_thread->total_stats.busy_tsc - prev_total_stats.busy_tsc;
lw_thread->current_stats.idle_tsc = lw_thread->total_stats.idle_tsc - prev_total_stats.idle_tsc;
}
static void
@ -1147,11 +1148,11 @@ _schedule_thread(void *arg1, void *arg2)
reactor = spdk_reactor_get(current_core);
assert(reactor != NULL);
/* Update current_stats to reflect state of thread
/* Update total_stats to reflect state of thread
* at the end of the move. */
thread = spdk_thread_get_from_ctx(lw_thread);
spdk_set_thread(thread);
spdk_thread_get_stats(&lw_thread->current_stats);
spdk_thread_get_stats(&lw_thread->total_stats);
spdk_set_thread(NULL);
TAILQ_INSERT_TAIL(&reactor->threads, lw_thread, link);

View File

@ -68,8 +68,8 @@ _get_thread_load(struct spdk_lw_thread *lw_thread)
{
uint64_t busy, idle;
busy = lw_thread->current_stats.busy_tsc - lw_thread->last_stats.busy_tsc;
idle = lw_thread->current_stats.idle_tsc - lw_thread->last_stats.idle_tsc;
busy = lw_thread->current_stats.busy_tsc;
idle = lw_thread->current_stats.idle_tsc;
if (busy == 0) {
/* No work was done, exit before possible division by 0. */
@ -158,7 +158,7 @@ balance(struct spdk_scheduler_core_info *cores_info, int cores_count,
thread = spdk_thread_get_from_ctx(lw_thread);
cpumask = spdk_thread_get_cpumask(thread);
thread_busy = lw_thread->current_stats.busy_tsc - lw_thread->last_stats.busy_tsc;
thread_busy = lw_thread->current_stats.busy_tsc;
load = _get_thread_load(lw_thread);

View File

@ -824,7 +824,7 @@ test_governor(void)
/* Update last stats so that we don't have to call scheduler twice */
lw_thread = spdk_thread_get_ctx(thread[i]);
lw_thread->last_stats.idle_tsc = 1;
lw_thread->current_stats.idle_tsc = 1;
}
reactor = spdk_reactor_get(0);