Skip to content

Commit e042354

Browse files
committed
PM: EM: Add function for registering a PD without capacity update
The intel_pstate driver manages CPU capacity changes itself and it does not need an update of the capacity of all CPUs in the system to be carried out after registering a PD. Moreover, in some configurations (for instance, an SMT-capable hybrid x86 system booted with nosmt in the kernel command line) the em_check_capacity_update() call at the end of em_dev_register_perf_domain() always fails and reschedules itself to run once again in 1 s, so effectively it runs in vain every 1 s forever. To address this, introduce a new variant of em_dev_register_perf_domain(), called em_dev_register_pd_no_update(), that does not invoke em_check_capacity_update(), and make intel_pstate use it instead of the original. Fixes: 7b010f9 ("cpufreq: intel_pstate: EAS support for hybrid platforms") Closes: https://lore.kernel.org/linux-pm/[email protected]/ Reported-by: Kenneth R. Crudup <[email protected]> Tested-by: Kenneth R. Crudup <[email protected]> Cc: 6.16+ <[email protected]> # 6.16+ Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 76eeb9b commit e042354

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,8 +1034,8 @@ static bool hybrid_register_perf_domain(unsigned int cpu)
10341034
if (!cpu_dev)
10351035
return false;
10361036

1037-
if (em_dev_register_perf_domain(cpu_dev, HYBRID_EM_STATE_COUNT, &cb,
1038-
cpumask_of(cpu), false))
1037+
if (em_dev_register_pd_no_update(cpu_dev, HYBRID_EM_STATE_COUNT, &cb,
1038+
cpumask_of(cpu), false))
10391039
return false;
10401040

10411041
cpudata->pd_registered = true;

include/linux/energy_model.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ int em_dev_update_perf_domain(struct device *dev,
171171
int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
172172
const struct em_data_callback *cb,
173173
const cpumask_t *cpus, bool microwatts);
174+
int em_dev_register_pd_no_update(struct device *dev, unsigned int nr_states,
175+
const struct em_data_callback *cb,
176+
const cpumask_t *cpus, bool microwatts);
174177
void em_dev_unregister_perf_domain(struct device *dev);
175178
struct em_perf_table *em_table_alloc(struct em_perf_domain *pd);
176179
void em_table_free(struct em_perf_table *table);
@@ -350,6 +353,13 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
350353
{
351354
return -EINVAL;
352355
}
356+
static inline
357+
int em_dev_register_pd_no_update(struct device *dev, unsigned int nr_states,
358+
const struct em_data_callback *cb,
359+
const cpumask_t *cpus, bool microwatts)
360+
{
361+
return -EINVAL;
362+
}
353363
static inline void em_dev_unregister_perf_domain(struct device *dev)
354364
{
355365
}

kernel/power/energy_model.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,30 @@ EXPORT_SYMBOL_GPL(em_cpu_get);
552552
int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
553553
const struct em_data_callback *cb,
554554
const cpumask_t *cpus, bool microwatts)
555+
{
556+
int ret = em_dev_register_pd_no_update(dev, nr_states, cb, cpus, microwatts);
557+
558+
if (_is_cpu_device(dev))
559+
em_check_capacity_update();
560+
561+
return ret;
562+
}
563+
EXPORT_SYMBOL_GPL(em_dev_register_perf_domain);
564+
565+
/**
566+
* em_dev_register_pd_no_update() - Register a perf domain for a device
567+
* @dev : Device to register the PD for
568+
* @nr_states : Number of performance states in the new PD
569+
* @cb : Callback functions for populating the energy model
570+
* @cpus : CPUs to include in the new PD (mandatory if @dev is a CPU device)
571+
* @microwatts : Whether or not the power values in the EM will be in uW
572+
*
573+
* Like em_dev_register_perf_domain(), but does not trigger a CPU capacity
574+
* update after registering the PD, even if @dev is a CPU device.
575+
*/
576+
int em_dev_register_pd_no_update(struct device *dev, unsigned int nr_states,
577+
const struct em_data_callback *cb,
578+
const cpumask_t *cpus, bool microwatts)
555579
{
556580
struct em_perf_table *em_table;
557581
unsigned long cap, prev_cap = 0;
@@ -636,12 +660,9 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
636660
unlock:
637661
mutex_unlock(&em_pd_mutex);
638662

639-
if (_is_cpu_device(dev))
640-
em_check_capacity_update();
641-
642663
return ret;
643664
}
644-
EXPORT_SYMBOL_GPL(em_dev_register_perf_domain);
665+
EXPORT_SYMBOL_GPL(em_dev_register_pd_no_update);
645666

646667
/**
647668
* em_dev_unregister_perf_domain() - Unregister Energy Model (EM) for a device

0 commit comments

Comments
 (0)