Skip to content

Commit 306c769

Browse files
committed
PM: EM: Add function for registering a PD without capacity update
JIRA: https://issues.redhat.com/browse/RHEL-112493 commit e042354 Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Date: Fri Sep 5 15:44:45 2025 +0200 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/40212796-734c-4140-8a85-854f72b8144d@panix.com/ Reported-by: Kenneth R. Crudup <kenny@panix.com> Tested-by: Kenneth R. Crudup <kenny@panix.com> Cc: 6.16+ <stable@vger.kernel.org> # 6.16+ Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: David Arcari <darcari@redhat.com>
1 parent ca7bd20 commit 306c769

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
@@ -1035,8 +1035,8 @@ static bool hybrid_register_perf_domain(unsigned int cpu)
10351035
if (!cpu_dev)
10361036
return false;
10371037

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

10421042
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);
@@ -351,6 +354,13 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
351354
{
352355
return -EINVAL;
353356
}
357+
static inline
358+
int em_dev_register_pd_no_update(struct device *dev, unsigned int nr_states,
359+
const struct em_data_callback *cb,
360+
const cpumask_t *cpus, bool microwatts)
361+
{
362+
return -EINVAL;
363+
}
354364
static inline void em_dev_unregister_perf_domain(struct device *dev)
355365
{
356366
}

kernel/power/energy_model.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,30 @@ EXPORT_SYMBOL_GPL(em_cpu_get);
619619
int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
620620
const struct em_data_callback *cb,
621621
const cpumask_t *cpus, bool microwatts)
622+
{
623+
int ret = em_dev_register_pd_no_update(dev, nr_states, cb, cpus, microwatts);
624+
625+
if (_is_cpu_device(dev))
626+
em_check_capacity_update();
627+
628+
return ret;
629+
}
630+
EXPORT_SYMBOL_GPL(em_dev_register_perf_domain);
631+
632+
/**
633+
* em_dev_register_pd_no_update() - Register a perf domain for a device
634+
* @dev : Device to register the PD for
635+
* @nr_states : Number of performance states in the new PD
636+
* @cb : Callback functions for populating the energy model
637+
* @cpus : CPUs to include in the new PD (mandatory if @dev is a CPU device)
638+
* @microwatts : Whether or not the power values in the EM will be in uW
639+
*
640+
* Like em_dev_register_perf_domain(), but does not trigger a CPU capacity
641+
* update after registering the PD, even if @dev is a CPU device.
642+
*/
643+
int em_dev_register_pd_no_update(struct device *dev, unsigned int nr_states,
644+
const struct em_data_callback *cb,
645+
const cpumask_t *cpus, bool microwatts)
622646
{
623647
struct em_perf_table *em_table;
624648
unsigned long cap, prev_cap = 0;
@@ -703,12 +727,9 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
703727
unlock:
704728
mutex_unlock(&em_pd_mutex);
705729

706-
if (_is_cpu_device(dev))
707-
em_check_capacity_update();
708-
709730
return ret;
710731
}
711-
EXPORT_SYMBOL_GPL(em_dev_register_perf_domain);
732+
EXPORT_SYMBOL_GPL(em_dev_register_pd_no_update);
712733

713734
/**
714735
* em_dev_unregister_perf_domain() - Unregister Energy Model (EM) for a device

0 commit comments

Comments
 (0)