Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 7b010f9b9061 ("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>

+37 -6
+2 -2
drivers/cpufreq/intel_pstate.c
··· 1034 1034 if (!cpu_dev) 1035 1035 return false; 1036 1036 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)) 1039 1039 return false; 1040 1040 1041 1041 cpudata->pd_registered = true;
+10
include/linux/energy_model.h
··· 171 171 int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, 172 172 const struct em_data_callback *cb, 173 173 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); 174 177 void em_dev_unregister_perf_domain(struct device *dev); 175 178 struct em_perf_table *em_table_alloc(struct em_perf_domain *pd); 176 179 void em_table_free(struct em_perf_table *table); ··· 350 347 int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, 351 348 const struct em_data_callback *cb, 352 349 const cpumask_t *cpus, bool microwatts) 350 + { 351 + return -EINVAL; 352 + } 353 + static inline 354 + int em_dev_register_pd_no_update(struct device *dev, unsigned int nr_states, 355 + const struct em_data_callback *cb, 356 + const cpumask_t *cpus, bool microwatts) 353 357 { 354 358 return -EINVAL; 355 359 }
+25 -4
kernel/power/energy_model.c
··· 553 553 const struct em_data_callback *cb, 554 554 const cpumask_t *cpus, bool microwatts) 555 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) 579 + { 556 580 struct em_perf_table *em_table; 557 581 unsigned long cap, prev_cap = 0; 558 582 unsigned long flags = 0; ··· 660 636 unlock: 661 637 mutex_unlock(&em_pd_mutex); 662 638 663 - if (_is_cpu_device(dev)) 664 - em_check_capacity_update(); 665 - 666 639 return ret; 667 640 } 668 - EXPORT_SYMBOL_GPL(em_dev_register_perf_domain); 641 + EXPORT_SYMBOL_GPL(em_dev_register_pd_no_update); 669 642 670 643 /** 671 644 * em_dev_unregister_perf_domain() - Unregister Energy Model (EM) for a device