summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDoug Smythies <dsmythies@telus.net>2014-05-30 10:10:57 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-06-11 11:54:13 -0700
commit9f3c8fdbb9786e46ffc6d2e261c9bf903e37fd4a (patch)
tree723a80aaa63561ea36a0aff7c8aef722b884743f /drivers
parentfb145ac9f30cf84d18a26b63e18c94849be54313 (diff)
downloadlinux-stable-9f3c8fdbb9786e46ffc6d2e261c9bf903e37fd4a.tar.gz
linux-stable-9f3c8fdbb9786e46ffc6d2e261c9bf903e37fd4a.tar.bz2
linux-stable-9f3c8fdbb9786e46ffc6d2e261c9bf903e37fd4a.zip
intel_pstate: Improve initial busy calculation
commit bf8102228a8bf053051f311e5486042fe0542894 upstream. This change makes the busy calculation using 64 bit math which prevents overflow for large values of aperf/mperf. Signed-off-by: Doug Smythies <dsmythies@telus.net> Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cpufreq/intel_pstate.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index b92051031ac9..de9ef4a1986d 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -563,16 +563,19 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
static inline void intel_pstate_calc_busy(struct cpudata *cpu,
struct sample *sample)
{
- int32_t core_pct;
+ int64_t core_pct;
+ int32_t rem;
- core_pct = div_fp(int_tofp((sample->aperf)),
- int_tofp((sample->mperf)));
- core_pct = mul_fp(core_pct, int_tofp(100));
+ core_pct = int_tofp(sample->aperf) * int_tofp(100);
+ core_pct = div_u64_rem(core_pct, int_tofp(sample->mperf), &rem);
+
+ if ((rem << 1) >= int_tofp(sample->mperf))
+ core_pct += 1;
sample->freq = fp_toint(
mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct));
- sample->core_pct_busy = core_pct;
+ sample->core_pct_busy = (int32_t)core_pct;
}
static inline void intel_pstate_sample(struct cpudata *cpu)