intel_pstate: Use avg_pstate instead of current_pstate
Subsystems (2)
PATCH v4 1/1 intel_pstate: Use avg_pstate instead of current_pstate
The result returned by pid_calc() is subtracted from current_pstate (which is the pstate requested during the last period) in order to obtain the target pstate for the current iteration. However, current_pstate may not reflect the real current P-state of the CPU. In particular, that P-state may be higher because of the frequency sharing per module.
The theory is:
- The load is the percentage of time spent in C0 and is related to the average frequency during the same period (We'll not have the same load at 1GHz or at 2GHz for the same task running).
- The current frequency can be completely different than the average frequency (because of frequency sharing or throttling).
=> The frequency shift computed by the pid_calc is based on the load, so it must be applied to the frequency with which the load was measured.
Using the average pstate instead of current pstate solve some migration issues (e.g when a task migrates from one core to another in the same package/module and all of the cores in there except for that particular one are basically idle).
Performance and power comparison with this patch on Android:
IPLoad+Avg-Pstate vs IP Load:
Benchmark ∆Perf ∆Power FishTank 10.45% 3.1% SmartBench-Gaming -0.1% -10.4% SmartBench-Productivity -0.8% -10.4% CandyCrush n/a -17.4% AngryBirds n/a -5.9% videoPlayback n/a -13.9% audioPlayback n/a -4.9% IcyRocks-20-50 0.0% -38.4% iozone RR -0.16% -1.3% iozone RW 0.74% -1.3%
Comparison with the perf algorithm:
(this patch in cpu_load vs Core algorithm)
Benchmark ∆Perf ∆Power
SmartBench-Gaming -0.58% -22.8%
SmartBench-Productivity 0.82%
CandyCrush n/a -20.8% AngryBirds n/a -37.0% videoPlayback n/a -53.4% audioPlayback n/a -2.1%
iozone RR -0.55% -13.29%
iozone RW 2.22%
=> No regression > 1% observed and a huge power improvement!
--- drivers/cpufreq/intel_pstate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/cpufreq/intel_pstate.c +7 -1
@@ -919,6 +919,12 @@ static inline int32_t get_avg_frequency(struct cpudata *cpu) cpu->pstate.scaling, cpu->sample.mperf); } +static inline int32_t get_avg_pstate (struct cpudata *cpu) +{ +return div64_u64 (cpu->pstate.max_pstate_physical * cpu->sample.aperf, + cpu->sample.mperf); +} +static inline int32_t get_target_pstate_use_cpu_load (struct cpudata *cpu) {struct sample *sample = &cpu->sample;
@@ -951,7 +957,7 @@ static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu) cpu_load =div64_u64 (int_tofp (100 ) * mperf, sample->tsc); cpu->sample.busy_scaled = cpu_load; -return cpu->pstate.current_pstate -pid_calc (&cpu->pid, cpu_load); +return get_avg_pstate (cpu) -pid_calc (&cpu->pid, cpu_load); }static inline int32_t get_target_pstate_use_performance (struct cpudata *cpu)
Signature · 1 line
1.9.1
PATCH v4 1/1 intel_pstate: Use avg_pstate instead of current_pstate
The result returned by pid_calc() is subtracted from current_pstate (which is the pstate requested during the last period) in order to obtain the target pstate for the current iteration. However, current_pstate may not reflect the real current P-state of the CPU. In particular, that P-state may be higher because of the frequency sharing per module.
The theory is:
- The load is the percentage of time spent in C0 and is related to the average frequency during the same period (We'll not have the same load at 1GHz or at 2GHz for the same task running).
- The current frequency can be completely different than the average frequency (because of frequency sharing or throttling).
=> The frequency shift computed by the pid_calc is based on the load, so it must be applied to the frequency with which the load was measured.
Using the average pstate instead of current pstate solve some migration issues (e.g when a task migrates from one core to another in the same package/module and all of the cores in there except for that particular one are basically idle).
Performance and power comparison with this patch on Android:
IPLoad+Avg-Pstate vs IP Load:
Benchmark ∆Perf ∆Power FishTank 10.45% 3.1% SmartBench-Gaming -0.1% -10.4% SmartBench-Productivity -0.8% -10.4% CandyCrush n/a -17.4% AngryBirds n/a -5.9% videoPlayback n/a -13.9% audioPlayback n/a -4.9% IcyRocks-20-50 0.0% -38.4% iozone RR -0.16% -1.3% iozone RW 0.74% -1.3%
Comparison with the perf algorithm:
(this patch in cpu_load vs Core algorithm)
Benchmark ∆Perf ∆Power
SmartBench-Gaming -0.58% -22.8%
SmartBench-Productivity 0.82%
CandyCrush n/a -20.8% AngryBirds n/a -37.0% videoPlayback n/a -53.4% audioPlayback n/a -2.1%
iozone RR -0.55% -13.29%
iozone RW 2.22%
=> No regression > 1% observed and a huge power improvement!
--- drivers/cpufreq/intel_pstate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/cpufreq/intel_pstate.c +7 -1
@@ -919,6 +919,12 @@ static inline int32_t get_avg_frequency(struct cpudata *cpu) cpu->pstate.scaling, cpu->sample.mperf); } +static inline int32_t get_avg_pstate (struct cpudata *cpu) +{ +return div64_u64 (cpu->pstate.max_pstate_physical * cpu->sample.aperf, + cpu->sample.mperf); +} +static inline int32_t get_target_pstate_use_cpu_load (struct cpudata *cpu) {struct sample *sample = &cpu->sample;
@@ -951,7 +957,7 @@ static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu) cpu_load =div64_u64 (int_tofp (100 ) * mperf, sample->tsc); cpu->sample.busy_scaled = cpu_load; -return cpu->pstate.current_pstate -pid_calc (&cpu->pid, cpu_load); +return get_avg_pstate (cpu) -pid_calc (&cpu->pid, cpu_load); }static inline int32_t get_target_pstate_use_performance (struct cpudata *cpu)
Signature · 1 line
1.9.1
Quoted 51 lines · Philippe Longepe
The result returned by
pid_calc()is subtracted fromcurrent_pstate(which is the pstate requested during the last period) in order to obtain the target pstate for the current iteration. However,current_pstatemay not reflect the real current P-state of the CPU. In particular, that P-state may be higher because of the frequency sharing per module.The theory is:
- The load is the percentage of time spent in C0 and is related to the average frequency during the same period (We'll not have the same load at 1GHz or at 2GHz for the same task running).
- The current frequency can be completely different than the average frequency (because of frequency sharing or throttling).
=> The frequency shift computed by the
pid_calcis based on the load, so it must be applied to the frequency with which the load was measured.Using the average pstate instead of current pstate solve some migration issues (e.g when a task migrates from one core to another in the same package/module and all of the cores in there except for that particular one are basically idle).
Performance and power comparison with this patch on Android:
IPLoad+Avg-Pstate vs IP Load:
Benchmark ∆Perf ∆Power FishTank 10.45% 3.1% SmartBench-Gaming -0.1% -10.4% SmartBench-Productivity -0.8% -10.4% CandyCrush n/a -17.4% AngryBirds n/a -5.9% videoPlayback n/a -13.9% audioPlayback n/a -4.9% IcyRocks-20-50 0.0% -38.4% iozone RR -0.16% -1.3% iozone RW 0.74% -1.3%Comparison with the perf algorithm:
(this patch incpu_loadvs Core algorithm)Benchmark ∆Perf ∆Power
SmartBench-Gaming -0.58% -22.8%
SmartBench-Productivity 0.82%CandyCrush n/a -20.8% AngryBirds n/a -37.0% videoPlayback n/a -53.4% audioPlayback n/a -2.1%
Quoted 6 lines
iozone RR -0.55% -13.29%
iozone RW 2.22%=> No regression > 1% observed and a huge power improvement!
Signed-off-by Philippe Longepe <[email protected]>
Srinivas, what about this one? Yes? No? Maybe?
Quoted 31 lines
--- drivers/cpufreq/intel_pstate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/cpufreq/intel_pstate.c +7
-1@@ -919,6 +919,12 @@ static inline int32_t get_avg_frequency(struct cpudata *cpu) cpu->pstate.scaling, cpu->sample.mperf); } +static inline int32_t get_avg_pstate (struct cpudata *cpu) +{ +return div64_u64 (cpu->pstate.max_pstate_physical * cpu->sample.aperf, + cpu->sample.mperf); +} +static inline int32_t get_target_pstate_use_cpu_load (struct cpudata *cpu) {struct sample *sample = &cpu->sample;@@ -951,7 +957,7 @@ static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu) cpu_load =div64_u64 (int_tofp (100 ) * mperf, sample->tsc); cpu->sample.busy_scaled = cpu_load; -return cpu->pstate.current_pstate -pid_calc (&cpu->pid, cpu_load); +return get_avg_pstate (cpu) -pid_calc (&cpu->pid, cpu_load); }static inline int32_t get_target_pstate_use_performance (struct cpudata *cpu)
Srinivas Pandruvada
maintainerQuoted 56 lines · Rafael J. Wysocki
Quoted 55 lines · Philippe Longepe
The result returned by
pid_calc()is subtracted fromcurrent_pstate(which is the pstate requested during the last period) in order to obtain the target pstate for the current iteration. However,current_pstatemay not reflect the real current P-state of the CPU. In particular, that P-state may be higher because of the frequency sharing per module.The theory is:
- The load is the percentage of time spent in C0 and is related to the average frequency during the same period (We'll not have the same load at 1GHz or at 2GHz for the same task running).
- The current frequency can be completely different than the average frequency (because of frequency sharing or throttling).
=> The frequency shift computed by the
pid_calcis based on the load, so it must be applied to the frequency with which the load was measured.Using the average pstate instead of current pstate solve some migration issues (e.g when a task migrates from one core to another in the same package/module and all of the cores in there except for that particular one are basically idle).
Performance and power comparison with this patch on Android:
IPLoad+Avg-Pstate vs IP Load:
Benchmark ∆Perf ∆Power
FishTank 10.45% 3.1%
SmartBench-Gaming -0.1% -10.4%
SmartBench-Productivity -0.8% -10.4%
CandyCrush n/a -17.4%
AngryBirds n/a -5.9%
videoPlayback n/a -13.9%
audioPlayback n/a -4.9%
IcyRocks-20-50 0.0% -38.4%
iozone RR -0.16% -1.3%
iozone RW 0.74% -1.3%Comparison with the perf algorithm:
(this patch incpu_loadvs Core algorithm)Benchmark ∆Perf ∆Power
SmartBench-Gaming -0.58% -22.8%
SmartBench-Productivity 0.82%
CandyCrush n/a -20.8%
AngryBirds n/a -37.0%
videoPlayback n/a -53.4%
audioPlayback n/a -2.1%
iozone RR -0.55% -13.29%
iozone RW 2.22%
Quoted 7 lines
Quoted 3 lines
=> No regression > 1% observed and a huge power improvement!
Signed-off-by Philippe Longepe <[email protected]>Srinivas, what about this one? Yes? No? Maybe?
I am fine with this change.
I would like to edit the commit and remove the bottom table compare with core and statement with exclamation as this not relevant here for the affected platforms.
Do you want me to send update?
Thanks,
Srinivas
Quoted 45 lines
Quoted 34 lines
---
drivers/cpufreq/intel_pstate.c | 8 +++++++-1 file changed, 7 insertions(+), 1 deletion(-)drivers/cpufreq/intel_pstate.c +0
-0@@ -919,6 +919,12 @@ static inline int32_t get_avg_frequency(struct cpudata *cpu) cpu->pstate.scaling, cpu->sample.mperf); }drivers/cpufreq/intel_pstate.c +3
-0+static inline int32_t get_avg_pstate (struct cpudata *cpu) +{ + return div64_u64(cpu->pstate.max_pstate_physical * cpu-Quoted 1 line
sample.aperf,
drivers/cpufreq/intel_pstate.c +3
-0+ cpu->sample.mperf); +} +static inline
int32_tget_target_pstate_use_cpu_load(struct cpudata *cpu)
{
struct sample *sample =&cpu->sample;drivers/cpufreq/intel_pstate.c +0
-0@@ -951,7 +957,7 @@ static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu) cpu_load = div64_u64(int_tofp(100) * mperf, sample->tsc); cpu->sample.busy_scaled = cpu_load;drivers/cpufreq/intel_pstate.c +0
-1- return cpu->pstate.current_pstate - pid_calc(&cpu->pid,
cpu_load);drivers/cpufreq/intel_pstate.c +1
-0+ return get_avg_pstate(cpu) - pid_calc(&cpu->pid,Quoted 6 lines
cpu_load);
}
static inlineint32_tget_target_pstate_use_performance(struct cpudata *cpu)--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Rafael J. Wysocki
maintainerQuoted 62 lines · Srinivas Pandruvada
Quoted 59 lines · Rafael J. Wysocki
Quoted 58 lines · Philippe Longepe
The result returned by
pid_calc()is subtracted fromcurrent_pstate(which is the pstate requested during the last period) in order to obtain the target pstate for the current iteration. However,current_pstatemay not reflect the real current P-state of the CPU. In particular, that P-state may be higher because of the frequency sharing per module.The theory is:
- The load is the percentage of time spent in C0 and is related to the average frequency during the same period (We'll not have the same load at 1GHz or at 2GHz for the same task running).
- The current frequency can be completely different than the average frequency (because of frequency sharing or throttling).
=> The frequency shift computed by the
pid_calcis based on the load, so it must be applied to the frequency with which the load was measured.Using the average pstate instead of current pstate solve some migration issues (e.g when a task migrates from one core to another in the same package/module and all of the cores in there except for that particular one are basically idle).
Performance and power comparison with this patch on Android:
IPLoad+Avg-Pstate vs IP Load:
Benchmark ∆Perf ∆Power FishTank 10.45% 3.1% SmartBench-Gaming -0.1% -10.4% SmartBench-Productivity -0.8% -10.4% CandyCrush n/a -17.4% AngryBirds n/a -5.9% videoPlayback n/a -13.9% audioPlayback n/a -4.9% IcyRocks-20-50 0.0% -38.4% iozone RR -0.16% -1.3% iozone RW 0.74% -1.3%Comparison with the perf algorithm:
(this patch incpu_loadvs Core algorithm)Benchmark ∆Perf ∆Power
SmartBench-Gaming -0.58% -22.8%
SmartBench-Productivity 0.82%CandyCrush n/a -20.8% AngryBirds n/a -37.0% videoPlayback n/a -53.4% audioPlayback n/a -2.1%iozone RR -0.55% -13.29%
iozone RW 2.22%=> No regression > 1% observed and a huge power improvement!
Signed-off-by Philippe Longepe <[email protected]>
Quoted 8 lines
Quoted 2 lines
Srinivas, what about this one? Yes? No? Maybe?
I am fine with this change.
I would like to edit the commit and remove the bottom table compare with core and statement with exclamation as this not relevant here for the affected platforms.Do you want me to send update?
Yes, please.
Srinivas,
Recall a couple of months ago, on the "Increase hold-off time before busyness is scaled" thread, Stephane suggested we try applying this method on the get_target_pstate_use_performance branch of the intel_pstate driver, as opposed to just on the get_target_pstate_use_cpu_load branch.
It didn't make any difference with respect to the hold-off time issue. However, I did spend considerable time testing it in other scenarios.
It does somewhat temper the occasional tendency to suddenly have a ridiculously high scaled busy number with virtually no load (the same issue from the "[intel-pstate driver regression] processor frequency very high even if in idle" thread, that continued in https://bugzilla.kernel.org/show_bug.cgi?id=115771 )
I didn't find any significant regression, and did observe some small energy savings in some scenarios (admittedly, small enough to have possibly been simply test to test variations, and I didn't do enough tests to extract a definite trend).
I am suggesting to consider extending the patch to get_target_pstate_use_performance also.
... Doug
Srinivas Pandruvada
maintainerHi Doug,
Quoted 26 lines · Doug Smythies
Srinivas,
Recall a couple of months ago, on the "Increase hold-off time before busyness is scaled"
thread, Stephane suggested we try applying this method on theget_target_pstate_use_performance
branch of theintel_pstatedriver, as opposed to just on theget_target_pstate_use_cpu_loadbranch.It didn't make any difference with respect to the hold-off time issue.
However, I did spend considerable time testing it in other scenarios. It does somewhat temper the occasional tendency to suddenly have a ridiculously high
scaled busy number with virtually no load (the same issue from the "[intel-pstate driver regression] processor frequency very high even if in idle" thread,
that continued in https://bugzilla.kernel.org/show_bug.cgi?id=115771
)
I didn't find any significant regression, and did observe some small energy savings
in some scenarios (admittedly, small enough to have possibly been simply test to test
variations, and I didn't do enough tests to extract a definite trend).
Quoted 3 lines
I am suggesting to consider extending the patch to
get_target_pstate_use_performancealso.
Many core platforms have per core P states. So here the assumption that we get a boost of P State on one core because some activity on other core will not hold true.
We are experimenting with algorithm to improve core performance (similar approach as yours + IO boost), hopefully we can publish soon.
Thanks,
Srinivas
Quoted 8 lines
... Doug
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html