lib/event: update current_stats at the time of thread reschedule

_reactor_schedule_thread() zeroes out the lw_thread on move.

To properly calculate thread stats since the move,
save them right after reschedule.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I44cc3b5907adda35b3117c2dd7268dc813d59853
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7919
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Tomasz Zawadzki 2021-05-18 06:19:40 -04:00
parent e0d448e7f6
commit 3db73426f2

View File

@ -1131,6 +1131,7 @@ static void
_schedule_thread(void *arg1, void *arg2)
{
struct spdk_lw_thread *lw_thread = arg1;
struct spdk_thread *thread;
struct spdk_reactor *reactor;
uint32_t current_core;
int efd;
@ -1139,15 +1140,20 @@ _schedule_thread(void *arg1, void *arg2)
reactor = spdk_reactor_get(current_core);
assert(reactor != NULL);
/* Update current_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_set_thread(NULL);
TAILQ_INSERT_TAIL(&reactor->threads, lw_thread, link);
reactor->thread_count++;
/* Operate thread intr if running with full interrupt ability */
if (spdk_interrupt_mode_is_enabled()) {
int rc;
struct spdk_thread *thread;
thread = spdk_thread_get_from_ctx(lw_thread);
efd = spdk_thread_get_interrupt_fd(thread);
rc = spdk_fd_group_add(reactor->fgrp, efd, thread_process_interrupts, thread);
if (rc < 0) {