Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1504304imm; Tue, 15 May 2018 21:50:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqk5sRhtR4CuhbIZUMaB+e1edyla91ouwB1ATgdYvvhih3g9twQB+QyOxVGP/9sskBC7DN+ X-Received: by 2002:a17:902:9883:: with SMTP id s3-v6mr17654939plp.179.1526446214627; Tue, 15 May 2018 21:50:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526446214; cv=none; d=google.com; s=arc-20160816; b=mx6NGzRYo8qpzs0ccYJ701ce5SzJfii+0kdNTgVPwmZhNYF8Q+jM/hkfpSohJv6rJ6 ExjnrU6AZ8KQnaMJTZN+/VCMY7AO2DNrUQU3L63KBpCxIQZczwxQ88aOg7IwIqjg0aSa HolWrc+nkWU2eeVn6NsF+sQUHDzHMcIbAT2PC/y1yZ6dfEj14YWU2pCLqTV445UqXM8n sKLSW64jvoGMPW5x3PzeS66VrX60lys5+hPu5cwPLLxfKqi8WuiyRP6hpKzvl8SLk8wg cVD4vP9XTJVDht8gvnmQ3QOJw6C4K3Sj2kN/mKEPIsl/MKddPgr6eSNNDkLTzNOe/dI8 2LmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ewFzhh6MPigZrPw6TdjN2ag6DIg0lUhQ+bl50sKkhjo=; b=H10YGPfoam98nr2cJHjxZZDE3Q67+WR2TcpTjsAaFdGGujfj30ZA+xDmj5GvaID3ai 1QHhvhroY9gC0+iae4MvV0z0oGl4b77c85pnQCWOrdwkDIQRP8oWjrltR/b1qzTv/HUe jGIwArRURwv1PTQ48Mq28/vSt1XoRIjkBIA4pyJmvt81VARo7LhTykXsEDFoQ+olNkxE /sh9dr0JeXZrYPAvIH191aDahdKQhbxF9GUeYBe4uRaT/IihNNOZs1uIThEUhANBYz45 Mf179NLNkDAxUE3IWjJqTLEu3ceCsrMDhAt71KLyh+Q96ebzJ0KOq0wr6TAsfIknqPpm 9onw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f10-v6si1683706pln.443.2018.05.15.21.50.00; Tue, 15 May 2018 21:50:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752319AbeEPEtj (ORCPT + 99 others); Wed, 16 May 2018 00:49:39 -0400 Received: from mga04.intel.com ([192.55.52.120]:1169 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751844AbeEPEtW (ORCPT ); Wed, 16 May 2018 00:49:22 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 May 2018 21:49:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,404,1520924400"; d="scan'208";a="41300350" Received: from sunandaa-mobl.amr.corp.intel.com (HELO spandruv-mobl.jf.intel.com) ([10.252.135.192]) by orsmga007.jf.intel.com with ESMTP; 15 May 2018 21:49:20 -0700 From: Srinivas Pandruvada To: srinivas.pandruvada@linux.intel.com, tglx@linutronix.de, mingo@redhat.com, peterz@infradead.org, bp@suse.de, lenb@kernel.org, rjw@rjwysocki.net, mgorman@techsingularity.net Cc: x86@kernel.org, linux-pm@vger.kernel.org, viresh.kumar@linaro.org, juri.lelli@arm.com, linux-kernel@vger.kernel.org Subject: [RFC/RFT] [PATCH 08/10] cpufreq: intel_pstate: Dyanmically update busy pct Date: Tue, 15 May 2018 21:49:09 -0700 Message-Id: <20180516044911.28797-9-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180516044911.28797-1-srinivas.pandruvada@linux.intel.com> References: <20180516044911.28797-1-srinivas.pandruvada@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Calculate hwp_boost_threshold_busy_pct (task busy percent, which is worth boosting) and hwp_boost_pstate_threshold (Don't boost if CPU already has some performance) based on platform, min, max and turbo frequencies. Signed-off-by: Srinivas Pandruvada --- drivers/cpufreq/intel_pstate.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index ec455af..c43edce 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1463,6 +1463,42 @@ static inline int intel_pstate_get_sched_util(struct cpudata *cpu) return util * 100 / max; } + +static inline void intel_pstate_update_busy_threshold(struct cpudata *cpu) +{ + if (!hwp_boost_threshold_busy_pct) { + int min_freq, max_freq; + + min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling; + update_turbo_state(); + max_freq = global.turbo_disabled || global.no_turbo ? + cpu->pstate.max_freq : cpu->pstate.turbo_freq; + + /* + * We are guranteed to get atleast min P-state. If we assume + * P-state is proportional to load (such that 10% load + * increase will result in 10% P-state increase), we will + * get at least min P-state till we have atleast + * (min * 100/max) percent cpu load. So any load less than + * than this this we shouldn't do any boost. Then boosting + * is not free, we will add atleast 20% offset. + */ + hwp_boost_threshold_busy_pct = min_freq * 100 / max_freq; + hwp_boost_threshold_busy_pct += 20; + pr_debug("hwp_boost_threshold_busy_pct = %d\n", + hwp_boost_threshold_busy_pct); + } + + /* P1 percent out of total range of P-states */ + if (cpu->pstate.max_freq != cpu->pstate.turbo_freq) { + hwp_boost_pstate_threshold = + cpu->pstate.max_freq * SCHED_CAPACITY_SCALE / cpu->pstate.turbo_freq; + pr_debug("hwp_boost_pstate_threshold = %d\n", + hwp_boost_pstate_threshold); + } + +} + static inline void intel_pstate_update_util_hwp(struct update_util_data *data, u64 time, unsigned int flags) { @@ -2061,8 +2097,10 @@ static int __intel_pstate_cpu_init(struct cpufreq_policy *policy) policy->fast_switch_possible = true; - if (hwp_active) + if (hwp_active) { csd_init(cpu); + intel_pstate_update_busy_threshold(cpu); + } return 0; } -- 2.9.5