cpufreq: CPPC: Correct desired_perf calculation
PATCH 1/1 cpufreq: CPPC: Correct desired_perf calculation
The desired_perf is an abstract performance number. Its value should be in the range of [lowest perf, highest perf] of CPPC. The correct calculation is
desired_perf = freq * cppc_highest_perf / cppc_dmi_max_khz
--- drivers/cpufreq/cppc_cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cppc_cpufreq.c +1 -1
@@ -84,7 +84,7 @@ static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, cpu = all_cpu_data[policy->cpu]; - cpu->perf_ctrls.desired_perf = (u64 )target_freq * policy->max / cppc_dmi_max_khz; + cpu->perf_ctrls.desired_perf = (u64 )target_freq * cpu->perf_caps.highest_perf / cppc_dmi_max_khz; freqs.old = policy->cur; freqs.new = target_freq;
Signature · 1 line
1.9.1
Quoted 16 lines · Hoan Tran
The
desired_perfis an abstract performance number. Its value should be in the range of [lowest perf, highest perf] of CPPC. The correct calculation is
desired_perf= freq *cppc_highest_perf/cppc_dmi_max_khzSigned-off-by Hoan Tran <[email protected]>--- drivers/cpufreq/cppc_cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cpufreq/cppc_cpufreq.c +0
-0
drivers/cpufreq/cppc_cpufreq.c static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, · line 90
Quoted 8 lines
drivers/cpufreq/cppc_cpufreq.c +1
-1@@ -84,7 +84,7 @@ static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, cpu = all_cpu_data[policy->cpu]; - cpu->perf_ctrls.desired_perf = (u64 )target_freq * policy->max / cppc_dmi_max_khz; + cpu->perf_ctrls.desired_perf = (u64 )target_freq * cpu->perf_caps.highest_perf / cppc_dmi_max_khz; freqs.old = policy->cur; freqs.new = target_freq;
This patch has already been applied AFAICS.
Thanks,
Rafael
Hi Rafael,
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · Hoan Tran
The
desired_perfis an abstract performance number. Its value should be in the range of [lowest perf, highest perf] of CPPC. The correct calculation is
desired_perf= freq *cppc_highest_perf/cppc_dmi_max_khzSigned-off-by Hoan Tran <[email protected]>--- drivers/cpufreq/cppc_cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cpufreq/cppc_cpufreq.c +0
-0@@ -84,7 +84,7 @@ static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, cpu = all_cpu_data[policy->cpu];
Quoted 9 lines
drivers/cpufreq/cppc_cpufreq.c static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, · line 90
Quoted 6 lines
drivers/cpufreq/cppc_cpufreq.c +1
-1- cpu->perf_ctrls.desired_perf = (u64 )target_freq * policy->max / cppc_dmi_max_khz; + cpu->perf_ctrls.desired_perf = (u64 )target_freq * cpu->perf_caps.highest_perf / cppc_dmi_max_khz; freqs.old = policy->cur; freqs.new = target_freq;This patch has already been applied AFAICS.
You mean this applied patch "cpufreq: CPPC: Avoid overflow when calculating desired_perf"
This is another the bug, not the overflow bug.
Thanks
Hoan
Quoted 3 lines
Thanks,
Rafael
Quoted 15 lines · Hoan Tran
The
desired_perfis an abstract performance number. Its value should be in the range of [lowest perf, highest perf] of CPPC. The correct calculation is
desired_perf= freq *cppc_highest_perf/cppc_dmi_max_khzSigned-off-by Hoan Tran <[email protected]>--- drivers/cpufreq/cppc_cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cpufreq/cppc_cpufreq.c +0
-0
drivers/cpufreq/cppc_cpufreq.c static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, · line 89
Quoted 7 lines
drivers/cpufreq/cppc_cpufreq.c +1
-1@@ -84,7 +84,7 @@ static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, cpu = all_cpu_data[policy->cpu]; - cpu->perf_ctrls.desired_perf = (u64 )target_freq * policy->max / cppc_dmi_max_khz; + cpu->perf_ctrls.desired_perf = (u64 )target_freq * cpu->perf_caps.highest_perf / cppc_dmi_max_khz; freqs.old = policy->cur; freqs.new = target_freq;
I am not sure what the calculations should be like, but I don't have any objections against applying this..
Signature · 1 line
viresh
Hi Hoan,
Quoted 15 lines · Hoan Tran
The
desired_perfis an abstract performance number. Its value should be in the range of [lowest perf, highest perf] of CPPC. The correct calculation is
desired_perf= freq *cppc_highest_perf/cppc_dmi_max_khzSigned-off-by Hoan Tran <[email protected]>--- drivers/cpufreq/cppc_cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cpufreq/cppc_cpufreq.c +0
-0
drivers/cpufreq/cppc_cpufreq.c static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, · line 87
Quoted 5 lines
drivers/cpufreq/cppc_cpufreq.c +1
-1@@ -84,7 +84,7 @@ static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, cpu = all_cpu_data[policy->cpu]; - cpu->perf_ctrls.desired_perf = (u64 )target_freq * policy->max / cppc_dmi_max_khz; + cpu->perf_ctrls.desired_perf = (u64 )target_freq * cpu->perf_caps.highest_perf / cppc_dmi_max_khz;
The patch looks good, I suppose we can add a small optimization. We can do a simple check to see if the newly computed desired_perf is same as old one, If it is same we can just return here instead of calling cppc_set_perf with same desired_perf value.
Thanks,
Prashanth
[Resend with plain text mode]
Hi Prashanth,
Quoted 19 lines · Prashanth
Hi Hoan,
Quoted 16 lines · Hoan Tran
The
desired_perfis an abstract performance number. Its value should be in the range of [lowest perf, highest perf] of CPPC. The correct calculation is
desired_perf= freq *cppc_highest_perf/cppc_dmi_max_khzSigned-off-by Hoan Tran <[email protected]>--- drivers/cpufreq/cppc_cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cpufreq/cppc_cpufreq.c +0
-0@@ -84,7 +84,7 @@ static int cppc_cpufreq_set_target(struct cpufreq_policy *policy,
Quoted 7 lines
drivers/cpufreq/cppc_cpufreq.c static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, · line 87
Quoted 4 lines
drivers/cpufreq/cppc_cpufreq.c +1
-1cpu = all_cpu_data[policy->cpu]; - cpu->perf_ctrls.desired_perf = (u64 )target_freq * policy->max / cppc_dmi_max_khz; + cpu->perf_ctrls.desired_perf = (u64 )target_freq * cpu->perf_caps.highest_perf / cppc_dmi_max_khz;The patch looks good, I suppose we can add a small optimization. We can do a simple check to see if the newly computed
desired_perfis same as old one, If it is same we can just return here instead of callingcppc_set_perfwith samedesired_perfvalue.
That's a good point. I can add a check into this patch.
Thanks
Hoan
Quoted 3 lines
Thanks,
Prashanth