From ba7aac83edb09a4432cc9c4801b3f59329f48196 Mon Sep 17 00:00:00 2001 From: Liu Xiaodong Date: Fri, 5 Mar 2021 07:34:08 -0500 Subject: [PATCH] reactor: get_rusage directly in reactor_run Move get_rusage directly into reactor_run(), then both poll mode and interrupt mode can check rusage info. Change-Id: Id5926752cfb19c13cb969fbfbb35f643e5d49d9a Signed-off-by: Liu Xiaodong Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6718 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto Reviewed-by: Tomasz Zawadzki Reviewed-by: Maciej Szwed --- lib/event/reactor.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/event/reactor.c b/lib/event/reactor.c index 03f73e144..b2c802180 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -871,8 +871,6 @@ reactor_interrupt_run(struct spdk_reactor *reactor) int block_timeout = -1; /* _EPOLL_WAIT_FOREVER */ spdk_fd_group_wait(reactor->fgrp, block_timeout); - - /* TODO: g_framework_context_switch_monitor_enabled */ } static void @@ -899,13 +897,6 @@ _reactor_run(struct spdk_reactor *reactor) reactor_post_process_lw_thread(reactor, lw_thread); } - - if (g_framework_context_switch_monitor_enabled) { - if ((reactor->last_rusage + g_rusage_period) < reactor->tsc_last) { - get_rusage(reactor); - reactor->last_rusage = reactor->tsc_last; - } - } } static int @@ -935,6 +926,13 @@ reactor_run(void *arg) _reactor_run(reactor); } + if (g_framework_context_switch_monitor_enabled) { + if ((reactor->last_rusage + g_rusage_period) < reactor->tsc_last) { + get_rusage(reactor); + reactor->last_rusage = reactor->tsc_last; + } + } + if (spdk_unlikely(g_scheduler_period > 0 && (reactor->tsc_last - last_sched) > g_scheduler_period && reactor == g_scheduling_reactor &&