Skip to contentSkip to conversation

cpufreq: Migrate users of policy notifiers to QoS requests

PATCH Superseded Viresh Kumar 2 participants 5 messages Jul 16, 2019

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Viresh Kumar

author maintainer
#0 lore raw

cover cpufreq: Migrate users of policy notifiers to QoS requests

Hello,

Now that cpufreq core supports taking QoS requests for min/max cpu frequencies, lets migrate rest of the users to using them instead of the policy notifiers.

The CPUFREQ_NOTIFY and CPUFREQ_ADJUST events of the policy notifiers are removed as a result, but we have to add CPUFREQ_CREATE_POLICY and CPUFREQ_REMOVE_POLICY events to it for the acpi stuff specifically. So the policy notifiers aren't completely removed.

Boot tested on my x86 PC and ARM hikey board. Nothing looked broken :)

This has already gone through build bot for a few days now.

--
viresh

Viresh Kumar (10):
cpufreq: Add policy create/remove notifiers
video: sa1100fb: Remove cpufreq policy notifier
video: pxafb: Remove cpufreq policy notifier
arch_topology: Use CPUFREQ_CREATE_POLICY instead of CPUFREQ_NOTIFY
thermal: cpu_cooling: Switch to QoS requests instead of cpufreq
notifier
powerpc: macintosh: Switch to QoS requests instead of cpufreq notifier
cpufreq: powerpc_cbe: Switch to QoS requests instead of cpufreq
notifier
ACPI: cpufreq: Switch to QoS requests instead of cpufreq notifier
cpufreq: Remove CPUFREQ_ADJUST and CPUFREQ_NOTIFY policy notifier
events
Documentation: cpufreq: Update policy notifier documentation

 Documentation/cpu-freq/core.txt            |  16 +--
 drivers/acpi/processor_driver.c            |  44 ++++++++-
 drivers/acpi/processor_perflib.c           | 106 +++++++++-----------
 drivers/acpi/processor_thermal.c           |  81 ++++++++-------
 drivers/base/arch_topology.c               |   2 +-
 drivers/cpufreq/cpufreq.c                  |  51 ++++------
 drivers/cpufreq/ppc_cbe_cpufreq.c          |  19 +++-
 drivers/cpufreq/ppc_cbe_cpufreq.h          |   8 ++
 drivers/cpufreq/ppc_cbe_cpufreq_pmi.c      |  96 +++++++++++-------
 drivers/macintosh/windfarm_cpufreq_clamp.c |  77 ++++++++++-----
 drivers/thermal/cpu_cooling.c              | 110 +++++----------------
 drivers/video/fbdev/pxafb.c                |  21 ----
 drivers/video/fbdev/pxafb.h                |   1 -
 drivers/video/fbdev/sa1100fb.c             |  27 -----
 drivers/video/fbdev/sa1100fb.h             |   1 -
 include/acpi/processor.h                   |  22 +++--
 include/linux/cpufreq.h                    |   4 +-
 17 files changed, 327 insertions(+), 359 deletions(-)
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
author maintainer
#1 lore raw

PATCH 1/10 cpufreq: Add policy create/remove notifiers

This reverts commit f9f41e3ef99ac9d4e91b07634362e393fb929aad.

We have a new use case for policy create/remove notifiers (for allocating/freeing QoS requests per policy), lets add them back.

---
 drivers/cpufreq/cpufreq.c | 15 ++++++++++++++-
 include/linux/cpufreq.h   |  2 ++
 2 files changed, 16 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +14 -1
index 4d6043ee7834..8a7eff2a3771 100644
@@ -1268,7 +1268,17 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)
 				   DEV_PM_QOS_MAX_FREQUENCY);
 	dev_pm_qos_remove_notifier(dev, &policy->nb_min,
 				   DEV_PM_QOS_MIN_FREQUENCY);
-	dev_pm_qos_remove_request(policy->max_freq_req);
+
+	if (policy->max_freq_req) {
+		/*
+		 * CPUFREQ_CREATE_POLICY notification is sent only after
+		 * successfully adding max_freq_req request.
+		 */
+		blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
+					     CPUFREQ_REMOVE_POLICY, policy);
+		dev_pm_qos_remove_request(policy->max_freq_req);
+	}
+
 	dev_pm_qos_remove_request(policy->min_freq_req);
 	kfree(policy->min_freq_req);
 
@@ -1393,6 +1403,9 @@ static int cpufreq_online(unsigned int cpu)
 				ret);
 			goto out_destroy_policy;
 		}
