reactor: Change the context_switch period to microseconds
Signed-off-by: suhua <suhua1@kingsoft.com> Change-Id: I95a4cc3cb5bef37e31a630171a47e28f14331494 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475333 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
b99df8ee33
commit
25baf7148d
@ -282,6 +282,7 @@ _spdk_event_queue_run_batch(struct spdk_reactor *reactor)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 1s */
|
||||||
#define CONTEXT_SWITCH_MONITOR_PERIOD 1000000
|
#define CONTEXT_SWITCH_MONITOR_PERIOD 1000000
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -340,6 +341,7 @@ _spdk_reactor_run(void *arg)
|
|||||||
uint64_t last_rusage = 0;
|
uint64_t last_rusage = 0;
|
||||||
struct spdk_lw_thread *lw_thread, *tmp;
|
struct spdk_lw_thread *lw_thread, *tmp;
|
||||||
char thread_name[32];
|
char thread_name[32];
|
||||||
|
uint64_t rusage_period = 0;
|
||||||
|
|
||||||
SPDK_NOTICELOG("Reactor started on core %u\n", reactor->lcore);
|
SPDK_NOTICELOG("Reactor started on core %u\n", reactor->lcore);
|
||||||
|
|
||||||
@ -349,6 +351,8 @@ _spdk_reactor_run(void *arg)
|
|||||||
snprintf(thread_name, sizeof(thread_name), "reactor_%u", reactor->lcore);
|
snprintf(thread_name, sizeof(thread_name), "reactor_%u", reactor->lcore);
|
||||||
_set_thread_name(thread_name);
|
_set_thread_name(thread_name);
|
||||||
|
|
||||||
|
rusage_period = (CONTEXT_SWITCH_MONITOR_PERIOD * spdk_get_ticks_hz()) / SPDK_SEC_TO_USEC;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
uint64_t now;
|
uint64_t now;
|
||||||
int rc;
|
int rc;
|
||||||
@ -374,7 +378,7 @@ _spdk_reactor_run(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g_framework_monitor_context_switch_enabled) {
|
if (g_framework_monitor_context_switch_enabled) {
|
||||||
if ((last_rusage + CONTEXT_SWITCH_MONITOR_PERIOD) < now) {
|
if ((last_rusage + rusage_period) < now) {
|
||||||
get_rusage(reactor);
|
get_rusage(reactor);
|
||||||
last_rusage = now;
|
last_rusage = now;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user