From patchwork Fri Jul 18 15:37:27 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: 4586361 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 605BBC0514 for ; Fri, 18 Jul 2014 15:38:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C6DD320176 for ; Fri, 18 Jul 2014 15:38:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B3F7320160 for ; Fri, 18 Jul 2014 15:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422819AbaGRPh7 (ORCPT ); Fri, 18 Jul 2014 11:37:59 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:60502 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422813AbaGRPh4 (ORCPT ); Fri, 18 Jul 2014 11:37:56 -0400 Received: by mail-pa0-f48.google.com with SMTP id et14so5647526pad.35 for ; Fri, 18 Jul 2014 08:37:55 -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=Qb5PD1z+o2T+QOd5d+WGeNeu0/OaWWsZonXQnoqdf4E=; b=eLkPD5n3/gQgwkfru3M/yr9rzOFcnuv6j9rDiJMseeTBqWAjvqkAKNcPUAgg+MJ8uX dOviHd0cOyw9YXdl6ZmxnONt8dSl73P5fp9a4sBVHoYLdcTUXQuumpfXEghrJUUyA8/Z P1e1kkalRadF2brwkpW70sZW1SQqodMV8Qd4rdz8XBHbZOliGx5D0Uv+p6hSoMs//ish BN9WlcDekTk4RsVTZzug5oo2ynDCjO+6gdPDcuPoGBDRbtXlRTT6/OSUf/kbj5RqTC6j f1pM0dKGagAVYtIctjR5wKCSMKL7EJHvmg2sKSlKuDED9EEeC9yw0szoJrqtjot2b9Mz 7rvA== X-Received: by 10.68.225.105 with SMTP id rj9mr6271495pbc.108.1405697875939; Fri, 18 Jul 2014 08:37:55 -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.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jul 2014 08:37:54 -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 10/11] cpufreq: intel_pstate: Remove core_pct rounding Date: Fri, 18 Jul 2014 08:37:27 -0700 Message-Id: <1405697848-13546-12-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 The specific rounding adds conditionally only 1/256 to fractional part of core_pct. We can safely remove it without any noticeable impact in calculations. Use div64_u64 instead of div_u64 to avoid possible overflow of sample->mperf as divisor Signed-off-by: Stratos Karafotis Signed-off-by: Dirk Brandewie --- drivers/cpufreq/intel_pstate.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 33a09da..dc6e6bf 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -545,13 +545,9 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu) { struct sample *sample = &cpu->sample; int64_t core_pct; - int32_t rem; core_pct = int_tofp(sample->aperf) * int_tofp(100); - core_pct = div_u64_rem(core_pct, int_tofp(sample->mperf), &rem); - - if ((rem << 1) >= int_tofp(sample->mperf)) - core_pct += 1; + core_pct = div64_u64(core_pct, int_tofp(sample->mperf)); sample->freq = fp_toint( mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct));