Skip to content

Commit 8fa520a

Browse files
Philippe Longeperafaeljw
authored andcommitted
intel_pstate: Remove freq calculation from intel_pstate_calc_busy()
Use a helper function to compute the average pstate and call it only where it is needed (only when tracing or in intel_pstate_get). Signed-off-by: Philippe Longepe <philippe.longepe@linux.intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 7349ec0 commit 8fa520a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -881,12 +881,6 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu)
881881
core_pct = int_tofp(sample->aperf) * int_tofp(100);
882882
core_pct = div64_u64(core_pct, int_tofp(sample->mperf));
883883

884-
sample->freq = fp_toint(
885-
mul_fp(int_tofp(
886-
cpu->pstate.max_pstate_physical *
887-
cpu->pstate.scaling / 100),
888-
core_pct));
889-
890884
sample->core_pct_busy = (int32_t)core_pct;
891885
}
892886

@@ -920,6 +914,12 @@ static inline void intel_pstate_sample(struct cpudata *cpu, u64 time)
920914
cpu->prev_tsc = tsc;
921915
}
922916

917+
static inline int32_t get_avg_frequency(struct cpudata *cpu)
918+
{
919+
return div64_u64(cpu->pstate.max_pstate_physical * cpu->sample.aperf *
920+
cpu->pstate.scaling, cpu->sample.mperf);
921+
}
922+
923923
static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu)
924924
{
925925
struct sample *sample = &cpu->sample;
@@ -1015,7 +1015,7 @@ static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu)
10151015
sample->mperf,
10161016
sample->aperf,
10171017
sample->tsc,
1018-
sample->freq);
1018+
get_avg_frequency(cpu));
10191019
}
10201020

10211021
static void intel_pstate_update_util(struct update_util_data *data, u64 time,
@@ -1104,7 +1104,7 @@ static unsigned int intel_pstate_get(unsigned int cpu_num)
11041104
if (!cpu)
11051105
return 0;
11061106
sample = &cpu->sample;
1107-
return sample->freq;
1107+
return get_avg_frequency(cpu);
11081108
}
11091109

11101110
static int intel_pstate_set_policy(struct cpufreq_policy *policy)

0 commit comments

Comments
 (0)