Commit 5ba5dde9 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

gscheduler: add percentage variables



Currently the up/down decision is based on comparing idle v. busy,
which implicitly means comparing against 50%.

Likewise the min/max decisions are based on comparing idle v. busy/100
(or vice versa), which implicitly means comparing against 99% (or 1%).

Upcoming patches will allow for configuring these values, so in
preparation for that, create variables for these percentages and do
calculations based on those.

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


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 2779e39b
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -13,6 +13,10 @@
#include "spdk/env.h"
#include "spdk/scheduler.h"

static uint32_t g_max_threshold = 99;
static uint32_t g_adjust_threshold = 50;
static uint32_t g_min_threshold = 1;

static int
init(void)
{
@@ -31,6 +35,8 @@ 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;

@@ -47,17 +53,20 @@ balance(struct spdk_scheduler_core_info *cores, uint32_t core_count)
			return;
		}

		if (core->current_busy_tsc < (core->current_idle_tsc / 100)) {
		total_tsc = core->current_busy_tsc + core->current_idle_tsc;
		busy_pct = core->current_busy_tsc * 100 / total_tsc;

		if (busy_pct < g_min_threshold) {
			rc = governor->set_core_freq_min(core->lcore);
			if (rc < 0) {
				SPDK_ERRLOG("setting to minimal frequency for core %u failed\n", core->lcore);
			}
		} else if (core->current_idle_tsc > core->current_busy_tsc) {
		} else if (busy_pct < g_adjust_threshold) {
			rc = governor->core_freq_down(core->lcore);
			if (rc < 0) {
				SPDK_ERRLOG("lowering frequency for core %u failed\n", core->lcore);
			}
		} else if (core->current_idle_tsc < (core->current_busy_tsc / 100)) {
		} else if (busy_pct >= g_max_threshold) {
			rc = governor->set_core_freq_max(core->lcore);
			if (rc < 0) {
				SPDK_ERRLOG("setting to maximal frequency for core %u failed\n", core->lcore);