x86/cpufreq: Add Kconfig option for CPU frequency scaling
PATCH 1/1 x86/cpufreq: Add Kconfig option for CPU frequency scaling
Add CONFIG_CPUFREQ to allow CPU frequency scaling support to be disabled at build time. When disabled, this removes cpufreq code from the build.
Add stubs where necessary.
--- xen/arch/x86/acpi/Makefile | 2 +- xen/common/Kconfig | 4 ++-- xen/drivers/Makefile | 2 +- xen/drivers/cpufreq/Kconfig | 16 +++++++++++++++- xen/include/acpi/cpufreq/cpufreq.h | 5 +++++ xen/include/xen/acpi.h | 8 +++++++- xen/include/xen/pmstat.h | 15 ++++++++++++++- xen/include/xen/sched.h | 9 +++++++-- 8 files changed, 52 insertions(+), 9 deletions(-)
xen/arch/x86/acpi/Makefile +1 -1
@@ -1,4 +1,4 @@ -obj-y += cpufreq/ +obj-$(CONFIG_CPUFREQ) += cpufreq/ obj-y += lib.o power.o cpu_idle.o cpuidle_menu.o obj-bin-y += boot.init.o wakeup_prot.o
xen/common/Kconfig +2 -2
@@ -652,7 +652,7 @@ endmenu config PM_OP bool "Enable Performance Management Operation" - depends on ACPI && HAS_CPUFREQ && SYSCTL + depends on ACPI && CPUFREQ && SYSCTL default y help This option shall enable userspace performance management control
@@ -660,7 +660,7 @@ config PM_OP config PM_STATS bool "Enable Performance Management Statistics" - depends on ACPI && HAS_CPUFREQ && SYSCTL + depends on ACPI && CPUFREQ && SYSCTL default y help Enable collection of performance management statistics to aid in
xen/drivers/Makefile +1 -1
@@ -1,5 +1,5 @@ obj-y += char/ -obj-$(CONFIG_HAS_CPUFREQ) += cpufreq/ +obj-$(CONFIG_CPUFREQ) += cpufreq/ obj-$(CONFIG_HAS_PCI) += pci/ obj-$(CONFIG_HAS_VPCI) += vpci/ obj-$(CONFIG_HAS_PASSTHROUGH) += passthrough/
xen/drivers/cpufreq/Kconfig +15 -1
@@ -1,3 +1,17 @@ - config HAS_CPUFREQ bool + +config CPUFREQ + bool "CPU Frequency scaling" + default y + depends on HAS_CPUFREQ + help + Enable CPU frequency scaling and power management governors. + This allows Xen to dynamically adjust CPU P-states (performance + states) based on system load. + + Disabling this option removes all cpufreq governors and power + management interfaces. This is useful for real-time systems or + minimal hypervisor builds. + + If unsure, say Y.
xen/include/acpi/cpufreq/cpufreq.h +5 -0
@@ -381,8 +381,13 @@ int write_ondemand_up_threshold(unsigned int up_threshold);int write_userspace_scaling_setspeed (unsigned int cpu,unsigned int freq); +#ifdef CONFIG_CPUFREQ void cpufreq_dbs_timer_suspend (void );void cpufreq_dbs_timer_resume (void ); +#else +static inline void cpufreq_dbs_timer_suspend (void ) {} +static inline void cpufreq_dbs_timer_resume (void ) {} +#endif void intel_feature_detect (struct cpufreq_policy *policy);
xen/include/xen/acpi.h +7 -1
@@ -185,8 +185,14 @@ static inline unsigned int acpi_get_csubstate_limit(void) { return 0; }static inline void acpi_set_csubstate_limit (unsigned int new_limit) {return ; }#endif -#ifdef XEN_GUEST_HANDLE +#if defined(XEN_GUEST_HANDLE ) && defined(CONFIG_CPUFREQ )int acpi_set_pdc_bits (unsigned int acpi_id,XEN_GUEST_HANDLE (uint32 )); +#elif defined(XEN_GUEST_HANDLE ) +static inline int acpi_set_pdc_bits (unsigned int acpi_id, +XEN_GUEST_HANDLE (uint32) pdc) +{ +return -ENOSYS ; +}#endif int arch_acpi_set_pdc_bits (u32 acpi_id,u32 *,u32 mask);
xen/include/xen/pmstat.h +14 -1
@@ -5,10 +5,23 @@#include <public/platform.h> /* for struct xen_processor_power */ #include <public/sysctl.h> /* for struct pm_cx_stat */ +#ifdef CONFIG_CPUFREQ int set_px_pminfo (uint32_t acpi_id,struct xen_processor_performance *perf); -long set_cx_pminfo (uint32_t acpi_id,struct xen_processor_power *power);int set_cppc_pminfo (unsigned int acpi_id,const struct xen_processor_cppc *cppc_data); +#else +static inline int set_px_pminfo (uint32_t acpi_id, +struct xen_processor_performance *perf) +{ +return -ENOSYS ; +} +static inline int set_cppc_pminfo (unsigned int acpi_id, +const struct xen_processor_cppc *cppc_data) +{ +return -ENOSYS ; +} +#endif +long set_cx_pminfo (uint32_t acpi_id,struct xen_processor_power *power);#ifdef CONFIG_COMPAT struct compat_processor_performance ;
xen/include/xen/sched.h +7 -2
@@ -1255,9 +1255,14 @@ static always_inline bool is_iommu_enabled(const struct domain *d)extern bool sched_smt_power_savings;extern bool sched_disable_smt_switching; -extern enum cpufreq_controller { +enum cpufreq_controller { FREQCTL_none, FREQCTL_dom0_kernel, FREQCTL_xen -} cpufreq_controller; +}; +#ifdef CONFIG_CPUFREQ +extern enum cpufreq_controller cpufreq_controller; +#else +#define cpufreq_controller FREQCTL_none +#endif static always_inline bool is_cpufreq_controller(const struct domain *d) {
Signature · 1 line
2.25.1
Quoted 7 lines · Stefano Stabellini
Add
CONFIG_CPUFREQto allow CPU frequency scaling support to be disabled at build time. When disabled, this removes cpufreq code from the build.Add stubs where necessary.
Signed-off-by Stefano Stabellini <[email protected]>
Quoted 9 lines · Jason Andryuk
Quoted 7 lines · Stefano Stabellini
Add
CONFIG_CPUFREQto allow CPU frequency scaling support to be disabled at build time. When disabled, this removes cpufreq code from the build.Add stubs where necessary.
Signed-off-by Stefano Stabellini <[email protected]>Reviewed-by Jason Andryuk <[email protected]>
Actually I missed a couple of stubs, I had to send a v2
Quoted 7 lines · Stefano Stabellini
Add
CONFIG_CPUFREQto allow CPU frequency scaling support to be disabled at build time. When disabled, this removes cpufreq code from the build.Add stubs where necessary.
Signed-off-by Stefano Stabellini <[email protected]>