From ccf0eccbf11531b2bf79dbaa4545abf08ce02d24 Mon Sep 17 00:00:00 2001 From: hanabbi Date: Mon, 24 Apr 2023 14:08:57 +0900 Subject: [PATCH] fix(sys-clk-oc): improve governor by changing get_next_freq algorithm use freq set in profile as max_freq instead of last entry in table --- Source/sys-clk-OC/sysmodule/src/oc_extra.cpp | 9 ++++++--- Source/sys-clk-OC/sysmodule/src/oc_extra.h | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/sys-clk-OC/sysmodule/src/oc_extra.cpp b/Source/sys-clk-OC/sysmodule/src/oc_extra.cpp index 005413d6..4084dbec 100644 --- a/Source/sys-clk-OC/sysmodule/src/oc_extra.cpp +++ b/Source/sys-clk-OC/sysmodule/src/oc_extra.cpp @@ -140,8 +140,10 @@ namespace GovernorImpl { // Schedutil: https://github.com/torvalds/linux/blob/master/kernel/sched/cpufreq_schedutil.c // C = 1.25, tipping-point 80.0% (used in Linux schedutil), 1.25 -> 1 + (1 >> 2) // C = 1.5, tipping-point 66.7%, 1.5 -> 1 + (1 >> 1) -// Utilization is frequency-invariant (normalized): -// target_freq = C * max_freq(ref_freq) * util / max +// Utilization is frequency-invariant : +// target_freq = C * max_freq * util / max +// Approximate the would-be frequency-invariant utilization (normalized) : +// target_freq = C * curr_freq * util_raw / max void BaseGovernor::ApplyNewFreqFromNormUtil(uint32_t normUtil) { uint32_t curr_hz = m_target_hz; @@ -154,7 +156,8 @@ void BaseGovernor::ApplyNewFreqFromNormUtil(uint32_t normUtil) { return *(--p); }; - uint32_t next_freq = m_ref_hz / UTIL_MAX * normUtil; + //uint32_t next_freq = m_ref_hz / UTIL_MAX * normUtil; + uint32_t next_freq = max_hz / UTIL_MAX * normUtil; next_freq += next_freq >> 1; uint32_t new_hz; diff --git a/Source/sys-clk-OC/sysmodule/src/oc_extra.h b/Source/sys-clk-OC/sysmodule/src/oc_extra.h index b0ab1c34..c80a4068 100644 --- a/Source/sys-clk-OC/sysmodule/src/oc_extra.h +++ b/Source/sys-clk-OC/sysmodule/src/oc_extra.h @@ -91,7 +91,8 @@ namespace GovernorImpl { protected: uint32_t CalcNormalizedUtil(uint32_t rawUtil) { - return ((uint64_t)rawUtil * m_target_hz / m_ref_hz); + //return ((uint64_t)rawUtil * m_target_hz / m_ref_hz); + return ((uint64_t)rawUtil * m_target_hz / max_hz); }; void ApplyNewFreqFromNormUtil(uint32_t norm);