From patchwork Fri Jul 18 15:37:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dirk.brandewie@gmail.com X-Patchwork-Id: 4586341 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F0B049F26C for ; Fri, 18 Jul 2014 15:38:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 96F0A2013A for ; Fri, 18 Jul 2014 15:38:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A1CB820179 for ; Fri, 18 Jul 2014 15:38:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422816AbaGRPhz (ORCPT ); Fri, 18 Jul 2014 11:37:55 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:34211 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422813AbaGRPhx (ORCPT ); Fri, 18 Jul 2014 11:37:53 -0400 Received: by mail-pd0-f175.google.com with SMTP id r10so3725589pdi.6 for ; Fri, 18 Jul 2014 08:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4jtHTIenYDocYt4abO/Xy78oYw5VD6QqNXiBNCRd5II=; b=Kmig/6msTa2/ePHdJO/VObsNk7GFoRuHBC1/DHURqTMLmrKJn1GZuplbrrfuFb3TCy v+CvT34h/m+3w9NY6HOPChS8Axz+IQR3YMVLbDMI1lD1G/5tR6yOJRcCT7aGW2qU+Tta kBkgVveuZ2lpgzAVLUcTB4YpTSASOsYA60JnSWCLQQaEgcedgRerLjpjNI8SyxavZbFX L5dAR6hu8b/2ijGNs0PGYpj2eSZUzCrKLY6ursIPLbfkuzro0RiBEWk1gr95QwjPkFNk cnLyM7TuB+hrHFXVFTB0KtOsxbSSq4OZZELcb3sX2c1nONEf/dFc5MBkv7DzOanNJLqK i22g== X-Received: by 10.69.26.68 with SMTP id iw4mr5982048pbd.137.1405697872926; Fri, 18 Jul 2014 08:37:52 -0700 (PDT) Received: from echolake.localdomain (static-50-43-41-81.bvtn.or.frontiernet.net. [50.43.41.81]) by mx.google.com with ESMTPSA id be7sm7894439pdb.37.2014.07.18.08.37.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jul 2014 08:37:52 -0700 (PDT) From: dirk.brandewie@gmail.com X-Google-Original-From: dirk.j.brandewie@intel.com To: linux-pm@vger.kernel.org Cc: rjw@rjwysocki.net, Stratos Karafotis , Dirk Brandewie Subject: [PATCH 09/17] cpufreq: intel_pstate: Keep values in aperf/mperf in full precision Date: Fri, 18 Jul 2014 08:37:25 -0700 Message-Id: <1405697848-13546-10-git-send-email-dirk.j.brandewie@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1405697848-13546-1-git-send-email-dirk.j.brandewie@intel.com> References: <1405697848-13546-1-git-send-email-dirk.j.brandewie@intel.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Stratos Karafotis Currently we shift right aperf and mperf variables by FRAC_BITS to prevent overflow when we convert them to fix point numbers (shift left by FRAC_BITS). But this is not necessary, because we actually use delta aperf and mperf which are much less than APERF and MPERF values. So, use the unmodified APERF and MPERF values in calculation. This also adds 8 bits in precision, although the gain is insignificant. Also, use div64_u64 instead of div_u64 in calc_busy() to avoid overflow of sample->mperf as divisor. Signed-off-by: Stratos Karafotis Signed-off-by: Dirk Brandewie --- drivers/cpufreq/intel_pstate.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index ff3c562..129ffb2 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -584,9 +584,6 @@ static inline void intel_pstate_sample(struct cpudata *cpu) rdmsrl(MSR_IA32_MPERF, mperf); local_irq_restore(flags); - aperf = aperf >> FRAC_BITS; - mperf = mperf >> FRAC_BITS; - cpu->last_sample_time = cpu->sample.time; cpu->sample.time = ktime_get(); cpu->sample.aperf = aperf;