Skip to content

Commit ae1bdd2

Browse files
committed
cpufreq: intel_pstate: Adjust frequency percentage computations
Adjust frequency percentage computations in update_cpu_qos_request() to avoid going above the exact numerical percentage in the FREQ_QOS_MAX case. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Zihuan Zhang <zhangzihuan@kylinos.cn> Link: https://patch.msgid.link/3395556.44csPzL39Z@rafael.j.wysocki [ rjw: Rename "cpu" to "cpudata" and "cpunum" to "cpu" ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent f1bbf5b commit ae1bdd2

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

drivers/cpufreq/intel_pstate.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,8 +1655,8 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,
16551655
static void update_cpu_qos_request(int cpu, enum freq_qos_req_type type)
16561656
{
16571657
struct cpudata *cpudata = all_cpu_data[cpu];
1658+
unsigned int freq = cpudata->pstate.turbo_freq;
16581659
struct freq_qos_request *req;
1659-
unsigned int freq, perf_pct;
16601660

16611661
struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpu);
16621662
if (!policy)
@@ -1670,14 +1670,12 @@ static void update_cpu_qos_request(int cpu, enum freq_qos_req_type type)
16701670
intel_pstate_get_hwp_cap(cpudata);
16711671

16721672
if (type == FREQ_QOS_MIN) {
1673-
perf_pct = global.min_perf_pct;
1673+
freq = DIV_ROUND_UP(freq * global.min_perf_pct, 100);
16741674
} else {
16751675
req++;
1676-
perf_pct = global.max_perf_pct;
1676+
freq = (freq * global.max_perf_pct) / 100;
16771677
}
16781678

1679-
freq = DIV_ROUND_UP(cpudata->pstate.turbo_freq * perf_pct, 100);
1680-
16811679
if (freq_qos_update_request(req, freq) < 0)
16821680
pr_warn("Failed to update freq constraint: CPU%d\n", cpu);
16831681
}

0 commit comments

Comments
 (0)