lib/event: Count thread run time correctly on multiple threads per core

This patch updates reactor to count thread run time correctly
on multiple SPDK threads per CPU core configuration by using
the refined spdk_thread_poll().

Add tsc_last to struct spdk_reactor to use the end time of the
last thread as the start time of the next thread.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I21042867885d289ff0c23bf2a9ba6a8076a59673
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1256
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: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-03-13 12:03:38 +09:00 committed by Tomasz Zawadzki
parent 2139be1598
commit 80323e2066
2 changed files with 8 additions and 8 deletions

View File

@ -78,6 +78,8 @@ struct spdk_reactor {
uint32_t reserved : 31;
} flags;
uint64_t tsc_last;
struct spdk_ring *events;
/* The last known rusage values */

View File

@ -313,19 +313,15 @@ static uint64_t g_rusage_period;
static void
reactor_run(struct spdk_reactor *reactor)
{
uint64_t now;
struct spdk_thread *thread;
struct spdk_lw_thread *lw_thread, *tmp;
/* For each loop through the reactor, capture the time. This time
* is used for all threads. */
now = spdk_get_ticks();
_spdk_event_queue_run_batch(reactor);
TAILQ_FOREACH_SAFE(lw_thread, &reactor->threads, link, tmp) {
thread = spdk_thread_get_from_ctx(lw_thread);
spdk_thread_poll(thread, 0, now);
spdk_thread_poll(thread, 0, reactor->tsc_last);
reactor->tsc_last = spdk_thread_get_last_tsc(thread);
if (spdk_unlikely(lw_thread->resched)) {
lw_thread->resched = false;
@ -347,9 +343,9 @@ reactor_run(struct spdk_reactor *reactor)
}
if (g_framework_context_switch_monitor_enabled) {
if ((reactor->last_rusage + g_rusage_period) < now) {
if ((reactor->last_rusage + g_rusage_period) < reactor->tsc_last) {
get_rusage(reactor);
reactor->last_rusage = now;
reactor->last_rusage = reactor->tsc_last;
}
}
}
@ -371,6 +367,8 @@ _spdk_reactor_run(void *arg)
snprintf(thread_name, sizeof(thread_name), "reactor_%u", reactor->lcore);
_set_thread_name(thread_name);
reactor->tsc_last = spdk_get_ticks();
while (1) {
reactor_run(reactor);