+
+		blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
+				CPUFREQ_CREATE_POLICY, policy);
 	}
 
 	if (cpufreq_driver->get && has_target()) {
include/linux/cpufreq.h +2 -0
index d757a56a74dc..e28c8af697d2 100644
@@ -458,6 +458,8 @@ static inline void cpufreq_resume(void) {}
 /* Policy Notifiers  */
 #define CPUFREQ_ADJUST			(0)
 #define CPUFREQ_NOTIFY			(1)
+#define CPUFREQ_CREATE_POLICY		(2)
+#define CPUFREQ_REMOVE_POLICY		(3)
 
 #ifdef CONFIG_CPU_FREQ
 int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list);
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
#2 lore raw
In reply to Viresh Kumar
Quoted 6 lines · Viresh Kumar

Hello,

Now that cpufreq core supports taking QoS requests for min/max cpu frequencies, lets migrate rest of the users to using them instead of the policy notifiers.

Technically, this still is linux-next only. :-)

Quoted 4 lines

The CPUFREQ_NOTIFY and CPUFREQ_ADJUST events of the policy notifiers are removed as a result, but we have to add CPUFREQ_CREATE_POLICY and CPUFREQ_REMOVE_POLICY events to it for the acpi stuff specifically. So the policy notifiers aren't completely removed.

That's not entirely accurate, because arch_topology is going to use CPUFREQ_CREATE_POLICY now too.

Quoted 3 lines

Boot tested on my x86 PC and ARM hikey board. Nothing looked broken :)

This has already gone through build bot for a few days now.

So I'd prefer patches [5-8] to go right after the first one and then do the cleanups on top of that, as somebody may want to backport the essential changes without the cleanups.

author maintainer
#3 lore raw
Quoted 9 lines · Rafael J. Wysocki
Quoted 6 lines · Viresh Kumar

Hello,

Now that cpufreq core supports taking QoS requests for min/max cpu frequencies, lets migrate rest of the users to using them instead of the policy notifiers.

Technically, this still is linux-next only. :-)

True :)

Quoted 7 lines
Quoted 4 lines

The CPUFREQ_NOTIFY and CPUFREQ_ADJUST events of the policy notifiers are removed as a result, but we have to add CPUFREQ_CREATE_POLICY and CPUFREQ_REMOVE_POLICY events to it for the acpi stuff specifically. So the policy notifiers aren't completely removed.

That's not entirely accurate, because arch_topology is going to use CPUFREQ_CREATE_POLICY now too.

Yeah, I thought about that while writing this patchset and coverletter. But had it not been required for ACPI, I would have done it differently for the arch-topology code. Maybe direct calling of arch-topology routine from cpufreq core. I wanted to get rid of the policy notifiers completely but I couldn't find a better way of doing it for ACPI stuff.

Quoted 7 lines
Quoted 3 lines

Boot tested on my x86 PC and ARM hikey board. Nothing looked broken :)

This has already gone through build bot for a few days now.

So I'd prefer patches [5-8] to go right after the first one and then do the cleanups on top of that, as somebody may want to backport the essential changes without the cleanups.

In the exceptional case where nobody finds anything wrong with the patches (highly unlikely), do you want me to resend with reordering or you can reorder them while applying? There are no dependencies between those patches anyway.

--
viresh

#4 lore raw
Quoted 33 lines · Viresh Kumar
Quoted 9 lines · Rafael J. Wysocki
Quoted 6 lines · Viresh Kumar

Hello,

Now that cpufreq core supports taking QoS requests for min/max cpu frequencies, lets migrate rest of the users to using them instead of the policy notifiers.

Technically, this still is linux-next only. :-)

True :)

Quoted 7 lines
Quoted 4 lines

The CPUFREQ_NOTIFY and CPUFREQ_ADJUST events of the policy notifiers are removed as a result, but we have to add CPUFREQ_CREATE_POLICY and CPUFREQ_REMOVE_POLICY events to it for the acpi stuff specifically. So the policy notifiers aren't completely removed.

That's not entirely accurate, because arch_topology is going to use CPUFREQ_CREATE_POLICY now too.

Yeah, I thought about that while writing this patchset and coverletter. But had it not been required for ACPI, I would have done it differently for the arch-topology code. Maybe direct calling of arch-topology routine from cpufreq core. I wanted to get rid of the policy notifiers completely but I couldn't find a better way of doing it for ACPI stuff.

Quoted 4 lines
Quoted 3 lines

Boot tested on my x86 PC and ARM hikey board. Nothing looked broken :)

This has already gone through build bot for a few days now.

Quoted 8 lines
Quoted 3 lines

So I'd prefer patches [5-8] to go right after the first one and then do the cleanups on top of that, as somebody may want to backport the essential changes without the cleanups.

In the exceptional case where nobody finds anything wrong with the patches (highly unlikely), do you want me to resend with reordering or you can reorder them while applying? There are no dependencies between those patches anyway.

Please resend the reordered set when the merge window closes.