intel_pstate: Do not skip samples partially
Subsystems (2)
PATCH 1/1 intel_pstate: Do not skip samples partially
From: Rafael J. Wysocki <[email protected]>
If the current value of MPERF or the current value of TSC is the same as the previous one, respectively, intel_pstate_sample() bails out early and skips the sample.
However, intel_pstate_adjust_busy_pstate() is still called in that case which is not correct, so modify intel_pstate_sample() to return a bool value indicating whether or not the sample has been taken and use it to decide whether or not to call intel_pstate_adjust_busy_pstate().
While at it, remove redundant parentheses from the MPERF/TSC check in intel_pstate_sample().
---
On top of my linux-next branch.
--- drivers/cpufreq/intel_pstate.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/cpufreq/intel_pstate.c +7 -5
@@ -890,7 +890,7 @@ static inline void intel_pstate_calc_bus sample->core_pct_busy = (int32_t )core_pct; } -static inline void intel_pstate_sample (struct cpudata *cpu,u64 time) +static inline bool intel_pstate_sample (struct cpudata *cpu,u64 time) {u64 aperf, mperf;unsigned long flags;
@@ -900,9 +900,9 @@ static inline void intel_pstate_sample(srdmsrl (MSR_IA32_APERF , aperf);rdmsrl (MSR_IA32_MPERF , mperf); tsc =rdtsc (); -if ((cpu->prev_mperf == mperf) || (cpu->prev_tsc == tsc)) { +if (cpu->prev_mperf == mperf || cpu->prev_tsc == tsc) {local_irq_restore (flags); -return ; +return false; }local_irq_restore (flags);
@@ -920,6 +920,7 @@ static inline void intel_pstate_sample(s cpu->prev_aperf = aperf; cpu->prev_mperf = mperf; cpu->prev_tsc = tsc; +return true; }static inline int32_t get_target_pstate_use_cpu_load (struct cpudata *cpu)
@@ -1026,8 +1027,9 @@ static void intel_pstate_update_util(stru64 delta_ns = time - cpu->sample.time;if ((s64 )delta_ns >= pid_params.sample_rate_ns) { -intel_pstate_sample (cpu, time); -if (!hwp_active) +bool sample_taken =intel_pstate_sample (cpu, time); + +if (sample_taken && !hwp_active)intel_pstate_adjust_busy_pstate (cpu); } }
Quoted 12 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If the current value of MPERF or the current value of TSC is the same as the previous one, respectively,
intel_pstate_sample()bails out early and skips the sample.However,
intel_pstate_adjust_busy_pstate()is still called in that case which is not correct, so modifyintel_pstate_sample()to return a bool value indicating whether or not the sample has been taken and use it to decide whether or not to callintel_pstate_adjust_busy_pstate().
Quoted 4 lines
While at it, remove redundant parentheses from the MPERF/TSC check in
intel_pstate_sample().Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 62 lines
---
On top of my linux-next branch.
---
drivers/cpufreq/intel_pstate.c | 12 +++++++-----1 file changed, 7 insertions(+), 5 deletions(-)Index:
linux-pm/drivers/cpufreq/intel_pstate.c
===================================================================drivers/cpufreq/intel_pstate.c +0
-0@@ -890,7 +890,7 @@ static inline void intel_pstate_calc_bus sample->core_pct_busy = (int32_t)core_pct; }
-static inline voidintel_pstate_sample(struct cpudata *cpu, u64 time)
+static inline boolintel_pstate_sample(struct cpudata *cpu, u64 time)
{
u64 aperf, mperf;
unsigned long flags;drivers/cpufreq/intel_pstate.c +2
-2@@ -900,9 +900,9 @@ static inline void intel_pstate_sample(s rdmsrl(MSR_IA32_APERF, aperf); rdmsrl(MSR_IA32_MPERF, mperf); tsc = rdtsc(); -if ((cpu->prev_mperf == mperf) || (cpu->prev_tsc == tsc)) { +if (cpu->prev_mperf == mperf || cpu->prev_tsc == tsc) { local_irq_restore(flags); -return ; +return false; } local_irq_restore(flags);drivers/cpufreq/intel_pstate.c +1
-0@@ -920,6 +920,7 @@ static inline void intel_pstate_sample(s cpu->prev_aperf = aperf; cpu->prev_mperf = mperf; cpu->prev_tsc = tsc; +return true; }
static inlineint32_tget_target_pstate_use_cpu_load(struct cpudata *cpu)drivers/cpufreq/intel_pstate.c +0
-0@@ -1026,8 +1027,9 @@ static void intel_pstate_update_util(str u64 delta_ns = time - cpu->sample.time;
if ((s64)delta_ns >= pid_params.sample_rate_ns) {drivers/cpufreq/intel_pstate.c +3
-2-intel_pstate_sample (cpu, time); -if (!hwp_active) +bool sample_taken =intel_pstate_sample (cpu, time); + +if (sample_taken && !hwp_active)
intel_pstate_adjust_busy_pstate(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