public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Prarit Bhargava <prarit@redhat.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-kernel@vger.kernel.org,
	Srinivas Pandruvada <srinivas.pandruvada@intel.com>,
	Len Brown <len.brown@intel.com>,
	Alexandra Yates <alexandra.yates@intel.com>,
	Kristen Carlson Accardi <kristen@linux.intel.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	linux-pm@vger.kernel.org
Subject: Re: [PATCH] cpufreq, intel_pstate.c, Fix rounding errors
Date: Thu, 19 Nov 2015 14:07:37 -0500	[thread overview]
Message-ID: <564E1DF9.1020809@redhat.com> (raw)
In-Reply-To: <20151119044639.GD3737@ubuntu>



On 11/18/2015 11:46 PM, Viresh Kumar wrote:
> On 18-11-15, 10:55, Prarit Bhargava wrote:
>> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
>> index 2e31d09..686f024 100644
>> --- a/drivers/cpufreq/intel_pstate.c
>> +++ b/drivers/cpufreq/intel_pstate.c
>> @@ -1233,6 +1233,8 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
>>  	struct cpudata *cpu;
>>  	int i;
>>  #endif
>> +	int max_policy_calc;
>> +
>>  	pr_debug("intel_pstate: %s max %u policy->max %u\n", __func__,
>>  		 policy->cpuinfo.max_freq, policy->max);
>>  	if (!policy->cpuinfo.max_freq)
>> @@ -1249,7 +1251,10 @@ 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;
>> +
>> +	max_policy_calc = (policy->max * 1000) / policy->cpuinfo.max_freq;
>> +	limits->max_policy_pct = DIV_ROUND_UP(max_policy_calc, 10);
>> +
> 
> Nice catch, but why can't we do this instead:
> 
> 	limits->max_policy_pct = DIV_ROUND_UP(policy->max * 100, policy->cpuinfo.max_freq);
> 

Ah, I got so deep into the code I didn't even think of simplifying the
calculation.  Thanks -- I'll do that instead.

>>  	limits->max_policy_pct = clamp_t(int, limits->max_policy_pct, 0 , 100);
>>  
>>  	/* Normalize user input to [min_policy_pct, max_policy_pct] */
>> @@ -1269,6 +1274,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);
> 
> Perhaps you should fix this in a separate patch.
> 

Okay, I submit these as a 2 part patchset.

P.

      reply	other threads:[~2015-11-19 19:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18 15:55 [PATCH] cpufreq, intel_pstate.c, Fix rounding errors Prarit Bhargava
2015-11-19  4:46 ` Viresh Kumar
2015-11-19 19:07   ` Prarit Bhargava [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=564E1DF9.1020809@redhat.com \
    --to=prarit@redhat.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=rjw@rjwysocki.net \
    --cc=srinivas.pandruvada@intel.com \
    --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