From: "Pandruvada, Srinivas" <srinivas.pandruvada@intel.com>
To: "prarit@redhat.com" <prarit@redhat.com>
Cc: "Brown, Len" <len.brown@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"viresh.kumar@linaro.org" <viresh.kumar@linaro.org>,
"kristen@linux.intel.com" <kristen@linux.intel.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"rjw@rjwysocki.net" <rjw@rjwysocki.net>,
"Yates, Alexandra" <alexandra.yates@intel.com>
Subject: Re: [PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct rounding error
Date: Fri, 20 Nov 2015 20:02:37 +0000 [thread overview]
Message-ID: <1448049757.4914.3.camel@intel.com> (raw)
In-Reply-To: <564F3FBA.6030806@redhat.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2840 bytes --]
On Fri, 2015-11-20 at 10:43 -0500, Prarit Bhargava wrote:
>
> On 11/20/2015 10:19 AM, Viresh Kumar wrote:
> > On 20-11-15, 10:10, Prarit Bhargava wrote:
> >>>> limits->max_policy_pct = clamp_t(int, limits->max_policy_pct, 0 , 100);
> >>>
> >>> And put this after the later one ?
> >>>
> >>>> + limits->max_policy_pct = DIV_ROUND_UP(policy->max * 100,
> >>>> + policy->cpuinfo.max_freq);
> >>>>
> >>>> /* Normalize user input to [min_policy_pct, max_policy_pct] */
> >>>> limits->min_perf_pct = max(limits->min_policy_pct,
> >>>
> >>> Sure you tested it ? :)
> >>
> >> Oops -- and yeah, tested. It works because I rewrite the value of
> >> max_policy_pct :). I'll repost shortly.
> >
> > But we aren't doing below anymore, doesn't this change the
> > calculations at all?
> >
> > limits->max_policy_pct = clamp_t(int, limits->max_policy_pct, 0 , 100);
>
> The clamp only confines the max_policy between 0 and 100. AFAIK it doesn't make
> any change tothe value of limits->max_policy_pct unless it was outside of that
> range.
>
> P.
> >
With the changes below (as suggested above), I did tests. Except two
cases, it did correct. Those two are in turbo range, so I am OK with
that.
diff --git a/drivers/cpufreq/intel_pstate.c
b/drivers/cpufreq/intel_pstate.c
index b78abe9..c3bcca4 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1111,9 +1111,9 @@ static int intel_pstate_set_policy(struct
cpufreq_policy *policy)
limits = &powersave_limits;
limits->min_policy_pct = (policy->min * 100) /
policy->cpuinfo.max_freq;
limits->min_policy_pct = clamp_t(int, limits->min_policy_pct, 0 ,
100);
- limits->max_policy_pct = (policy->max * 100) /
policy->cpuinfo.max_freq;
+ limits->max_policy_pct = DIV_ROUND_UP(policy->max * 100,
+ policy->cpuinfo.max_freq);
limits->max_policy_pct = clamp_t(int, limits->max_policy_pct, 0 ,
100);
-
/* Normalize user input to [min_policy_pct, max_policy_pct] */
limits->min_perf_pct = max(limits->min_policy_pct,
limits->min_sysfs_pct);
@@ -1131,7 +1131,7 @@ static int intel_pstate_set_policy(struct
cpufreq_policy *policy)
int_tofp(100));
limits->max_perf = div_fp(int_tofp(limits->max_perf_pct),
int_tofp(100));
-
+ limits->max_perf = round_up(limits->max_perf, 8);
if (hwp_active)
intel_pstate_hwp_set();
3300 : OK
3200 : 1 less
3100 : 1 less
3000 : 1 less
2900 : OK
2800 : OK
2700 : OK
2600 : OK
2500 : OK
2400 : OK
2300 : OK
2200 : OK
2100 : OK
2000 : OK
1900 : OK
1800 : OK
1700 : OK
1600 : OK
1500 : OK
1400 : OK
1300 : OK
1200 : OK
1100 : OK
1000 : OK
900 : OK
800 : OK
Thanks,
Srinivas
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
next prev parent reply other threads:[~2015-11-20 20:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-20 12:32 [PATCH 0/2 v2] cpufreq, intel_pstate, Fix rounding errors Prarit Bhargava
2015-11-20 12:32 ` [PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct rounding error Prarit Bhargava
2015-11-20 13:18 ` Viresh Kumar
2015-11-20 15:10 ` Prarit Bhargava
2015-11-20 15:19 ` Viresh Kumar
2015-11-20 15:43 ` Prarit Bhargava
2015-11-20 20:02 ` Pandruvada, Srinivas [this message]
2015-11-20 23:47 ` Prarit Bhargava
2015-11-20 23:57 ` Pandruvada, Srinivas
2015-11-20 12:32 ` [PATCH 2/2] cpufreq, intel_pstate, fix limits->max_perf " Prarit Bhargava
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=1448049757.4914.3.camel@intel.com \
--to=srinivas.pandruvada@intel.com \
--cc=alexandra.yates@intel.com \
--cc=kristen@linux.intel.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=prarit@redhat.com \
--cc=rjw@rjwysocki.net \
--cc=viresh.kumar@linaro.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