]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PM: EM: Move sched domains rebuild function from schedutil to EM
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 12 Dec 2024 12:01:02 +0000 (13:01 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 18 Dec 2024 19:32:13 +0000 (20:32 +0100)
Function sugov_eas_rebuild_sd() defined in the schedutil cpufreq governor
implements generic functionality that may be useful in other places.  In
particular, there is a plan to use it in the intel_pstate driver in the
future.

For this reason, move it from schedutil to the energy model code and
rename it to em_rebuild_sched_domains().

This also helps to get rid of some #ifdeffery in schedutil which is a
plus.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
drivers/cpufreq/cpufreq.c
include/linux/energy_model.h
kernel/power/energy_model.c
kernel/sched/cpufreq_schedutil.c

index 1a4cae54a01bd7ccf6c0838831c45b628c89b9ef..418236fef172363b4f72b824ed4b106a5113b533 100644 (file)
@@ -1538,7 +1538,7 @@ static int cpufreq_online(unsigned int cpu)
 
                /*
                 * Register with the energy model before
-                * sugov_eas_rebuild_sd() is called, which will result
+                * em_rebuild_sched_domains() is called, which will result
                 * in rebuilding of the sched domains, which should only be done
                 * once the energy model is properly initialized for the policy
                 * first.
index 752e0b2975820ab59788f4aa2c47c575140b3674..78318d49276dc049bcd79e381b61d3aade49b648 100644 (file)
@@ -179,6 +179,7 @@ int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
 int em_dev_update_chip_binning(struct device *dev);
 int em_update_performance_limits(struct em_perf_domain *pd,
                unsigned long freq_min_khz, unsigned long freq_max_khz);
+void em_rebuild_sched_domains(void);
 
 /**
  * em_pd_get_efficient_state() - Get an efficient performance state from the EM
@@ -404,6 +405,7 @@ int em_update_performance_limits(struct em_perf_domain *pd,
 {
        return -EINVAL;
 }
+static inline void em_rebuild_sched_domains(void) {}
 #endif
 
 #endif
index d07faf42eace6f4f9baff2729868d330e8941ad1..3874f0e97651e8ea1c944d4918f73776b7b07aad 100644 (file)
@@ -908,3 +908,20 @@ int em_update_performance_limits(struct em_perf_domain *pd,
        return 0;
 }
 EXPORT_SYMBOL_GPL(em_update_performance_limits);
+
+static void rebuild_sd_workfn(struct work_struct *work)
+{
+       rebuild_sched_domains_energy();
+}
+
+void em_rebuild_sched_domains(void)
+{
+       static DECLARE_WORK(rebuild_sd_work, rebuild_sd_workfn);
+
+       /*
+        * When called from the cpufreq_register_driver() path, the
+        * cpu_hotplug_lock is already held, so use a work item to
+        * avoid nested locking in rebuild_sched_domains().
+        */
+       schedule_work(&rebuild_sd_work);
+}
index 28c77904ea749f638c196ea7989af38239b844b4..1c07a2f8c8b5db23202e21b916d50d2de4d08782 100644 (file)
@@ -604,31 +604,6 @@ static const struct kobj_type sugov_tunables_ktype = {
 
 /********************** cpufreq governor interface *********************/
 
-#ifdef CONFIG_ENERGY_MODEL
-static void rebuild_sd_workfn(struct work_struct *work)
-{
-       rebuild_sched_domains_energy();
-}
-
-static DECLARE_WORK(rebuild_sd_work, rebuild_sd_workfn);
-
-/*
- * EAS shouldn't be attempted without sugov, so rebuild the sched_domains
- * on governor changes to make sure the scheduler knows about it.
- */
-static void sugov_eas_rebuild_sd(void)
-{
-       /*
-        * When called from the cpufreq_register_driver() path, the
-        * cpu_hotplug_lock is already held, so use a work item to
-        * avoid nested locking in rebuild_sched_domains().
-        */
-       schedule_work(&rebuild_sd_work);
-}
-#else
-static inline void sugov_eas_rebuild_sd(void) { };
-#endif
-
 struct cpufreq_governor schedutil_gov;
 
 static struct sugov_policy *sugov_policy_alloc(struct cpufreq_policy *policy)
@@ -784,7 +759,11 @@ static int sugov_init(struct cpufreq_policy *policy)
                goto fail;
 
 out:
-       sugov_eas_rebuild_sd();
+       /*
+        * Schedutil is the preferred governor for EAS, so rebuild sched domains
+        * on governor changes to make sure the scheduler knows about them.
+        */
+       em_rebuild_sched_domains();
        mutex_unlock(&global_tunables_lock);
        return 0;
 
@@ -826,7 +805,7 @@ static void sugov_exit(struct cpufreq_policy *policy)
        sugov_policy_free(sg_policy);
        cpufreq_disable_fast_switch(policy);
 
-       sugov_eas_rebuild_sd();
+       em_rebuild_sched_domains();
 }
 
 static int sugov_start(struct cpufreq_policy *policy)