Skip to content

Commit 59a5680

Browse files
committed
xen/acpi-processor: C and P-state driver that uploads said data to hypervisor.
This driver solves three problems: 1). Parse and upload ACPI0007 (or PROCESSOR_TYPE) information to the hypervisor - aka P-states (cpufreq data). 2). Upload the the Cx state information (cpuidle data). 3). Inhibit CPU frequency scaling drivers from loading. The reason for wanting to solve 1) and 2) is such that the Xen hypervisor is the only one that knows the CPU usage of different guests and can make the proper decision of when to put CPUs and packages in proper states. Unfortunately the hypervisor has no support to parse ACPI DSDT tables, hence it needs help from the initial domain to provide this information. The reason for 3) is that we do not want the initial domain to change P-states while the hypervisor is doing it as well - it causes rather some funny cases of P-states transitions. For this to work, the driver parses the Power Management data and uploads said information to the Xen hypervisor. It also calls acpi_processor_notify_smm() to inhibit the other CPU frequency scaling drivers from being loaded. Everything revolves around the 'struct acpi_processor' structure which gets updated during the bootup cycle in different stages. At the startup, when the ACPI parser starts, the C-state information is processed (processor_idle) and saved in said structure as 'power' element. Later on, the CPU frequency scaling driver (powernow-k8 or acpi_cpufreq), would call the the acpi_processor_* (processor_perflib functions) to parse P-states information and populate in the said structure the 'performance' element. Since we do not want the CPU frequency scaling drivers from loading we have to call the acpi_processor_* functions to parse the P-states and call "acpi_processor_notify_smm" to stop them from loading. There is also one oddity in this driver which is that under Xen, the physical online CPU count can be different from the virtual online CPU count. Meaning that the macros 'for_[online|possible]_cpu' would process only up to virtual online CPU count. We on the other hand want to process the full amount of physical CPUs. For that, the driver checks if the ACPI IDs count is different from the APIC ID count - which can happen if the user choose to use dom0_max_vcpu argument. In such a case a backup of the PM structure is used and uploaded to the hypervisor. [v1-v2: Initial RFC implementations that were posted] [v3: Changed the name to passthru suggested by Pasi Kärkkäinen <[email protected]>] [v4: Added vCPU != pCPU support - aka dom0_max_vcpus support] [v5: Cleaned up the driver, fix bug under Athlon XP] [v6: Changed the driver to a CPU frequency governor] [v7: Jan Beulich <[email protected]> suggestion to make it a cpufreq scaling driver made me rework it as driver that inhibits cpufreq scaling driver] [v8: Per Jan's review comments, fixed up the driver] [v9: Allow to continue even if acpi_processor_preregister_perf.. fails] Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
1 parent ead1d01 commit 59a5680

File tree

4 files changed

+597
-1
lines changed

4 files changed

+597
-1
lines changed

drivers/xen/Kconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,21 @@ config XEN_PRIVCMD
178178
depends on XEN
179179
default m
180180

181+
config XEN_ACPI_PROCESSOR
182+
tristate "Xen ACPI processor"
183+
depends on XEN && X86 && ACPI_PROCESSOR
184+
default y if (X86_ACPI_CPUFREQ = y || X86_POWERNOW_K8 = y)
185+
default m if (X86_ACPI_CPUFREQ = m || X86_POWERNOW_K8 = m)
186+
help
187+
This ACPI processor uploads Power Management information to the Xen hypervisor.
188+
189+
To do that the driver parses the Power Management data and uploads said
190+
information to the Xen hypervisor. Then the Xen hypervisor can select the
191+
proper Cx and Pxx states. It also registers itslef as the SMM so that
192+
other drivers (such as ACPI cpufreq scaling driver) will not load.
193+
194+
To compile this driver as a module, choose M here: the
195+
module will be called xen_acpi_processor If you do not know what to choose,
196+
select M here. If the CPUFREQ drivers are built in, select Y here.
197+
181198
endmenu

drivers/xen/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o
2020
obj-$(CONFIG_XEN_DOM0) += pci.o
2121
obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/
2222
obj-$(CONFIG_XEN_PRIVCMD) += xen-privcmd.o
23-
23+
obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o
2424
xen-evtchn-y := evtchn.o
2525
xen-gntdev-y := gntdev.o
2626
xen-gntalloc-y := gntalloc.o

0 commit comments

Comments
 (0)