Skip to content

Commit ebeeee3

Browse files
committed
PM: EM: Move sched domains rebuild function from schedutil to EM
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>
1 parent 78d4f34 commit ebeeee3

File tree

4 files changed

+26
-28
lines changed

4 files changed

+26
-28
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ static int cpufreq_online(unsigned int cpu)
15381538

15391539
/*
15401540
* Register with the energy model before
1541-
* sugov_eas_rebuild_sd() is called, which will result
1541+
* em_rebuild_sched_domains() is called, which will result
15421542
* in rebuilding of the sched domains, which should only be done
15431543
* once the energy model is properly initialized for the policy
15441544
* first.

include/linux/energy_model.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
179179
int em_dev_update_chip_binning(struct device *dev);
180180
int em_update_performance_limits(struct em_perf_domain *pd,
181181
unsigned long freq_min_khz, unsigned long freq_max_khz);
182+
void em_rebuild_sched_domains(void);
182183

183184
/**
184185
* 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,
404405
{
405406
return -EINVAL;
406407
}
408+
static inline void em_rebuild_sched_domains(void) {}
407409
#endif
408410

409411
#endif

kernel/power/energy_model.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,3 +908,20 @@ int em_update_performance_limits(struct em_perf_domain *pd,
908908
return 0;
909909
}
910910
EXPORT_SYMBOL_GPL(em_update_performance_limits);
911+
912+
static void rebuild_sd_workfn(struct work_struct *work)
913+
{
914+
rebuild_sched_domains_energy();
915+
}
916+
917+
void em_rebuild_sched_domains(void)
918+
{
919+
static DECLARE_WORK(rebuild_sd_work, rebuild_sd_workfn);
920+
921+
/*
922+
* When called from the cpufreq_register_driver() path, the
923+
* cpu_hotplug_lock is already held, so use a work item to
924+
* avoid nested locking in rebuild_sched_domains().
925+
*/
926+
schedule_work(&rebuild_sd_work);
927+
}

kernel/sched/cpufreq_schedutil.c

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -604,31 +604,6 @@ static const struct kobj_type sugov_tunables_ktype = {
604604

605605
/********************** cpufreq governor interface *********************/
606606

607-
#ifdef CONFIG_ENERGY_MODEL
608-
static void rebuild_sd_workfn(struct work_struct *work)
609-
{
610-
rebuild_sched_domains_energy();
611-
}
612-
613-
static DECLARE_WORK(rebuild_sd_work, rebuild_sd_workfn);
614-
615-
/*
616-
* EAS shouldn't be attempted without sugov, so rebuild the sched_domains
617-
* on governor changes to make sure the scheduler knows about it.
618-
*/
619-
static void sugov_eas_rebuild_sd(void)
620-
{
621-
/*
622-
* When called from the cpufreq_register_driver() path, the
623-
* cpu_hotplug_lock is already held, so use a work item to
624-
* avoid nested locking in rebuild_sched_domains().
625-
*/
626-
schedule_work(&rebuild_sd_work);
627-
}
628-
#else
629-
static inline void sugov_eas_rebuild_sd(void) { };
630-
#endif
631-
632607
struct cpufreq_governor schedutil_gov;
633608

634609
static struct sugov_policy *sugov_policy_alloc(struct cpufreq_policy *policy)
@@ -784,7 +759,11 @@ static int sugov_init(struct cpufreq_policy *policy)
784759
goto fail;
785760

786761
out:
787-
sugov_eas_rebuild_sd();
762+
/*
763+
* Schedutil is the preferred governor for EAS, so rebuild sched domains
764+
* on governor changes to make sure the scheduler knows about them.
765+
*/
766+
em_rebuild_sched_domains();
788767
mutex_unlock(&global_tunables_lock);
789768
return 0;
790769

@@ -826,7 +805,7 @@ static void sugov_exit(struct cpufreq_policy *policy)
826805
sugov_policy_free(sg_policy);
827806
cpufreq_disable_fast_switch(policy);
828807

829-
sugov_eas_rebuild_sd();
808+
em_rebuild_sched_domains();
830809
}
831810

832811
static int sugov_start(struct cpufreq_policy *policy)

0 commit comments

Comments
 (0)