* [patch 0/2] acpi x86: Make aperf mperf MSR usage in acpi_cpufreq read only @ 2009-04-06 18:26 venkatesh.pallipadi 2009-04-06 18:26 ` [patch 1/2] acpi x86: Cleanup acpi_cpufreq structures related to aperf/mperf venkatesh.pallipadi 2009-04-06 18:26 ` [patch 2/2] acpi x86: Make aperf/mperf MSR access in acpi_cpufreq read_only venkatesh.pallipadi 0 siblings, 2 replies; 5+ messages in thread From: venkatesh.pallipadi @ 2009-04-06 18:26 UTC (permalink / raw) To: lenb; +Cc: linux-acpi, Venkatesh Pallipadi Patchset makes aperf mperf MSR access in acpi_cpufreq read only. This enables other kernel and usaer level components to share read access to these MSRs. -- ^ permalink raw reply [flat|nested] 5+ messages in thread
* [patch 1/2] acpi x86: Cleanup acpi_cpufreq structures related to aperf/mperf 2009-04-06 18:26 [patch 0/2] acpi x86: Make aperf mperf MSR usage in acpi_cpufreq read only venkatesh.pallipadi @ 2009-04-06 18:26 ` venkatesh.pallipadi 2009-04-07 5:34 ` Len Brown 2009-04-06 18:26 ` [patch 2/2] acpi x86: Make aperf/mperf MSR access in acpi_cpufreq read_only venkatesh.pallipadi 1 sibling, 1 reply; 5+ messages in thread From: venkatesh.pallipadi @ 2009-04-06 18:26 UTC (permalink / raw) To: lenb; +Cc: linux-acpi, Venkatesh Pallipadi [-- Attachment #1: 0001-acpi-x86-Cleanup-acpi_cpufreq-structures-related-to.patch --] [-- Type: text/plain, Size: 3383 bytes --] Change structure name to make the code cleaner and simpler. No functionality change in this patch. Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> --- arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 42 +++++++++++++-------------- 1 files changed, 20 insertions(+), 22 deletions(-) diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c index 19f6b9d..340bdbe 100644 --- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c @@ -241,23 +241,23 @@ static u32 get_cur_val(const struct cpumask *mask) return cmd.val; } -struct perf_cur { +struct perf_pair { union { struct { u32 lo; u32 hi; } split; u64 whole; - } aperf_cur, mperf_cur; + } aperf, mperf; }; static long 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); @@ -281,7 +281,7 @@ static long read_measured_perf_ctrs(void *_cur) static 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; @@ -294,39 +294,37 @@ static unsigned int get_measured_perf(struct cpufreq_policy *policy, * 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; -- 1.6.0.6 -- ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch 1/2] acpi x86: Cleanup acpi_cpufreq structures related to aperf/mperf 2009-04-06 18:26 ` [patch 1/2] acpi x86: Cleanup acpi_cpufreq structures related to aperf/mperf venkatesh.pallipadi @ 2009-04-07 5:34 ` Len Brown 0 siblings, 0 replies; 5+ messages in thread From: Len Brown @ 2009-04-07 5:34 UTC (permalink / raw) To: Venkatesh Pallipadi; +Cc: linux-acpi, cpufreq applied (and cpufreq@vger.kernel.org added to cc) thanks, Len Brown, Intel Open Source Technology Center On Mon, 6 Apr 2009, venkatesh.pallipadi@intel.com wrote: > Change structure name to make the code cleaner and simpler. No > functionality change in this patch. > > Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> > --- > arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 42 +++++++++++++-------------- > 1 files changed, 20 insertions(+), 22 deletions(-) > > diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c > index 19f6b9d..340bdbe 100644 > --- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c > +++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c > @@ -241,23 +241,23 @@ static u32 get_cur_val(const struct cpumask *mask) > return cmd.val; > } > > -struct perf_cur { > +struct perf_pair { > union { > struct { > u32 lo; > u32 hi; > } split; > u64 whole; > - } aperf_cur, mperf_cur; > + } aperf, mperf; > }; > > > static long 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); > @@ -281,7 +281,7 @@ static long read_measured_perf_ctrs(void *_cur) > static 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; > > @@ -294,39 +294,37 @@ static unsigned int get_measured_perf(struct cpufreq_policy *policy, > * 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; > > -- > 1.6.0.6 > > -- > > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 5+ messages in thread
* [patch 2/2] acpi x86: Make aperf/mperf MSR access in acpi_cpufreq read_only 2009-04-06 18:26 [patch 0/2] acpi x86: Make aperf mperf MSR usage in acpi_cpufreq read only venkatesh.pallipadi 2009-04-06 18:26 ` [patch 1/2] acpi x86: Cleanup acpi_cpufreq structures related to aperf/mperf venkatesh.pallipadi @ 2009-04-06 18:26 ` venkatesh.pallipadi 2009-04-07 5:35 ` Len Brown 1 sibling, 1 reply; 5+ messages in thread From: venkatesh.pallipadi @ 2009-04-06 18:26 UTC (permalink / raw) To: lenb; +Cc: linux-acpi, Venkatesh Pallipadi [-- Attachment #1: 0002-acpi-x86-Make-aperf-mperf-MSR-access-in-acpi_cpufre.patch --] [-- Type: text/plain, Size: 1843 bytes --] Not write zeroes to APERF and MPERF by ondemand governor. With this change, other users can share these MSRs for reads. Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> --- arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c index 340bdbe..9d3af38 100644 --- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c @@ -68,6 +68,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); @@ -259,9 +260,6 @@ static long read_measured_perf_ctrs(void *_cur) 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); - return 0; } @@ -281,13 +279,20 @@ static long read_measured_perf_ctrs(void *_cur) static 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 (!work_on_cpu(cpu, read_measured_perf_ctrs, &cur)) + if (!work_on_cpu(cpu, read_measured_perf_ctrs, &readin)) 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 -- 1.6.0.6 -- ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch 2/2] acpi x86: Make aperf/mperf MSR access in acpi_cpufreq read_only 2009-04-06 18:26 ` [patch 2/2] acpi x86: Make aperf/mperf MSR access in acpi_cpufreq read_only venkatesh.pallipadi @ 2009-04-07 5:35 ` Len Brown 0 siblings, 0 replies; 5+ messages in thread From: Len Brown @ 2009-04-07 5:35 UTC (permalink / raw) To: Venkatesh Pallipadi; +Cc: linux-acpi, cpufreq applied (and cpufreq@vger.kernel.org cc'd) thanks, Len Brown, Intel Open Source Technology Center On Mon, 6 Apr 2009, venkatesh.pallipadi@intel.com wrote: > Not write zeroes to APERF and MPERF by ondemand governor. With this > change, other users can share these MSRs for reads. > > Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> > --- > arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 15 ++++++++++----- > 1 files changed, 10 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c > index 340bdbe..9d3af38 100644 > --- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c > +++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c > @@ -68,6 +68,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); > @@ -259,9 +260,6 @@ static long read_measured_perf_ctrs(void *_cur) > 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); > - > return 0; > } > > @@ -281,13 +279,20 @@ static long read_measured_perf_ctrs(void *_cur) > static 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 (!work_on_cpu(cpu, read_measured_perf_ctrs, &cur)) > + if (!work_on_cpu(cpu, read_measured_perf_ctrs, &readin)) > 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 > -- > 1.6.0.6 > > -- > > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-04-07 5:35 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-04-06 18:26 [patch 0/2] acpi x86: Make aperf mperf MSR usage in acpi_cpufreq read only venkatesh.pallipadi 2009-04-06 18:26 ` [patch 1/2] acpi x86: Cleanup acpi_cpufreq structures related to aperf/mperf venkatesh.pallipadi 2009-04-07 5:34 ` Len Brown 2009-04-06 18:26 ` [patch 2/2] acpi x86: Make aperf/mperf MSR access in acpi_cpufreq read_only venkatesh.pallipadi 2009-04-07 5:35 ` Len Brown
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).