x86, acpi_cpufreq: Make APERF MPERF read only in acpi_cpufreq
cover x86, acpi_cpufreq: Make APERF MPERF read only in acpi_cpufreq
PATCH 2/2 x86, acpi_cpufreq: do not clear aperf mperf MSR after read
Not write zeroes to APERF and MPERF by ondemand governor. With this other users can share these MSRs during reads.
Signed-off-by Venkatesh Pallipadi <[email protected]>
---
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +10 -5
@@ -66,6 +66,7 @@ struct acpi_cpufreq_data {unsigned int max_freq;unsigned int resume;unsigned int cpu_feature; +u64 saved_aperf, saved_mperf; }; static DEFINE_PER_CPU(struct acpi_cpufreq_data *, drv_data);
@@ -256,9 +257,6 @@ static void read_measured_perf_ctrs(voidrdmsr (MSR_IA32_APERF , cur->aperf.split.lo, cur->aperf.split.hi);rdmsr (MSR_IA32_MPERF , cur->mperf.split.lo, cur->mperf.split.hi); - -wrmsr (MSR_IA32_APERF ,0 ,0 ); -wrmsr (MSR_IA32_MPERF ,0 ,0 ); }/*
@@ -277,13 +275,20 @@ static void read_measured_perf_ctrs(voidstatic unsigned int get_measured_perf (struct cpufreq_policy *policy,unsigned int cpu) { -struct perf_pair cur; +struct perf_pair readin, cur;unsigned int perf_percent;unsigned int retval; -if (smp_call_function_single (cpu, read_measured_perf_ctrs, &cur,1 )) +if (smp_call_function_single (cpu, read_measured_perf_ctrs, &readin,1 ))return 0 ; + cur.aperf.whole = readin.aperf.whole - +per_cpu (drv_data, cpu)->saved_aperf; + cur.mperf.whole = readin.mperf.whole - +per_cpu (drv_data, cpu)->saved_mperf; +per_cpu (drv_data, cpu)->saved_aperf = readin.aperf.whole; +per_cpu (drv_data, cpu)->saved_mperf = readin.mperf.whole; +#ifdef __i386__/* * We dont want to do 64 bit divide with 32 bit kernel
PATCH 1/2 x86, acpi_cpufreq: cleanup structure names related to aperf mperf
In reply to [email protected]Change structure name to make the code look simpler. No functionality change in this patch.
Signed-off-by Venkatesh Pallipadi <[email protected]>
---
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 44 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-)
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +22 -22
@@ -238,24 +238,24 @@ static u32 get_cur_val(const struct cpumreturn cmd.val; } -struct perf_cur { +struct perf_pair {union {struct {u32 lo;u32 hi; } split;u64 whole; - } aperf_cur, mperf_cur; + } aperf, mperf; };/* Called via smp_call_function_single(), on the target CPU */ static void read_measured_perf_ctrs (void *_cur) { -struct perf_cur *cur = _cur; +struct perf_pair *cur = _cur; -rdmsr (MSR_IA32_APERF , cur->aperf_cur.split.lo, cur->aperf_cur.split.hi); -rdmsr (MSR_IA32_MPERF , cur->mperf_cur.split.lo, cur->mperf_cur.split.hi); +rdmsr (MSR_IA32_APERF , cur->aperf.split.lo, cur->aperf.split.hi); +rdmsr (MSR_IA32_MPERF , cur->mperf.split.lo, cur->mperf.split.hi);wrmsr (MSR_IA32_APERF ,0 ,0 );wrmsr (MSR_IA32_MPERF ,0 ,0 );
@@ -277,7 +277,7 @@ static void read_measured_perf_ctrs(voidstatic unsigned int get_measured_perf (struct cpufreq_policy *policy,unsigned int cpu) { -struct perf_cur cur; +struct perf_pair cur;unsigned int perf_percent;unsigned int retval;
@@ -290,39 +290,39 @@ static unsigned int get_measured_perf(st* Get an approximate value. Return failure in case we cannot get * an approximate value. */ -if (unlikely (cur.aperf_cur.split.hi || cur.mperf_cur.split.hi)) { +if (unlikely (cur.aperf.split.hi || cur.mperf.split.hi)) {int shift_count;u32 h; - h =max_t (u32, cur.aperf_cur.split.hi, cur.mperf_cur.split.hi); + h =max_t (u32, cur.aperf.split.hi, cur.mperf.split.hi); shift_count =fls (h); - cur.aperf_cur.whole >>= shift_count; - cur.mperf_cur.whole >>= shift_count; + cur.aperf.whole >>= shift_count; + cur.mperf.whole >>= shift_count; } -if (((unsigned long )(-1 ) /100 ) < cur.aperf_cur.split.lo) { +if (((unsigned long )(-1 ) /100 ) < cur.aperf.split.lo) {int shift_count =7 ; - cur.aperf_cur.split.lo >>= shift_count; - cur.mperf_cur.split.lo >>= shift_count; + cur.aperf.split.lo >>= shift_count; + cur.mperf.split.lo >>= shift_count; } -if (cur.aperf_cur.split.lo && cur.mperf_cur.split.lo) - perf_percent = (cur.aperf_cur.split.lo *100 ) / - cur.mperf_cur.split.lo; +if (cur.aperf.split.lo && cur.mperf.split.lo) + perf_percent = (cur.aperf.split.lo *100 ) / + cur.mperf.split.lo;else perf_percent =0 ;#else -if (unlikely (((unsigned long )(-1 ) /100 ) < cur.aperf_cur.whole)) { +if (unlikely (((unsigned long )(-1 ) /100 ) < cur.aperf.whole)) {int shift_count =7 ; - cur.aperf_cur.whole >>= shift_count; - cur.mperf_cur.whole >>= shift_count; + cur.aperf.whole >>= shift_count; + cur.mperf.whole >>= shift_count; } -if (cur.aperf_cur.whole && cur.mperf_cur.whole) - perf_percent = (cur.aperf_cur.whole *100 ) / - cur.mperf_cur.whole; +if (cur.aperf.whole && cur.mperf.whole) + perf_percent = (cur.aperf.whole *100 ) / + cur.mperf.whole;else perf_percent =0 ;
Len Brown
reviewerRe: [patch 1/2] x86, acpi_cpufreq: cleanup structure names related to aperf mperf
Venki,
Can you refresh these to apply to top of tree?
thanks,
Len Brown, Intel Open Source Technology Center