From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759865AbbKTNSj (ORCPT ); Fri, 20 Nov 2015 08:18:39 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:32837 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759641AbbKTNSi (ORCPT ); Fri, 20 Nov 2015 08:18:38 -0500 Date: Fri, 20 Nov 2015 18:48:33 +0530 From: Viresh Kumar To: Prarit Bhargava Cc: linux-kernel@vger.kernel.org, Srinivas Pandruvada , Len Brown , Alexandra Yates , Kristen Carlson Accardi , "Rafael J. Wysocki" , linux-pm@vger.kernel.org Subject: Re: [PATCH 1/2] cpufreq, intel_pstate, Fix limits->max_policy_pct rounding error Message-ID: <20151120131833.GD3957@ubuntu> References: <1448022757-7856-1-git-send-email-prarit@redhat.com> <1448022757-7856-2-git-send-email-prarit@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1448022757-7856-2-git-send-email-prarit@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Cc: Len Brown > Cc: Alexandra Yates > Cc: Kristen Carlson Accardi > Cc: "Rafael J. Wysocki" > Cc: Viresh Kumar > Cc: linux-pm@vger.kernel.org > Signed-off-by: Prarit Bhargava > --- > 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 ? :) -- viresh