linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: linux-kernel@vger.kernel.org, rafael@kernel.org
Cc: linux-pm@vger.kernel.org, lukasz.luba@arm.com,
	viresh.kumar@linaro.org, Dietmar.Eggemann@arm.com
Subject: [PATCH 2/2] cpufreq: Update CPU capacity reduction in store_scaling_max_freq()
Date: Fri, 30 Sep 2022 10:48:21 +0100	[thread overview]
Message-ID: <20220930094821.31665-2-lukasz.luba@arm.com> (raw)
In-Reply-To: <20220930094821.31665-1-lukasz.luba@arm.com>

When the new max frequency value is stored, the task scheduler must
know about it. The scheduler uses the CPUs capacity information in the
task placement. Use the existing mechanism which provides information
about reduced CPU capacity to the scheduler due to thermal capping.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 drivers/cpufreq/cpufreq.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 1f8b93f42c76..205d9ea9c023 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -27,6 +27,7 @@
 #include <linux/slab.h>
 #include <linux/suspend.h>
 #include <linux/syscore_ops.h>
+#include <linux/thermal.h>
 #include <linux/tick.h>
 #include <linux/units.h>
 #include <trace/events/power.h>
@@ -718,6 +719,8 @@ static ssize_t show_scaling_cur_freq(struct cpufreq_policy *policy, char *buf)
 static ssize_t store_scaling_max_freq
 (struct cpufreq_policy *policy, const char *buf, size_t count)
 {
+	unsigned int frequency;
+	struct cpumask *cpus;
 	unsigned long val;
 	int ret;
 
@@ -726,7 +729,20 @@ static ssize_t store_scaling_max_freq
 		return -EINVAL;
 
 	ret = freq_qos_update_request(policy->max_freq_req, val);
-	return ret >= 0 ? count : ret;
+	if (ret >= 0) {
+		/*
+		 * Make sure that the task scheduler sees these CPUs
+		 * capacity reduction. Use the thermal pressure mechanism
+		 * to propagate this information to the scheduler.
+		 */
+		cpus = policy->related_cpus;
+		frequency = __resolve_freq(policy, val, CPUFREQ_RELATION_HE);
+		arch_update_thermal_pressure(cpus, frequency);
+
+		ret = count;
+	}
+
+	return ret;
 }
 
 static ssize_t store_scaling_min_freq
-- 
2.17.1


  reply	other threads:[~2022-09-30  9:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30  9:48 [PATCH 1/2] cpufreq: Change macro for store scaling min/max frequency Lukasz Luba
2022-09-30  9:48 ` Lukasz Luba [this message]
2022-10-10  5:39   ` [PATCH 2/2] cpufreq: Update CPU capacity reduction in store_scaling_max_freq() Viresh Kumar
2022-10-10  9:02     ` Lukasz Luba
2022-10-10  9:15       ` Vincent Guittot
2022-10-10  9:30         ` Lukasz Luba
2022-10-10  9:32           ` Vincent Guittot
2022-10-10 10:12             ` Lukasz Luba
2022-10-10 10:22               ` Vincent Guittot
2022-10-10 10:49                 ` Lukasz Luba
2022-10-10 12:21                   ` Vincent Guittot
2022-10-10 13:05                     ` Lukasz Luba
2022-10-10 10:25               ` Peter Zijlstra
2022-10-10 10:46                 ` Lukasz Luba
2022-10-11  8:38                   ` Peter Zijlstra
2022-10-11 10:25                     ` Lukasz Luba
2022-10-10  5:36 ` [PATCH 1/2] cpufreq: Change macro for store scaling min/max frequency Viresh Kumar
2022-10-10  8:49   ` Lukasz Luba

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=20220930094821.31665-2-lukasz.luba@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=Dietmar.Eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=viresh.kumar@linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).