lib/event: calculate reactor tsc from last scheduling period

This patch expands spdk_scheduler_core_info with two new
fields that will contain core stats only from last scheduling
period.

This will make sure that schedulers do not have to keep track
and calculate this value on their own.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I3aa7dfa6a60c1d14d95a0e684e84c2e83f0a4496
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8048
Reviewed-by: Jim Harris <james.r.harris@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-24 12:34:03 -04:00
parent da11c9d2a2
commit abbfa1a5d1
3 changed files with 7 additions and 8 deletions

View File

@ -262,6 +262,9 @@ struct spdk_scheduler_core_info {
/* stats over a lifetime of a core */
uint64_t total_idle_tsc;
uint64_t total_busy_tsc;
/* stats during the last scheduling period */
uint64_t current_idle_tsc;
uint64_t current_busy_tsc;
uint32_t lcore;
uint32_t threads_count;

View File

@ -792,7 +792,9 @@ _reactors_scheduler_gather_metrics(void *arg1, void *arg2)
reactor->flags.is_scheduling = true;
core_info = &g_core_infos[reactor->lcore];
core_info->lcore = reactor->lcore;
core_info->current_idle_tsc = reactor->idle_tsc - core_info->total_idle_tsc;
core_info->total_idle_tsc = reactor->idle_tsc;
core_info->current_busy_tsc = reactor->busy_tsc - core_info->total_busy_tsc;
core_info->total_busy_tsc = reactor->busy_tsc;
core_info->interrupt_mode = reactor->in_interrupt;

View File

@ -43,7 +43,6 @@
static uint32_t g_next_lcore = SPDK_ENV_LCORE_ID_ANY;
static uint32_t g_main_lcore;
static bool g_core_mngmnt_available;
uint64_t g_last_main_core_busy, g_last_main_core_idle;
#define SCHEDULER_THREAD_BUSY 100
#define SCHEDULER_LOAD_LIMIT 50
@ -89,9 +88,6 @@ init(struct spdk_governor *governor)
rc = _spdk_governor_set("dpdk_governor");
g_core_mngmnt_available = !rc;
g_last_main_core_busy = 0;
g_last_main_core_idle = 0;
return 0;
}
@ -139,10 +135,8 @@ balance(struct spdk_scheduler_core_info *cores_info, int cores_count,
uint8_t load;
bool busy_threads_present = false;
main_core_busy = cores_info[g_main_lcore].total_busy_tsc - g_last_main_core_busy;
main_core_idle = cores_info[g_main_lcore].total_idle_tsc - g_last_main_core_idle;
g_last_main_core_busy = cores_info[g_main_lcore].total_busy_tsc;
g_last_main_core_idle = cores_info[g_main_lcore].total_idle_tsc;
main_core_busy = cores_info[g_main_lcore].current_busy_tsc;
main_core_idle = cores_info[g_main_lcore].current_idle_tsc;
SPDK_ENV_FOREACH_CORE(i) {
cores_info[i].pending_threads_count = cores_info[i].threads_count;