From patchwork Sat Apr 23 04:03:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 8916891 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 997839F457 for ; Sat, 23 Apr 2016 04:07:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A626520123 for ; Sat, 23 Apr 2016 04:07:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80D9F201F2 for ; Sat, 23 Apr 2016 04:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751292AbcDWEHT (ORCPT ); Sat, 23 Apr 2016 00:07:19 -0400 Received: from mga04.intel.com ([192.55.52.120]:17480 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750895AbcDWEHS (ORCPT ); Sat, 23 Apr 2016 00:07:18 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP; 22 Apr 2016 21:07:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,520,1455004800"; d="scan'208";a="951183614" Received: from spandruv-mobl3.jf.intel.com ([10.255.231.180]) by fmsmga001.fm.intel.com with ESMTP; 22 Apr 2016 21:07:15 -0700 From: Srinivas Pandruvada To: khlebnikov@yandex-team.ru Cc: linux-pm@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH v2 2/3] cpufreq: intel_pstate: Adjust policy->max Date: Fri, 22 Apr 2016 21:03:52 -0700 Message-Id: <1461384233-24214-3-git-send-email-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1461384233-24214-1-git-send-email-srinivas.pandruvada@linux.intel.com> References: <1461384233-24214-1-git-send-email-srinivas.pandruvada@linux.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=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 When policy->max is changed via _PPC or sysfs and is more than the max non turbo frequency, it does not really change resulting performance in some processors. When policy->max results in a P-State ratio more than the turbo activation ratio, then processor can choose any P-State up to max turbo. So the user or _PPC setting has no value, but this can cause undesirable side effects like: - Showing reduced max percentage in Intel P-State sysfs - It can cause reduced max performance, if the policy->max is set to the least turbo frequency and because of precision error in calculation of ceiling limit, we may end up in a limit which is in non turbo region. This issue is more prone when we enforce _PPC limit, because of the way _PPC limit is set to indicate the beginning of turbo region when config TDP feature is in use. When config TDP feature is ON, the max non turbo ratio can be less than max physical non turbo ratio. In this case _PPC points to turbo activation ratio + 1. In this case we don't need to treat this as the reduced frequency in set_policy callback, as we can get performance up to max turbo frequency. In this change when config TDP is active (When the physical max non turbo ratio is more than the current max non turbo ratio), any request above current max non turbo is treated as full performance. Signed-off-by: Srinivas Pandruvada --- drivers/cpufreq/intel_pstate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index b3e8124..c9cc72d 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1428,11 +1428,23 @@ static void intel_pstate_set_performance_limits(struct perf_limits *limits) static int intel_pstate_set_policy(struct cpufreq_policy *policy) { + struct cpudata *cpu; + if (!policy->cpuinfo.max_freq) return -ENODEV; intel_pstate_clear_update_util_hook(policy->cpu); + cpu = all_cpu_data[0]; + if (cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate) { + if (policy->max < policy->cpuinfo.max_freq && + policy->max > (cpu->pstate.max_pstate * + cpu->pstate.scaling)) { + pr_info("policy->max > max non turbo frequency\n"); + policy->max = policy->cpuinfo.max_freq; + } + } + if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { limits = &performance_limits; if (policy->max >= policy->cpuinfo.max_freq) {