[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] x86/cpufreq: Add Kconfig option for CPU frequency scaling


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stefano Stabellini <stefano.stabellini@xxxxxxx>
  • Date: Thu, 5 Feb 2026 17:32:22 -0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W2QrLWOJ471WddrIDb2oIZoosMi0VA38DRqFzfwk6Bw=; b=tqRsKIzxy9oKIV3lWIKAEA5PktGGZPJH+FSYyQmYVWNdxT+qXQKe1f3JiPyLyHWqczByo4pONcEiXDs4yG2H3GKrmKJzKQ8Faa/G7hKw/GQpYAB0jMBxtCN69nQhUNsdkDdgUxdmDHN73hQOR+rhLaaeoejXRTDgNMjiVU3+UEI33g+ZoFaDzmEvYinqNx85HMpkX86DoT1y6xKB2+gYxwuX3kFF6yOKiz0eW8MVLq3UfX3BX3wY+G6Bttvn1054k6WWsvseN+GE2CxhkISnPqedJ0uKpVTmJ5df3UxTbOSseqDTN9RE5+yGZy2vojxSD3crhJNeh8Yj3QtN6sfnvg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rhp2vCi1E4rFQ6MwavvVHHrcZEpK0bCkpZskIJfP4IGKNeajMXx8Z7qnS1tVNfqiKAFRnny4XUh7lIV2ng9UgWI0lUOxh4n0gsYg3HKqPEU//AOFNMrEcw1qoQIxOF9JG8w81kjC/VThESye3hZT3Md60l7kse1nA5kqgTtoy9sIaZWM3YYPD+HykGAeG6OqFc+GUvfR2qu7QUGQBLbel0jwZLZVGaR1hjlT1J5IUKtBdlTqSQX6BTWsPHO6GAk4j+sq0lO20cQ8ZRVAdHLMy9NOQZtG+2xgo48LivE/Ki7HxQYK9OvFQ6DXypv1q3giDOF8MYo5WJn80XdCDuWt1g==
  • Cc: <jbeulich@xxxxxxxx>, <andrew.cooper3@xxxxxxxxxx>, <roger.pau@xxxxxxxxxx>, <jason.andryuk@xxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxx>
  • Delivery-date: Fri, 06 Feb 2026 01:32:46 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
---
 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(-)

diff --git a/xen/arch/x86/acpi/Makefile b/xen/arch/x86/acpi/Makefile
index 041377e2bb..aa476f65d5 100644
--- a/xen/arch/x86/acpi/Makefile
+++ b/xen/arch/x86/acpi/Makefile
@@ -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
diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index d7e79e752a..cddd7337bb 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -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
diff --git a/xen/drivers/Makefile b/xen/drivers/Makefile
index 2a1ae8ad13..3d81b8dde4 100644
--- a/xen/drivers/Makefile
+++ b/xen/drivers/Makefile
@@ -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/
diff --git a/xen/drivers/cpufreq/Kconfig b/xen/drivers/cpufreq/Kconfig
index cce80f4aec..49631f92de 100644
--- a/xen/drivers/cpufreq/Kconfig
+++ b/xen/drivers/cpufreq/Kconfig
@@ -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.
diff --git a/xen/include/acpi/cpufreq/cpufreq.h 
b/xen/include/acpi/cpufreq/cpufreq.h
index 0171ccf0ba..a97c642a50 100644
--- a/xen/include/acpi/cpufreq/cpufreq.h
+++ b/xen/include/acpi/cpufreq/cpufreq.h
@@ -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);
 
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index 90635ba0f3..7077c27150 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -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);
 
diff --git a/xen/include/xen/pmstat.h b/xen/include/xen/pmstat.h
index 6096560d3c..4efddad438 100644
--- a/xen/include/xen/pmstat.h
+++ b/xen/include/xen/pmstat.h
@@ -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;
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 1268632344..1b431fc726 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -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)
 {
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.