Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1274166

Re: [PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct rounding error

From Prarit Bhargava <prarit@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct rounding error
Date 2015-11-20 16:20 +0100
Message-ID <qwVDH-uA-5@gated-at.bofh.it> (permalink)
References <qwT8S-7d6-21@gated-at.bofh.it> <qwT8S-7d6-19@gated-at.bofh.it> <qwTLA-7Gp-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 11/20/2015 08:18 AM, Viresh Kumar wrote:
> On 20-11-15, 07:32, Prarit Bhargava wrote:
>> I have a Intel (6,63) processor with a "marketing" frequency (from
>> /proc/cpuinfo) of 2100MHz, and a max turbo frequency of 2600MHz.  I
>> can execute
>>
>> cpupower frequency-set -g powersave --min 1200MHz --max 2100MHz
>>
>> and the max_freq_pct is set to 80.  When adding load to the system I noticed
>> that the cpu frequency only reached 2000MHZ and not 2100MHz as expected.
>>
>> This is because limits->max_policy_pct is calculated as 2100 * 100 /2600 = 80.7
>> and is rounded down to 80 when it should be rounded up to 81.  This patch
>> adds a DIV_ROUND_UP() which will return the correct value.
>>
>> Cc: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
>> Cc: Len Brown <len.brown@intel.com>
>> Cc: Alexandra Yates <alexandra.yates@intel.com>
>> Cc: Kristen Carlson Accardi <kristen@linux.intel.com>
>> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
>> Cc: Viresh Kumar <viresh.kumar@linaro.org>
>> Cc: linux-pm@vger.kernel.org
>> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
>> ---
>>  drivers/cpufreq/intel_pstate.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
>> index 001a532..6b63374 100644
>> --- a/drivers/cpufreq/intel_pstate.c
>> +++ b/drivers/cpufreq/intel_pstate.c
>> @@ -1110,6 +1110,8 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
>>  	limits->min_policy_pct = clamp_t(int, limits->min_policy_pct, 0 , 100);
>>  	limits->max_policy_pct = (policy->max * 100) / policy->cpuinfo.max_freq;
> 
> Forgot to remove this line ?
> 
>>  	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.

P.

> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct rounding error Prarit Bhargava <prarit@redhat.com> - 2015-11-20 13:40 +0100
  Re: [PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct  rounding error Viresh Kumar <viresh.kumar@linaro.org> - 2015-11-20 14:20 +0100
    Re: [PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct  rounding error Viresh Kumar <viresh.kumar@linaro.org> - 2015-11-20 16:20 +0100
      Re: [PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct  rounding error Prarit Bhargava <prarit@redhat.com> - 2015-11-20 16:50 +0100
        Re: [PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct  rounding error "Pandruvada, Srinivas" <srinivas.pandruvada@intel.com> - 2015-11-20 21:10 +0100
          Re: [PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct  rounding error Prarit Bhargava <prarit@redhat.com> - 2015-11-21 00:50 +0100
            Re: [PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct  rounding error "Pandruvada, Srinivas" <srinivas.pandruvada@intel.com> - 2015-11-21 01:00 +0100
    Re: [PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct  rounding error Prarit Bhargava <prarit@redhat.com> - 2015-11-20 16:20 +0100

csiph-web