Commit 54a1bea0 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

scheduler/gscheduler: break out busy_pct calc to a helper function



Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: I0d87a31a6f12387c94aa315d6623230bcbd096eb
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23701


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent a75a557b
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -29,13 +29,21 @@ deinit(void)
	spdk_governor_set(NULL);
}

static uint32_t
calculate_busy_pct(struct spdk_scheduler_core_info *core)
{
	uint64_t total_tsc;

	total_tsc = core->current_busy_tsc + core->current_idle_tsc;
	return core->current_busy_tsc * 100 / total_tsc;
}

static void
balance(struct spdk_scheduler_core_info *cores, uint32_t core_count)
{
	struct spdk_governor *governor;
	struct spdk_scheduler_core_info *core;
	struct spdk_governor_capabilities capabilities;
	uint64_t total_tsc;
	uint32_t busy_pct;
	uint32_t i;
	int rc;
@@ -53,8 +61,7 @@ balance(struct spdk_scheduler_core_info *cores, uint32_t core_count)
			return;
		}

		total_tsc = core->current_busy_tsc + core->current_idle_tsc;
		busy_pct = core->current_busy_tsc * 100 / total_tsc;
		busy_pct = calculate_busy_pct(core);

		if (busy_pct < g_min_threshold) {
			rc = governor->set_core_freq_min(core->lcore);