From patchwork Wed Jun 11 12:33:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stratos Karafotis X-Patchwork-Id: 4336041 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C99C3BEEAA for ; Wed, 11 Jun 2014 12:33:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 108222022A for ; Wed, 11 Jun 2014 12:33:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C4AFB2016C for ; Wed, 11 Jun 2014 12:33:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753692AbaFKMdn (ORCPT ); Wed, 11 Jun 2014 08:33:43 -0400 Received: from sema.semaphore.gr ([78.46.194.137]:59739 "EHLO sema.semaphore.gr" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751965AbaFKMdn (ORCPT ); Wed, 11 Jun 2014 08:33:43 -0400 Received: from albert.lan (ppp141237092003.access.hol.gr [141.237.92.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: stratosk) by sema.semaphore.gr (Postfix) with ESMTPSA id 579FC82B0C; Wed, 11 Jun 2014 14:33:40 +0200 (CEST) From: Stratos Karafotis To: rjw@rjwysocki.net, viresh.kumar@linaro.org, dirk.j.brandewie@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: intel_pstate: Fix rounding of core_pct Date: Wed, 11 Jun 2014 15:33:32 +0300 Message-Id: <1402490012-19969-1-git-send-email-stratosk@semaphore.gr> X-Mailer: git-send-email 1.9.3 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Local variable core_pct holds fixed point values. When we round it we add "1" to core_pct. This has almost no effect. So, add int_toftp(1) to core_pct when rounding. For example, in a given sample point (values taken from tracepoint) with: aperf = 5024 mperf = 10619 the core_pct is (before rounding): core_pct = 12111 fp_toint(core_pct) = 47 After rounding: core_pct = 12112 fp_toint(core_pct) = 47 After rounding with int_toftp(1): core_pct = 12367 fp_toint(core_pct) = 48 Signed-off-by: Stratos Karafotis --- Hi Rafael, I'm sorry for submitting again in merge window, but I thought that maybe we need this fix for 3.16. drivers/cpufreq/intel_pstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 4e7f492..dd80aa2 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -564,7 +564,7 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu) core_pct = div_u64_rem(core_pct, int_tofp(sample->mperf), &rem); if ((rem << 1) >= int_tofp(sample->mperf)) - core_pct += 1; + core_pct += int_tofp(1); sample->freq = fp_toint( mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct));