mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugo Sales <hugo@hsal.es>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: Len Brown <lenb@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	"Ashton A." <me@ashtonantila.com>,
	linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 1/4] cpufreq: Add a CPUFREQ_UPDATE_CPUINFO policy notifier event
Date: Sun,  1 Nov 2026 18:58:04 +0000	[thread overview]
Message-ID: <20261101185807.112449-2-hugo@hsal.es> (raw)
In-Reply-To: <20261101185807.112449-1-hugo@hsal.es>

Turning boost on or off changes policy->cpuinfo.max_freq in the
->set_boost() callbacks of amd-pstate, cppc_cpufreq and the drivers that
use cpufreq_boost_set_sw(). Users that derive a QoS request from
cpuinfo.max_freq have no way to learn about it. The ACPI processor
thermal code is one: its throttling steps are fixed fractions of
cpuinfo.max_freq, computed only when the cooling state is written

Its freq QoS notifiers don't help, since they only fire when the
aggregate limit changes. While a thermal cap is lower than both maximums,
turning boost on changes boost_freq_req but not the aggregate

Add a CPUFREQ_UPDATE_CPUINFO policy notifier event and send it from
policy_set_boost() once the driver has updated cpuinfo. The helper that
sends it is global, so a driver that changes cpuinfo.max_freq outside
->set_boost() can send it too

Signed-off-by: Hugo Sales <hugo@hsal.es>
---
 Documentation/cpu-freq/core.rst |  9 ++++++---
 drivers/cpufreq/cpufreq.c       | 16 ++++++++++++++++
 include/linux/cpufreq.h         |  2 ++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/Documentation/cpu-freq/core.rst b/Documentation/cpu-freq/core.rst
index 4ceef8e7217c3..946913c024121 100644
--- a/Documentation/cpu-freq/core.rst
+++ b/Documentation/cpu-freq/core.rst
@@ -49,11 +49,14 @@ transition notifiers.
 2.1 CPUFreq policy notifiers
 ----------------------------
 
-These are notified when a new policy is created or removed.
+These are notified when a new policy is created or removed, and when boost
+is turned on or off or the driver reports a change of cpuinfo.max_freq.
 
 The phase is specified in the second argument to the notifier.  The phase is
-CPUFREQ_CREATE_POLICY when the policy is first created and it is
-CPUFREQ_REMOVE_POLICY when the policy is removed.
+CPUFREQ_CREATE_POLICY when the policy is first created, it is
+CPUFREQ_REMOVE_POLICY when the policy is removed and it is
+CPUFREQ_UPDATE_CPUINFO when boost has been turned on or off or the driver
+reports that cpuinfo.max_freq has changed.
 
 The third argument, a ``void *pointer``, points to a struct cpufreq_policy
 consisting of several values, including min, max (the lower and upper
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 54dde8419bdc4..4d974dac4dff5 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -594,6 +594,8 @@ static int policy_set_boost(struct cpufreq_policy *policy, bool enable)
 		return ret;
 	}
 
+	cpufreq_notify_cpuinfo_update(policy);
+
 	return 0;
 }
 
@@ -1184,6 +1186,20 @@ void refresh_frequency_limits(struct cpufreq_policy *policy)
 }
 EXPORT_SYMBOL(refresh_frequency_limits);
 
+/**
+ * cpufreq_notify_cpuinfo_update - Notify policy notifiers of a cpuinfo change
+ * @policy: Policy whose cpuinfo limits have changed
+ *
+ * Send CPUFREQ_UPDATE_CPUINFO to the policy notifiers, so that QoS requests
+ * derived from @policy->cpuinfo can be recomputed. An inactive policy is
+ * notified too, since its QoS requests stay until CPUFREQ_REMOVE_POLICY
+ */
+void cpufreq_notify_cpuinfo_update(struct cpufreq_policy *policy)
+{
+	blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
+				     CPUFREQ_UPDATE_CPUINFO, policy);
+}
+
 static void handle_update(struct work_struct *work)
 {
 	struct cpufreq_policy *policy =
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index d3d0d9d02aa4a..f3acdcee7183f 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -249,6 +249,7 @@ void disable_cpufreq(void);
 u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy);
 
 void refresh_frequency_limits(struct cpufreq_policy *policy);
+void cpufreq_notify_cpuinfo_update(struct cpufreq_policy *policy);
 void cpufreq_update_policy(unsigned int cpu);
 void cpufreq_update_limits(unsigned int cpu);
 bool have_governor_per_policy(void);
@@ -536,6 +537,7 @@ static inline void cpufreq_resume(void) {}
 /* Policy Notifiers  */
 #define CPUFREQ_CREATE_POLICY		(0)
 #define CPUFREQ_REMOVE_POLICY		(1)
+#define CPUFREQ_UPDATE_CPUINFO		(2)
 
 #ifdef CONFIG_CPU_FREQ
 int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list);

base-commit: 5854d2ce4b0b9ccb37b154319d8283bad889a694
-- 
2.56.0


  reply	other threads:[~2026-11-01 18:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01 18:58 [RFC PATCH 0/4] ACPI: processor: thermal: Recompute the frequency cap when boost changes Hugo Sales
2026-11-01 18:58 ` Hugo Sales [this message]
2026-11-01 18:58 ` [RFC PATCH 2/4] cpufreq: intel_pstate: Send CPUFREQ_UPDATE_CPUINFO on max_freq changes Hugo Sales
2026-11-08  7:12   ` Ximing Zhang
2026-11-01 18:58 ` [RFC PATCH 3/4] ACPI: processor: thermal: Factor out the thermal_req update Hugo Sales
2026-11-01 18:58 ` [RFC PATCH 4/4] ACPI: processor: thermal: Recompute the frequency cap when boost changes Hugo Sales

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=20261101185807.112449-2-hugo@hsal.es \
    --to=hugo@hsal.es \
    --cc=corbet@lwn.net \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=me@ashtonantila.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=skhan@linuxfoundation.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --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

all inboxes | Powered by JetHome®