Skip to content

Commit d37e2b7

Browse files
Dirk Brandewierafaeljw
authored andcommitted
intel_pstate: remove unneeded sample buffers
Remove unneeded sample buffers, intel_pstate operates on the most recent sample only. This save some memory and make the code more readable. Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent bd0fa9b commit d37e2b7

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

‎drivers/cpufreq/intel_pstate.c‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ struct cpudata {
9999
u64 prev_aperf;
100100
u64 prev_mperf;
101101
unsigned long long prev_tsc;
102-
int sample_ptr;
103-
struct sample samples[SAMPLE_COUNT];
102+
struct sample sample;
104103
};
105104

106105
static struct cpudata **all_cpu_data;
@@ -586,15 +585,14 @@ static inline void intel_pstate_sample(struct cpudata *cpu)
586585
mperf = mperf >> FRAC_BITS;
587586
tsc = tsc >> FRAC_BITS;
588587

589-
cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT;
590-
cpu->samples[cpu->sample_ptr].aperf = aperf;
591-
cpu->samples[cpu->sample_ptr].mperf = mperf;
592-
cpu->samples[cpu->sample_ptr].tsc = tsc;
593-
cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf;
594-
cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf;
595-
cpu->samples[cpu->sample_ptr].tsc -= cpu->prev_tsc;
588+
cpu->sample.aperf = aperf;
589+
cpu->sample.mperf = mperf;
590+
cpu->sample.tsc = tsc;
591+
cpu->sample.aperf -= cpu->prev_aperf;
592+
cpu->sample.mperf -= cpu->prev_mperf;
593+
cpu->sample.tsc -= cpu->prev_tsc;
596594

597-
intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]);
595+
intel_pstate_calc_busy(cpu, &cpu->sample);
598596

599597
cpu->prev_aperf = aperf;
600598
cpu->prev_mperf = mperf;
@@ -614,7 +612,7 @@ static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu)
614612
{
615613
int32_t core_busy, max_pstate, current_pstate;
616614

617-
core_busy = cpu->samples[cpu->sample_ptr].core_pct_busy;
615+
core_busy = cpu->sample.core_pct_busy;
618616
max_pstate = int_tofp(cpu->pstate.max_pstate);
619617
current_pstate = int_tofp(cpu->pstate.current_pstate);
620618
core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate));
@@ -648,7 +646,7 @@ static void intel_pstate_timer_func(unsigned long __data)
648646

649647
intel_pstate_sample(cpu);
650648

651-
sample = &cpu->samples[cpu->sample_ptr];
649+
sample = &cpu->sample;
652650

653651
intel_pstate_adjust_busy_pstate(cpu);
654652

@@ -729,7 +727,7 @@ static unsigned int intel_pstate_get(unsigned int cpu_num)
729727
cpu = all_cpu_data[cpu_num];
730728
if (!cpu)
731729
return 0;
732-
sample = &cpu->samples[cpu->sample_ptr];
730+
sample = &cpu->sample;
733731
return sample->freq;
734732
}
735733

0 commit comments

Comments
 (0)