forked from mirrors/linux
		
	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>
This commit is contained in:
		
							parent
							
								
									bd0fa9bb45
								
							
						
					
					
						commit
						d37e2b7644
					
				
					 1 changed files with 11 additions and 13 deletions
				
			
		| 
						 | 
					@ -99,8 +99,7 @@ struct cpudata {
 | 
				
			||||||
	u64	prev_aperf;
 | 
						u64	prev_aperf;
 | 
				
			||||||
	u64	prev_mperf;
 | 
						u64	prev_mperf;
 | 
				
			||||||
	unsigned long long prev_tsc;
 | 
						unsigned long long prev_tsc;
 | 
				
			||||||
	int	sample_ptr;
 | 
						struct sample sample;
 | 
				
			||||||
	struct sample samples[SAMPLE_COUNT];
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct cpudata **all_cpu_data;
 | 
					static struct cpudata **all_cpu_data;
 | 
				
			||||||
| 
						 | 
					@ -586,15 +585,14 @@ static inline void intel_pstate_sample(struct cpudata *cpu)
 | 
				
			||||||
	mperf = mperf >> FRAC_BITS;
 | 
						mperf = mperf >> FRAC_BITS;
 | 
				
			||||||
	tsc = tsc >> FRAC_BITS;
 | 
						tsc = tsc >> FRAC_BITS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT;
 | 
						cpu->sample.aperf = aperf;
 | 
				
			||||||
	cpu->samples[cpu->sample_ptr].aperf = aperf;
 | 
						cpu->sample.mperf = mperf;
 | 
				
			||||||
	cpu->samples[cpu->sample_ptr].mperf = mperf;
 | 
						cpu->sample.tsc = tsc;
 | 
				
			||||||
	cpu->samples[cpu->sample_ptr].tsc = tsc;
 | 
						cpu->sample.aperf -= cpu->prev_aperf;
 | 
				
			||||||
	cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf;
 | 
						cpu->sample.mperf -= cpu->prev_mperf;
 | 
				
			||||||
	cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf;
 | 
						cpu->sample.tsc -= cpu->prev_tsc;
 | 
				
			||||||
	cpu->samples[cpu->sample_ptr].tsc -= cpu->prev_tsc;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]);
 | 
						intel_pstate_calc_busy(cpu, &cpu->sample);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cpu->prev_aperf = aperf;
 | 
						cpu->prev_aperf = aperf;
 | 
				
			||||||
	cpu->prev_mperf = mperf;
 | 
						cpu->prev_mperf = mperf;
 | 
				
			||||||
| 
						 | 
					@ -614,7 +612,7 @@ static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int32_t core_busy, max_pstate, current_pstate;
 | 
						int32_t core_busy, max_pstate, current_pstate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	core_busy = cpu->samples[cpu->sample_ptr].core_pct_busy;
 | 
						core_busy = cpu->sample.core_pct_busy;
 | 
				
			||||||
	max_pstate = int_tofp(cpu->pstate.max_pstate);
 | 
						max_pstate = int_tofp(cpu->pstate.max_pstate);
 | 
				
			||||||
	current_pstate = int_tofp(cpu->pstate.current_pstate);
 | 
						current_pstate = int_tofp(cpu->pstate.current_pstate);
 | 
				
			||||||
	core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate));
 | 
						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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	intel_pstate_sample(cpu);
 | 
						intel_pstate_sample(cpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sample = &cpu->samples[cpu->sample_ptr];
 | 
						sample = &cpu->sample;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	intel_pstate_adjust_busy_pstate(cpu);
 | 
						intel_pstate_adjust_busy_pstate(cpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -729,7 +727,7 @@ static unsigned int intel_pstate_get(unsigned int cpu_num)
 | 
				
			||||||
	cpu = all_cpu_data[cpu_num];
 | 
						cpu = all_cpu_data[cpu_num];
 | 
				
			||||||
	if (!cpu)
 | 
						if (!cpu)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	sample = &cpu->samples[cpu->sample_ptr];
 | 
						sample = &cpu->sample;
 | 
				
			||||||
	return sample->freq;
 | 
						return sample->freq;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue