public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Zihuan Zhang <zhangzihuan@kylinos.cn>,
	Jonathan Cameron <jonathan.cameron@huawei.com>
Subject: [PATCH v1 3/3] cpufreq: intel_pstate: Adjust frequency percentage computations
Date: Fri, 05 Sep 2025 15:53:54 +0200	[thread overview]
Message-ID: <3395556.44csPzL39Z@rafael.j.wysocki> (raw)
In-Reply-To: <5028967.GXAFRqVoOG@rafael.j.wysocki>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Adjust frequency percentage computations in update_cpu_qos_request() to
avoid going above the exact numerical percentage in the FREQ_QOS_MAX
case.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/intel_pstate.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1696,8 +1696,8 @@ unlock_driver:
 static void update_cpu_qos_request(int cpunum, enum freq_qos_req_type type)
 {
 	struct cpudata *cpu = all_cpu_data[cpunum];
+	unsigned int freq = cpu->pstate.turbo_freq;
 	struct freq_qos_request *req;
-	unsigned int freq, perf_pct;
 
 	struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpunum);
 	if (!policy)
@@ -1711,14 +1711,12 @@ static void update_cpu_qos_request(int c
 		intel_pstate_get_hwp_cap(cpu);
 
 	if (type == FREQ_QOS_MIN) {
-		perf_pct = global.min_perf_pct;
+		freq = DIV_ROUND_UP(freq * global.min_perf_pct, 100);
 	} else {
 		req++;
-		perf_pct = global.max_perf_pct;
+		freq = (freq * global.max_perf_pct) / 100;
 	}
 
-	freq = DIV_ROUND_UP(cpu->pstate.turbo_freq * perf_pct, 100);
-
 	if (freq_qos_update_request(req, freq) < 0)
 		pr_warn("Failed to update freq constraint: CPU%d\n", cpunum);
 }




  parent reply	other threads:[~2025-09-05 13:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05 13:51 [PATCH v1 0/3] cpufreq: intel_pstate: A fix, a __free()-based simplification, and a follow-up adjustment Rafael J. Wysocki
2025-09-05 13:52 ` [PATCH v1 1/3] cpufreq: intel_pstate: Fix object lifecycle issue in update_qos_request() Rafael J. Wysocki
2025-09-08  0:41   ` Zihuan Zhang
2025-09-05 13:52 ` [PATCH v1 2/3] cpufreq: intel_pstate: Rearrange freq QoS updates using __free() Rafael J. Wysocki
2025-09-08  0:53   ` Zihuan Zhang
2025-09-08 18:10     ` Rafael J. Wysocki
2025-09-09  0:47       ` Zihuan Zhang
2025-09-05 13:53 ` Rafael J. Wysocki [this message]
2025-09-08  1:12   ` [PATCH v1 3/3] cpufreq: intel_pstate: Adjust frequency percentage Zihuan Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3395556.44csPzL39Z@rafael.j.wysocki \
    --to=rafael@kernel.org \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=viresh.kumar@linaro.org \
    --cc=zhangzihuan@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox