From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: dirk.brandewie@gmail.com
Cc: Dirk Brandewie <dirk.j.brandewie@intel.com>,
linux-pm@vger.kernel.org, dsmythies@telus.net
Subject: Re: [PATCH] intel_pstate: Improve initial busy calculation
Date: Fri, 30 May 2014 23:41:51 +0200 [thread overview]
Message-ID: <6353493.ExLg8J4uY6@vostro.rjw.lan> (raw)
In-Reply-To: <20622011.cSTifjdH2d@vostro.rjw.lan>
On Friday, May 30, 2014 11:35:57 PM Rafael J. Wysocki wrote:
> On Friday, May 30, 2014 10:10:57 AM dirk.brandewie@gmail.com wrote:
> > From: Doug Smythies <dsmythies@telus.net>
> >
> > This change makes the busy calculation using 64 bit math which prevents
> > overflow for large values of aperf/mperf.
> >
> > Cc: <stable@vger.kernel.org> # 3.14.x
> > Signed-off-by: Doug Smythies <dsmythies@telus.net>
> > Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
>
> This doesn't apply for me on top of bleeding-edge. Is there a patch missing?
The one below does apply, however. Is that what you meant?
---
drivers/cpufreq/intel_pstate.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 032efe4f7..c034cde 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -563,15 +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 = &cpu->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)
prev parent reply other threads:[~2014-05-30 21:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1917099.8KOhsjZWCp@vostro.rjw.lan>
2014-05-30 17:10 ` [PATCH] intel_pstate: Improve initial busy calculation dirk.brandewie
2014-05-30 21:35 ` Rafael J. Wysocki
2014-05-30 21:41 ` Rafael J. Wysocki [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6353493.ExLg8J4uY6@vostro.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=dirk.brandewie@gmail.com \
--cc=dirk.j.brandewie@intel.com \
--cc=dsmythies@telus.net \
--cc=linux-pm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox