xen: ACPI processor related fixes
Subsystems (5)
cover xen: ACPI processor related fixes
Hello,
This series aims to fix some shortcomings with the handling of ACPI Processors objects when running as a Xen dom0.
First two patches fix the execution of the _PDC methods for all CPUs on the system and not just the ones available to dom0, while also making sure that the _PDC capabilities reported to ACPI match what the perfrmance and power drivers in Xen can handle.
Final patch fixes the Xen ACPI Processor driver to also work when used in a PVH dom0, that has a custom build ACPI MADT table and mismatched Processor UIDs between the MADT and the Processor objects in the dynamic AML.
I don't really like the current implementation of the Xen ACPI Processor driver, it IMO relies too much on data being fetched by generic kernel code. For one the generic fetcher functions can take CPUID data into account in order to sanitize what's found in ACPI, but capabilities reported to dom0 can be different from the native ones. Also the Xen ACPI Processor code relies on cloning the data from CPUs in order to fill for the pCPUs > vCPUs, but this is wrong when running on heterogeneous systems.
Last patch introduces some helpers to Xen ACPI Processor that should allow fetching all the required data, for each ACPI Processor object on the dynamic tables. It might be helpful to explore disabling any Processor object handling done by generic drivers and just fetch all the data from the Xen Processor driver itself for every Processor object on the namespace. Likewise it might be better to just execute _PDC from that same Xen ACPI Processor driver instead of polluting the generic ACPI Processor driver.
The series should be taken as a RFC partially, due to my own doubts about whether the current implementation is indeed the right one moving forward.
Thanks, Roger.
Roger Pau Monne (3):
acpi/processor: fix evaluating _PDC method when running as Xen dom0 acpi/processor: sanitize _PDC buffer bits when running as Xen dom0 xen/acpi: upload power and performance related data from a PVH dom0
arch/x86/include/asm/xen/hypervisor.h | 12 ++ arch/x86/xen/enlighten.c | 44 +++++ drivers/acpi/processor_pdc.c | 19 +++ drivers/xen/xen-acpi-processor.c | 225 ++++++++++++++++++++++++-- 4 files changed, 284 insertions(+), 16 deletions(-)
Signature · 1 line
2.37.3
PATCH 1/3 acpi/processor: fix evaluating _PDC method when running as Xen dom0
When running as a Xen dom0 the number of CPUs available to Linux can be different from the number of CPUs present on the system, but in order to properly fetch processor performance related data _PDC must be executed on all the physical CPUs online on the system.
The current checks in processor_physically_present() result in some processor objects not getting their _PDC methods evaluated when Linux is running as Xen dom0. Fix this by introducing a custom function to use when running as Xen dom0 in order to check whether a processor object matches a CPU that's online.
--- arch/x86/include/asm/xen/hypervisor.h | 10 ++++++++++ arch/x86/xen/enlighten.c | 27 +++++++++++++++++++++++++++ drivers/acpi/processor_pdc.c | 11 +++++++++++ 3 files changed, 48 insertions(+)
arch/x86/include/asm/xen/hypervisor.h +10 -0
@@ -61,4 +61,14 @@ void __init xen_pvh_init(struct boot_params *boot_params);void __init mem_map_via_hcall (struct boot_params *boot_params_p);#endif +#ifdef CONFIG_XEN_DOM0 +bool __init xen_processor_present (uint32_t acpi_id); +#else +static inline bool xen_processor_present (uint32_t acpi_id) +{ +BUG (); +return false; +} +#endif +#endif /* _ASM_X86_XEN_HYPERVISOR_H */
arch/x86/xen/enlighten.c +27 -0
@@ -346,3 +346,30 @@ void xen_arch_unregister_cpu(int num) }EXPORT_SYMBOL (xen_arch_unregister_cpu);#endif + +#ifdef CONFIG_XEN_DOM0 +bool __init xen_processor_present (uint32_t acpi_id) +{ +unsigned int i, maxid; +struct xen_platform_op op = { + .cmd = XENPF_get_cpuinfo, + .interface_version =XENPF_INTERFACE_VERSION , + }; +int ret =HYPERVISOR_platform_op (&op); + +if (ret) +return false; + + maxid = op.u.pcpu_info.max_present; +for (i =0 ; i <= maxid; i++) { + op.u.pcpu_info.xen_cpuid = i; + ret =HYPERVISOR_platform_op (&op); +if (ret) +continue ; +if (op.u.pcpu_info.acpi_id == acpi_id) +return op.u.pcpu_info.flags &XEN_PCPU_FLAGS_ONLINE ; + } + +return false; +} +#endif
drivers/acpi/processor_pdc.c +11 -0
@@ -14,6 +14,8 @@#include <linux/acpi.h> #include <acpi/processor.h> +#include <xen/xen.h> +#include "internal.h" static bool __init processor_physically_present (acpi_handle handle)
@@ -47,6 +49,15 @@ static bool __init processor_physically_present(acpi_handle handle)return false; } +if (xen_initial_domain ()) +/* +* When running as a Xen dom0 the number of processors Linux +* sees can be different from the real number of processors on +* the system, and we still need to execute _PDC for all of +* them. +*/ +return xen_processor_present (acpi_id); + type = (acpi_type ==ACPI_TYPE_DEVICE ) ?1 :0 ; cpuid =acpi_get_cpuid (handle, type, acpi_id);
Signature · 1 line
2.37.3
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 5 lines · Roger Pau Monne
drivers/acpi/processor_pdc.c +1
-0@@ -47,6 +49,15 @@ static bool __init processor_physically_present(acpi_handle handle)return false; } +if (xen_initial_domain ())
drivers/acpi/processor_pdc.c static bool __init processor_physically_present(acpi_handle handle) · line 62
Quoted 10 lines
drivers/acpi/processor_pdc.c +8
-0+/* +* When running as a Xen dom0 the number of processors Linux +* sees can be different from the real number of processors on +* the system, and we still need to execute _PDC for all of +* them. +*/ +return xen_processor_present (acpi_id); + type = (acpi_type ==ACPI_TYPE_DEVICE ) ?1 :0 ; cpuid =acpi_get_cpuid (handle, type, acpi_id);
We had to deal with this in our XenoLinux forward ports as well, but at the time it appeared upstream I decided to make use of acpi_get_apicid() (which meanwhile was renamed to acpi_get_phys_id()). Wouldn't than be an option, eliminating the need for a Xen-specific new function?
Jan
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Roger Pau Monne
drivers/acpi/processor_pdc.c +0
-0@@ -47,6 +49,15 @@ static bool __init processor_physically_present(acpi_handle handle)return false; }
Quoted 16 lines
drivers/acpi/processor_pdc.c static bool __init processor_physically_present(acpi_handle handle) · line 62
Quoted 11 lines
drivers/acpi/processor_pdc.c +9
-0+if (xen_initial_domain ()) +/* +* When running as a Xen dom0 the number of processors Linux +* sees can be different from the real number of processors on +* the system, and we still need to execute _PDC for all of +* them. +*/ +return xen_processor_present (acpi_id); + type = (acpi_type ==ACPI_TYPE_DEVICE ) ?1 :0 ; cpuid =acpi_get_cpuid (handle, type, acpi_id);We had to deal with this in our XenoLinux forward ports as well, but at the time it appeared upstream I decided to make use of
acpi_get_apicid()(which meanwhile was renamed toacpi_get_phys_id()). Wouldn't than be an option, eliminating the need for a Xen-specific new function?
While this would work for PV, it won't work on a PVH dom0, since the ACPI MADT table is not the native one in that case, and thus the Processor UIDs in the MADT don't match the ones in the Processor objects/devices.
Thanks, Roger.
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 23 lines · Roger Pau Monné
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Roger Pau Monne
drivers/acpi/processor_pdc.c +0
-0@@ -47,6 +49,15 @@ static bool __init processor_physically_present(acpi_handle handle)return false; }Quoted 16 lines
drivers/acpi/processor_pdc.c static bool __init processor_physically_present(acpi_handle handle) · line 62
Quoted 11 lines
drivers/acpi/processor_pdc.c +9
-0+if (xen_initial_domain ()) +/* +* When running as a Xen dom0 the number of processors Linux +* sees can be different from the real number of processors on +* the system, and we still need to execute _PDC for all of +* them. +*/ +return xen_processor_present (acpi_id); + type = (acpi_type ==ACPI_TYPE_DEVICE ) ?1 :0 ; cpuid =acpi_get_cpuid (handle, type, acpi_id);We had to deal with this in our XenoLinux forward ports as well, but at the time it appeared upstream I decided to make use of
acpi_get_apicid()(which meanwhile was renamed toacpi_get_phys_id()). Wouldn't than be an option, eliminating the need for a Xen-specific new function?
Quoted 4 lines
While this would work for PV, it won't work on a PVH dom0, since the ACPI MADT table is not the native one in that case, and thus the Processor UIDs in the MADT don't match the ones in the Processor objects/devices.
I wonder whether we can actually get away with this difference long term. I've gone back and looked at the commit introducing the code to build the replacement MADT, but there's no mention of either the reason for the changed numbering or the reason for limiting MADT entries to just the number of CPUs Dom0 will have. (Clearly we need distinct APIC IDs, at least until Xen becomes more flexible / correct in this regard. And clearly we'd need to "invent" ACPI IDs in case Dom0 had more vCPU-s than there are pCPU-s.)
Jan
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 29 lines · Jan Beulich
Quoted 23 lines · Roger Pau Monné
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Roger Pau Monne
drivers/acpi/processor_pdc.c +0
-0@@ -47,6 +49,15 @@ static bool __init processor_physically_present(acpi_handle handle)return false; }Quoted 16 lines
drivers/acpi/processor_pdc.c static bool __init processor_physically_present(acpi_handle handle) · line 62
Quoted 11 lines
drivers/acpi/processor_pdc.c +9
-0+if (xen_initial_domain ()) +/* +* When running as a Xen dom0 the number of processors Linux +* sees can be different from the real number of processors on +* the system, and we still need to execute _PDC for all of +* them. +*/ +return xen_processor_present (acpi_id); + type = (acpi_type ==ACPI_TYPE_DEVICE ) ?1 :0 ; cpuid =acpi_get_cpuid (handle, type, acpi_id);We had to deal with this in our XenoLinux forward ports as well, but at the time it appeared upstream I decided to make use of
acpi_get_apicid()(which meanwhile was renamed toacpi_get_phys_id()). Wouldn't than be an option, eliminating the need for a Xen-specific new function?Quoted 4 lines
While this would work for PV, it won't work on a PVH dom0, since the ACPI MADT table is not the native one in that case, and thus the Processor UIDs in the MADT don't match the ones in the Processor objects/devices.
Quoted 8 lines
I wonder whether we can actually get away with this difference long term. I've gone back and looked at the commit introducing the code to build the replacement MADT, but there's no mention of either the reason for the changed numbering or the reason for limiting MADT entries to just the number of CPUs Dom0 will have. (Clearly we need distinct APIC IDs, at least until Xen becomes more flexible / correct in this regard. And clearly we'd need to "invent" ACPI IDs in case Dom0 had more vCPU-s than there are pCPU-s.)
Linux when running in PVH/HVM mode uses the ACPI Processor UID in the MADT as the vCPU ID, so attempting to re-use the native UIDs doesn't work.
We could expand the dom0 crafted MADT to make sure all the native ACPI Processor UIDs are present in the crafted MADT, by adding them as not present entries, but that seems more like a bodge than a proper solution. Even then those X2APIC entries would appear as offline by the current checks, and thus won't get _PDC evaluated either.
Thanks, Roger.
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
In reply to Roger Pau MonnePing?
So far I've got some feedback from Jan which I've replied to, but I haven't got any more feedback.
Both patches 1 and 2 are required in order for Xen dom0s to properly handle ACPI Processor related data to the hypervisor. Patch 3 can be deal with later.
Thanks, Roger.
Quoted 105 lines · Roger Pau Monne
When running as a Xen dom0 the number of CPUs available to Linux can be different from the number of CPUs present on the system, but in order to properly fetch processor performance related data
_PDCmust be executed on all the physical CPUs online on the system.The current checks in
processor_physically_present()result in some processor objects not getting their_PDCmethods evaluated when Linux is running as Xen dom0. Fix this by introducing a custom function to use when running as Xen dom0 in order to check whether a processor object matches a CPU that's online.Fixes 5d554a7bb064 ('ACPI: processor: add internal processor_physically_present()')Signed-off-by Roger Pau Monné <[email protected]>--- arch/x86/include/asm/xen/hypervisor.h | 10 ++++++++++ arch/x86/xen/enlighten.c | 27 +++++++++++++++++++++++++++ drivers/acpi/processor_pdc.c | 11 +++++++++++ 3 files changed, 48 insertions(+)arch/x86/include/asm/xen/hypervisor.h +10
-0@@ -61,4 +61,14 @@ void __init xen_pvh_init(struct boot_params *boot_params);void __init mem_map_via_hcall (struct boot_params *boot_params_p);#endif +#ifdef CONFIG_XEN_DOM0 +bool __init xen_processor_present (uint32_t acpi_id); +#else +static inline bool xen_processor_present (uint32_t acpi_id) +{ +BUG (); +return false; +} +#endif +#endif /* _ASM_X86_XEN_HYPERVISOR_H */ arch/x86/xen/enlighten.c +27
-0@@ -346,3 +346,30 @@ void xen_arch_unregister_cpu(int num) }EXPORT_SYMBOL (xen_arch_unregister_cpu);#endif + +#ifdef CONFIG_XEN_DOM0 +bool __init xen_processor_present (uint32_t acpi_id) +{ +unsigned int i, maxid; +struct xen_platform_op op = { + .cmd = XENPF_get_cpuinfo, + .interface_version =XENPF_INTERFACE_VERSION , + }; +int ret =HYPERVISOR_platform_op (&op); + +if (ret) +return false; + + maxid = op.u.pcpu_info.max_present; +for (i =0 ; i <= maxid; i++) { + op.u.pcpu_info.xen_cpuid = i; + ret =HYPERVISOR_platform_op (&op); +if (ret) +continue ; +if (op.u.pcpu_info.acpi_id == acpi_id) +return op.u.pcpu_info.flags &XEN_PCPU_FLAGS_ONLINE ; + } + +return false; +} +#endif drivers/acpi/processor_pdc.c +11
-0@@ -14,6 +14,8 @@#include <linux/acpi.h> #include <acpi/processor.h> +#include <xen/xen.h> +#include "internal.h" static bool __init processor_physically_present (acpi_handle handle)@@ -47,6 +49,15 @@ static bool __init processor_physically_present(acpi_handle handle)return false; } +if (xen_initial_domain ()) +/* +* When running as a Xen dom0 the number of processors Linux +* sees can be different from the real number of processors on +* the system, and we still need to execute _PDC for all of +* them. +*/ +return xen_processor_present (acpi_id); + type = (acpi_type ==ACPI_TYPE_DEVICE ) ?1 :0 ; cpuid =acpi_get_cpuid (handle, type, acpi_id);Signature · 1 line
2.37.3
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
In reply to Roger Pau MonneQuoted 4 lines · Roger Pau Monne
When running as a Xen dom0 the number of CPUs available to Linux can be different from the number of CPUs present on the system, but in order to properly fetch processor performance related data
_PDCmust be executed on all the physical CPUs online on the system.
How is the number of CPUs available to Linux different?
Is this a result of the ACPI tables that dom0 sees being "wrong"?
Quoted 5 lines
The current checks in
processor_physically_present()result in some processor objects not getting their_PDCmethods evaluated when Linux is running as Xen dom0. Fix this by introducing a custom function to use when running as Xen dom0 in order to check whether a processor object matches a CPU that's online.
What is the end user visible effect of this problem and of the solution?
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 9 lines · Dave Hansen
Quoted 4 lines · Roger Pau Monne
When running as a Xen dom0 the number of CPUs available to Linux can be different from the number of CPUs present on the system, but in order to properly fetch processor performance related data
_PDCmust be executed on all the physical CPUs online on the system.How is the number of CPUs available to Linux different?
Is this a result of the ACPI tables that dom0 sees being "wrong"?
Depends on the mode. This is all specific to Linux running as a Xen dom0.
For PV dom0 the ACPI tables that dom0 sees are the native ones, however available CPUs are not detected based on the MADT, but using hypercalls, see xen_smp_ops struct and the x86_init.mpparse.get_smp_config hook used in smp_pv.c (_get_smp_config()).
For a PVH dom0 Xen provides dom0 with a crafted MADT table that does only contain the CPUs available to dom0, and hence is likely different from the native one present on the hardware.
In any case, the dynamic tables dom0 sees where the Processor objects/devices reside are not modified by Xen in any way, so the ACPI Processors are always exposed to dom0 as present on the native tables.
Xen cannot parse the dynamic ACPI tables (neither should it, since then it would act as OSPM), so it relies on dom0 to provide same data present on those tables for Xen to properly manage the frequency and idle states of the CPUs on the system.
Quoted 7 lines
Quoted 5 lines
The current checks in
processor_physically_present()result in some processor objects not getting their_PDCmethods evaluated when Linux is running as Xen dom0. Fix this by introducing a custom function to use when running as Xen dom0 in order to check whether a processor object matches a CPU that's online.What is the end user visible effect of this problem and of the solution?
Without this fix _PDC is only evaluated for the CPUs online from dom0 point of view, which means that if dom0 is limited to 8 CPUs but the system has 24 CPUs, _PDC will only get evaluated for 8 CPUs, and that can have the side effect of the data then returned by _PSD method or other methods being different between CPUs where _PDC was evaluated vs CPUs where the method wasn't evaluated. Such mismatches can ultimately lead to for example the CPU frequency driver in Xen not initializing properly because the coordination methods between CPUs on the same domain don't match.
Also not evaluating _PDC prevents the OS (or Xen in this case) from notifying ACPI of the features it supports.
IOW this fix attempts to make sure all physically online CPUs get _PDC evaluated, and in order to to that we need to ask the hypervisor if a Processor ACPI ID matches an online CPU or not, because Linux doesn't have that information when running as dom0.
Hope the above makes sense and allows to make some progress on the issue, sometimes it's hard to summarize without getting too specific,
Thanks, Roger.
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 55 lines · Roger Pau Monné
Quoted 9 lines · Dave Hansen
Quoted 4 lines · Roger Pau Monne
When running as a Xen dom0 the number of CPUs available to Linux can be different from the number of CPUs present on the system, but in order to properly fetch processor performance related data
_PDCmust be executed on all the physical CPUs online on the system.How is the number of CPUs available to Linux different?
Is this a result of the ACPI tables that dom0 sees being "wrong"?
Depends on the mode. This is all specific to Linux running as a Xen dom0.
For PV dom0 the ACPI tables that dom0 sees are the native ones, however available CPUs are not detected based on the MADT, but using hypercalls, see
xen_smp_opsstruct and the x86_init.mpparse.get_smp_config hook used insmp_pv.c(_get_smp_config()).For a PVH dom0 Xen provides dom0 with a crafted MADT table that does only contain the CPUs available to dom0, and hence is likely different from the native one present on the hardware.
In any case, the dynamic tables dom0 sees where the Processor objects/devices reside are not modified by Xen in any way, so the ACPI Processors are always exposed to dom0 as present on the native tables.
Xen cannot parse the dynamic ACPI tables (neither should it, since then it would act as OSPM), so it relies on dom0 to provide same data present on those tables for Xen to properly manage the frequency and idle states of the CPUs on the system.
Quoted 7 lines
Quoted 5 lines
The current checks in
processor_physically_present()result in some processor objects not getting their_PDCmethods evaluated when Linux is running as Xen dom0. Fix this by introducing a custom function to use when running as Xen dom0 in order to check whether a processor object matches a CPU that's online.What is the end user visible effect of this problem and of the solution?
Without this fix
_PDCis only evaluated for the CPUs online from dom0 point of view, which means that if dom0 is limited to 8 CPUs but the system has 24 CPUs,_PDCwill only get evaluated for 8 CPUs, and that can have the side effect of the data then returned by_PSDmethod or other methods being different between CPUs where_PDCwas evaluated vs CPUs where the method wasn't evaluated. Such mismatches can ultimately lead to for example the CPU frequency driver in Xen not initializing properly because the coordination methods between CPUs on the same domain don't match.Also not evaluating
_PDCprevents the OS (or Xen in this case) from notifying ACPI of the features it supports.
Quoted 8 lines
IOW this fix attempts to make sure all physically online CPUs get
_PDCevaluated, and in order to to that we need to ask the hypervisor if a Processor ACPI ID matches an online CPU or not, because Linux doesn't have that information when running as dom0.Hope the above makes sense and allows to make some progress on the issue, sometimes it's hard to summarize without getting too specific,
Yes, writing changelogs is hard. :)
Let's try though. I was missing some key pieces of background here. Believe it or not, I had no idea off the top of my head what _PDC was or why it's important.
the information about _PDC being required on all processors was missing, as was the information about the dom0's incomplete concept of the available physical processors.
== Background ==
In ACPI systems, the OS can direct power management, as opposed to the firmware. This OS-directed Power Management is called OSPM. Part of telling the firmware that the OS going to direct power management is making ACPI "_PDC" (Processor Driver Capabilities) calls. These _PDC calls must be made on every processor. If these _PDC calls are not completed on every processor it can lead to inconsistency and later failures in things like the CPU frequency driver.
In a Xen system, the dom0 kernel is responsible for system-wide power management. The dom0 kernel is in charge of OSPM. However, the Xen hypervisor hides some processors information from the dom0 kernel. This is presumably done to ensure that the dom0 system has less interference with guests that want to use the other processors.
== Problem ==
But, this leads to a problem: the dom0 kernel needs to run _PDC on all the processors, but it can't always see them.
== Solution ==
In dom0 kernels, ignore the existing ACPI method for determining if a processor is physically present because it might not be accurate. Instead, ask the hypervisor for this information.
This ensures that ...
----
Is that about right?
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 77 lines · Dave Hansen
Quoted 55 lines · Roger Pau Monné
Quoted 9 lines · Dave Hansen
Quoted 4 lines · Roger Pau Monne
When running as a Xen dom0 the number of CPUs available to Linux can be different from the number of CPUs present on the system, but in order to properly fetch processor performance related data
_PDCmust be executed on all the physical CPUs online on the system.How is the number of CPUs available to Linux different?
Is this a result of the ACPI tables that dom0 sees being "wrong"?
Depends on the mode. This is all specific to Linux running as a Xen dom0.
For PV dom0 the ACPI tables that dom0 sees are the native ones, however available CPUs are not detected based on the MADT, but using hypercalls, see
xen_smp_opsstruct and the x86_init.mpparse.get_smp_config hook used insmp_pv.c(_get_smp_config()).For a PVH dom0 Xen provides dom0 with a crafted MADT table that does only contain the CPUs available to dom0, and hence is likely different from the native one present on the hardware.
In any case, the dynamic tables dom0 sees where the Processor objects/devices reside are not modified by Xen in any way, so the ACPI Processors are always exposed to dom0 as present on the native tables.
Xen cannot parse the dynamic ACPI tables (neither should it, since then it would act as OSPM), so it relies on dom0 to provide same data present on those tables for Xen to properly manage the frequency and idle states of the CPUs on the system.
Quoted 7 lines
Quoted 5 lines
The current checks in
processor_physically_present()result in some processor objects not getting their_PDCmethods evaluated when Linux is running as Xen dom0. Fix this by introducing a custom function to use when running as Xen dom0 in order to check whether a processor object matches a CPU that's online.What is the end user visible effect of this problem and of the solution?
Without this fix
_PDCis only evaluated for the CPUs online from dom0 point of view, which means that if dom0 is limited to 8 CPUs but the system has 24 CPUs,_PDCwill only get evaluated for 8 CPUs, and that can have the side effect of the data then returned by_PSDmethod or other methods being different between CPUs where_PDCwas evaluated vs CPUs where the method wasn't evaluated. Such mismatches can ultimately lead to for example the CPU frequency driver in Xen not initializing properly because the coordination methods between CPUs on the same domain don't match.Also not evaluating
_PDCprevents the OS (or Xen in this case) from notifying ACPI of the features it supports.Quoted 8 lines
IOW this fix attempts to make sure all physically online CPUs get
_PDCevaluated, and in order to to that we need to ask the hypervisor if a Processor ACPI ID matches an online CPU or not, because Linux doesn't have that information when running as dom0.Hope the above makes sense and allows to make some progress on the issue, sometimes it's hard to summarize without getting too specific,
Yes, writing changelogs is hard. :)
Let's try though. I was missing some key pieces of background here. Believe it or not, I had no idea off the top of my head what
_PDCwas or why it's important.the information about
_PDCbeing required on all processors was missing, as was the information about the dom0's incomplete concept of the available physical processors.== Background ==
Quoted 7 lines
In ACPI systems, the OS can direct power management, as opposed to the firmware. This OS-directed Power Management is called OSPM. Part of telling the firmware that the OS going to direct power management is making ACPI "
_PDC" (Processor Driver Capabilities) calls. These_PDCcalls must be made on every processor. If these_PDCcalls are not completed on every processor it can lead to inconsistency and later failures in things like the CPU frequency driver.
I think the "on every processor" is not fully accurate. _PDC methods need to be evaluated for every Processor object. Whether that evaluation is executed on the physical processor that matches the ACPI UID of the object/device is not mandatory (iow: you can evaluate the _PDC methods of all Processor objects from the BSP). The usage of 'on' seems to me to note that the methods are executed on the matching physical processors.
I would instead use: "... must be made for every processor. If these _PDC calls are not completed for every processor..."
But I'm not a native English speaker, so this might all be irrelevant.
Quoted 6 lines
In a Xen system, the dom0 kernel is responsible for system-wide power management. The dom0 kernel is in charge of OSPM. However, the Xen hypervisor hides some processors information from the dom0 kernel. This is presumably done to ensure that the dom0 system has less interference with guests that want to use the other processors.
dom0 on a Xen system is just another guest, so the admin can limit the number of CPUs available to dom0, that's why we get into this weird situation.
Quoted 11 lines
== Problem ==
But, this leads to a problem: the dom0 kernel needs to run
_PDCon all the processors, but it can't always see them.== Solution ==
In dom0 kernels, ignore the existing ACPI method for determining if a processor is physically present because it might not be accurate. Instead, ask the hypervisor for this information.
Quoted 5 lines
This ensures that ...
----
Is that about right?
Yes, I think it's accurate. I will add to my commit log, thanks!
On the implementation side, is the proposed approach acceptable? Mostly asking because it adds Xen conditionals to otherwise generic ACPI code.
Thanks, Roger.
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 3 lines · Roger Pau Monné
On the implementation side, is the proposed approach acceptable? Mostly asking because it adds Xen conditionals to otherwise generic ACPI code.
That's a good Rafael question.
But, how do other places in the ACPI code handle things like this?
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 8 lines · Dave Hansen
Quoted 3 lines · Roger Pau Monné
On the implementation side, is the proposed approach acceptable? Mostly asking because it adds Xen conditionals to otherwise generic ACPI code.
That's a good Rafael question.
But, how do other places in the ACPI code handle things like this?
Hm, I don't know of other places in the Xen case, the only resource in ACPI AML tables managed by Xen are Processor objects/devices AFAIK. The rest of devices are fully managed by the dom0 guest.
I think such special handling is very specific to Xen, but maybe I'm wrong and there are similar existing cases in ACPI code already.
We could add some kind of hook (iow: a function pointer in some struct that could be filled on a implementation basis?) but I didn't want overengineering this if adding a conditional was deemed OK.
Thanks, Roger.
Rafael J. Wysocki
maintainerRe: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Dave Hansen
Quoted 3 lines · Roger Pau Monné
On the implementation side, is the proposed approach acceptable? Mostly asking because it adds Xen conditionals to otherwise generic ACPI code.
That's a good Rafael question.
Sorry for joining late, but first off _PDC has been deprecated since ACPI 3.0 (2004) and it is not even present in ACPI 6.5 any more.
It follows from your description that _PDC is still used in the field, though, after 18 years of deprecation. Who uses it, if I may know?
Quoted 6 lines
Quoted 1 line
But, how do other places in the ACPI code handle things like this?
Hm, I don't know of other places in the Xen case, the only resource in ACPI AML tables managed by Xen are Processor objects/devices AFAIK. The rest of devices are fully managed by the dom0 guest.
Quoted 6 lines
I think such special handling is very specific to Xen, but maybe I'm wrong and there are similar existing cases in ACPI code already.
We could add some kind of hook (iow: a function pointer in some struct that could be filled on a implementation basis?) but I didn't want overengineering this if adding a conditional was deemed OK.
What _PDC capabilities specifically do you need to pass to the firmware for things to work correctly?
What platforms are affected?
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines · Roger Pau Monné
Quoted 5 lines · Dave Hansen
Quoted 3 lines · Roger Pau Monné
On the implementation side, is the proposed approach acceptable? Mostly asking because it adds Xen conditionals to otherwise generic ACPI code.
Quoted 7 lines
Quoted 1 line
Quoted 1 line
That's a good Rafael question.
Sorry for joining late, but first off
_PDChas been deprecated since ACPI 3.0 (2004) and it is not even present in ACPI 6.5 any more.It follows from your description that
_PDCis still used in the field, though, after 18 years of deprecation. Who uses it, if I may know?
I saw this issue on a Sapphire Rapids SDP from Intel, but I would think there are other platforms affected.
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
But, how do other places in the ACPI code handle things like this?
Hm, I don't know of other places in the Xen case, the only resource in ACPI AML tables managed by Xen are Processor objects/devices AFAIK. The rest of devices are fully managed by the dom0 guest.
I think such special handling is very specific to Xen, but maybe I'm wrong and there are similar existing cases in ACPI code already.
Quoted 6 lines
Quoted 3 lines
We could add some kind of hook (iow: a function pointer in some struct that could be filled on a implementation basis?) but I didn't want overengineering this if adding a conditional was deemed OK.
What
_PDCcapabilities specifically do you need to pass to the firmware for things to work correctly?
I'm not sure what capabilities do I need to pass explicitly to _PSD, but the call to _PDC as done by Linux currently changes the reported _PSD Coordination Field (vs not doing the call).
Thanks, Roger.
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
In reply to Roger Pau MonneQuoted 62 lines · Roger Pau Monne
When running as a Xen dom0 the number of CPUs available to Linux can be different from the number of CPUs present on the system, but in order to properly fetch processor performance related data
_PDCmust be executed on all the physical CPUs online on the system.The current checks in
processor_physically_present()result in some processor objects not getting their_PDCmethods evaluated when Linux is running as Xen dom0. Fix this by introducing a custom function to use when running as Xen dom0 in order to check whether a processor object matches a CPU that's online.Fixes 5d554a7bb064 ('ACPI: processor: add internal processor_physically_present()')Signed-off-by Roger Pau Monné <[email protected]>--- arch/x86/include/asm/xen/hypervisor.h | 10 ++++++++++ arch/x86/xen/enlighten.c | 27 +++++++++++++++++++++++++++ drivers/acpi/processor_pdc.c | 11 +++++++++++ 3 files changed, 48 insertions(+)arch/x86/include/asm/xen/hypervisor.h +10
-0@@ -61,4 +61,14 @@ void __init xen_pvh_init(struct boot_params *boot_params);void __init mem_map_via_hcall (struct boot_params *boot_params_p);#endif +#ifdef CONFIG_XEN_DOM0 +bool __init xen_processor_present (uint32_t acpi_id); +#else +static inline bool xen_processor_present (uint32_t acpi_id) +{ +BUG (); +return false; +} +#endif +#endif /* _ASM_X86_XEN_HYPERVISOR_H */ arch/x86/xen/enlighten.c +16
-0@@ -346,3 +346,30 @@ void xen_arch_unregister_cpu(int num) }EXPORT_SYMBOL (xen_arch_unregister_cpu);#endif + +#ifdef CONFIG_XEN_DOM0 +bool __init xen_processor_present (uint32_t acpi_id) +{ +unsigned int i, maxid; +struct xen_platform_op op = { + .cmd = XENPF_get_cpuinfo, + .interface_version =XENPF_INTERFACE_VERSION , + }; +int ret =HYPERVISOR_platform_op (&op); + +if (ret) +return false; + + maxid = op.u.pcpu_info.max_present; +for (i =0 ; i <= maxid; i++) {
arch/x86/xen/enlighten.c void xen_arch_unregister_cpu(int num) · line 374
Quoted 10 lines
arch/x86/xen/enlighten.c +10
-0+ op.u.pcpu_info.xen_cpuid = i; + ret =HYPERVISOR_platform_op (&op); +if (ret) +continue ; +if (op.u.pcpu_info.acpi_id == acpi_id) +return op.u.pcpu_info.flags &XEN_PCPU_FLAGS_ONLINE ; + } + +return false; +}
My compiler (Default GCC on Fedora 32, compiling for Qubes) complain loudly that the below was missing.
+}
+EXPORT_SYMBOL(xen_processor_present);
ERROR: MODPOST xen_processor_present [drivers/xen/xen-acpi-processor.ko] undefined!
Same thing with xen_sanitize_pdc in the next patch.
+}
+EXPORT_SYMBOL(xen_sanitize_pdc);
Everything compiled fine after those changes.
Quoted 30 lines
arch/x86/xen/enlighten.c +1
-0+#endif drivers/acpi/processor_pdc.c +11
-0@@ -14,6 +14,8 @@#include <linux/acpi.h> #include <acpi/processor.h> +#include <xen/xen.h> +#include "internal.h" static bool __init processor_physically_present (acpi_handle handle)@@ -47,6 +49,15 @@ static bool __init processor_physically_present(acpi_handle handle)return false; } +if (xen_initial_domain ()) +/* +* When running as a Xen dom0 the number of processors Linux +* sees can be different from the real number of processors on +* the system, and we still need to execute _PDC for all of +* them. +*/ +return xen_processor_present (acpi_id); + type = (acpi_type ==ACPI_TYPE_DEVICE ) ?1 :0 ; cpuid =acpi_get_cpuid (handle, type, acpi_id);
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 47 lines · Josef Johansson
Quoted 22 lines · Roger Pau Monne
arch/x86/xen/enlighten.c +16
-0@@ -346,3 +346,30 @@ void xen_arch_unregister_cpu(int num) }EXPORT_SYMBOL (xen_arch_unregister_cpu);#endif + +#ifdef CONFIG_XEN_DOM0 +bool __init xen_processor_present (uint32_t acpi_id) +{ +unsigned int i, maxid; +struct xen_platform_op op = { + .cmd = XENPF_get_cpuinfo, + .interface_version =XENPF_INTERFACE_VERSION , + }; +int ret =HYPERVISOR_platform_op (&op); + +if (ret) +return false; + + maxid = op.u.pcpu_info.max_present; +for (i =0 ; i <= maxid; i++) {arch/x86/xen/enlighten.c void xen_arch_unregister_cpu(int num) · line 374
Quoted 10 lines
arch/x86/xen/enlighten.c +10
-0+ op.u.pcpu_info.xen_cpuid = i; + ret =HYPERVISOR_platform_op (&op); +if (ret) +continue ; +if (op.u.pcpu_info.acpi_id == acpi_id) +return op.u.pcpu_info.flags &XEN_PCPU_FLAGS_ONLINE ; + } + +return false; +}My compiler (Default GCC on Fedora 32, compiling for Qubes) complain loudly that the below was missing.
(quoted diff) +2
-0+} +EXPORT_SYMBOL(xen_processor_present);`ERROR: MODPOST
xen_processor_present
[drivers/xen/xen-acpi-processor.ko] undefined!`Same thing with
xen_sanitize_pdcin the next patch.(quoted diff) +2
-0+} +EXPORT_SYMBOL(xen_sanitize_pdc);
Quoted 1 line
Everything compiled fine after those changes.
Except that you may not export __init symbols. The section mismatch checker should actually complain about that.
Jan
Re: [PATCH 1/3] acpi/processor: fix evaluating _PDC method when running as Xen dom0
Quoted 45 lines · Jan Beulich
Quoted 44 lines · Josef Johansson
Quoted 22 lines · Roger Pau Monne
arch/x86/xen/enlighten.c +16
-0@@ -346,3 +346,30 @@ void xen_arch_unregister_cpu(int num) }EXPORT_SYMBOL (xen_arch_unregister_cpu);#endif + +#ifdef CONFIG_XEN_DOM0 +bool __init xen_processor_present (uint32_t acpi_id) +{ +unsigned int i, maxid; +struct xen_platform_op op = { + .cmd = XENPF_get_cpuinfo, + .interface_version =XENPF_INTERFACE_VERSION , + }; +int ret =HYPERVISOR_platform_op (&op); + +if (ret) +return false; + + maxid = op.u.pcpu_info.max_present; +for (i =0 ; i <= maxid; i++) {arch/x86/xen/enlighten.c void xen_arch_unregister_cpu(int num) · line 374
Quoted 10 lines
arch/x86/xen/enlighten.c +10
-0+ op.u.pcpu_info.xen_cpuid = i; + ret =HYPERVISOR_platform_op (&op); +if (ret) +continue ; +if (op.u.pcpu_info.acpi_id == acpi_id) +return op.u.pcpu_info.flags &XEN_PCPU_FLAGS_ONLINE ; + } + +return false; +}My compiler (Default GCC on Fedora 32, compiling for Qubes) complain loudly that the below was missing.
(quoted diff) +2
-0+} +EXPORT_SYMBOL(xen_processor_present);`ERROR: MODPOST
xen_processor_present
[drivers/xen/xen-acpi-processor.ko] undefined!`Same thing with
xen_sanitize_pdcin the next patch.
Quoted 8 lines
Quoted 4 lines
(quoted diff) +2
-0+} +EXPORT_SYMBOL(xen_sanitize_pdc);Everything compiled fine after those changes.
Except that you may not export
__initsymbols. The section mismatch checker should actually complain about that.Jan
That makes sense. Patch 3 does change it from an __init though.
arch/x86/xen/enlighten.c +0 -0
@@ -348,7 +348,7 @@ EXPORT_SYMBOL(xen_arch_unregister_cpu);
#endif
#ifdef CONFIG_XEN_DOM0
-bool __init xen_processor_present(uint32_t acpi_id) +bool xen_processor_present(uint32_t acpi_id) {
So the change should be in Patch 3 I guess.
Regards
- Josef
PATCH 2/3 acpi/processor: sanitize _PDC buffer bits when running as Xen dom0
In reply to Roger Pau MonneThe Processor _PDC buffer bits notify ACPI of the OS capabilities, and so ACPI can adjust the return of other Processor methods taking the OS capabilities into account.
When Linux is running as a Xen dom0, it's the hypervisor the entity in charge of processor power management, and hence Xen needs to make sure the capabilities reported in the _PDC buffer match the capabilities of the driver in Xen.
Introduce a small helper to sanitize the buffer when running as Xen dom0.
--- arch/x86/include/asm/xen/hypervisor.h | 2 ++ arch/x86/xen/enlighten.c | 17 +++++++++++++++++ drivers/acpi/processor_pdc.c | 8 ++++++++ 3 files changed, 27 insertions(+)
arch/x86/include/asm/xen/hypervisor.h +2 -0
@@ -63,12 +63,14 @@ void __init mem_map_via_hcall(struct boot_params *boot_params_p);#ifdef CONFIG_XEN_DOM0 bool __init xen_processor_present (uint32_t acpi_id); +void xen_sanitize_pdc (uint32_t *buf);#else static inline bool xen_processor_present (uint32_t acpi_id) {BUG ();return false; } +static inline void xen_sanitize_pdc (uint32_t *buf) {BUG (); }#endif #endif /* _ASM_X86_XEN_HYPERVISOR_H */
arch/x86/xen/enlighten.c +17 -0
@@ -372,4 +372,21 @@ bool __init xen_processor_present(uint32_t acpi_id) return false; } + +void xen_sanitize_pdc (uint32_t *buf) +{ +struct xen_platform_op op = { + .cmd = XENPF_set_processor_pminfo, + .interface_version =XENPF_INTERFACE_VERSION , + .u.set_pminfo.id =-1 , + .u.set_pminfo.type =XEN_PM_PDC , + }; +int ret; + +set_xen_guest_handle (op.u.set_pminfo.pdc, buf); + ret =HYPERVISOR_platform_op (&op); +if (ret) +pr_info ("sanitize of _PDC buffer bits from Xen failed: %d\n" , + ret); +}#endif
drivers/acpi/processor_pdc.c +8 -0
@@ -137,6 +137,14 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) buffer[2 ] &= ~(ACPI_PDC_C_C2C3_FFH |ACPI_PDC_C_C1_FFH ); } +if (xen_initial_domain ()) +/* +* When Linux is running as Xen dom0 it's the hypervisor the +* entity in charge of the processor power management, and so +* Xen needs to check the OS capabilities reported in the _PDC +* buffer matches what the hypervisor driver supports. +*/ +xen_sanitize_pdc ((uint32_t *)pdc_in->pointer->buffer.pointer); status =acpi_evaluate_object (handle,"_PDC" , pdc_in,NULL );if (ACPI_FAILURE (status))
Signature · 1 line
2.37.3
Re: [PATCH 2/3] acpi/processor: sanitize _PDC buffer bits when running as Xen dom0
Quoted 5 lines · Roger Pau Monne
drivers/acpi/processor_pdc.c +0
-0@@ -137,6 +137,14 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) buffer[2 ] &= ~(ACPI_PDC_C_C2C3_FFH |ACPI_PDC_C_C1_FFH );
drivers/acpi/processor_pdc.c acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) · line 148
Quoted 10 lines
drivers/acpi/processor_pdc.c +8
-0} +if (xen_initial_domain ()) +/* +* When Linux is running as Xen dom0 it's the hypervisor the +* entity in charge of the processor power management, and so +* Xen needs to check the OS capabilities reported in the _PDC +* buffer matches what the hypervisor driver supports. +*/ +xen_sanitize_pdc ((uint32_t *)pdc_in->pointer->buffer.pointer); status =acpi_evaluate_object (handle,"_PDC" , pdc_in,NULL );
Again looking at our old XenoLinux forward port we had this inside the earlier if(), as an _alternative_ to the &= (I don't think it's valid to apply both the kernel's and Xen's adjustments). That would also let you use "buffer" rather than re-calculating it via yet another (risky from an abstract pov) cast.
It was the very nature of requiring Xen-specific conditionals which I understand was the reason why so far no attempt was made to get this (incl the corresponding logic for patch 1) into any upstream kernel.
Jan
Re: [PATCH 2/3] acpi/processor: sanitize _PDC buffer bits when running as Xen dom0
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
drivers/acpi/processor_pdc.c +0
-0@@ -137,6 +137,14 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) buffer[2 ] &= ~(ACPI_PDC_C_C2C3_FFH |ACPI_PDC_C_C1_FFH );
Quoted 16 lines
drivers/acpi/processor_pdc.c acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) · line 148
Quoted 10 lines
drivers/acpi/processor_pdc.c +8
-0} +if (xen_initial_domain ()) +/* +* When Linux is running as Xen dom0 it's the hypervisor the +* entity in charge of the processor power management, and so +* Xen needs to check the OS capabilities reported in the _PDC +* buffer matches what the hypervisor driver supports. +*/ +xen_sanitize_pdc ((uint32_t *)pdc_in->pointer->buffer.pointer); status =acpi_evaluate_object (handle,"_PDC" , pdc_in,NULL );Again looking at our old XenoLinux forward port we had this inside the earlier
if(), as an _alternative_ to the &= (I don't think it's valid to apply both the kernel's and Xen's adjustments). That would also let you use "buffer" rather than re-calculating it via yet another (risky from an abstract pov) cast.
Oh, I notice this can end up being misleading: Besides having it in the earlier if() we had also #ifdef-ed out that if() itself (keeping just the body). The equivalent of this here might then be
if (boot_option_idle_override == IDLE_NOMWAIT || xen_initial_domain()) {Jan
Re: [PATCH 2/3] acpi/processor: sanitize _PDC buffer bits when running as Xen dom0
In reply to Jan BeulichQuoted 6 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
drivers/acpi/processor_pdc.c +0
-0@@ -137,6 +137,14 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) buffer[2 ] &= ~(ACPI_PDC_C_C2C3_FFH |ACPI_PDC_C_C1_FFH );
Quoted 16 lines
drivers/acpi/processor_pdc.c acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) · line 148
Quoted 10 lines
drivers/acpi/processor_pdc.c +8
-0} +if (xen_initial_domain ()) +/* +* When Linux is running as Xen dom0 it's the hypervisor the +* entity in charge of the processor power management, and so +* Xen needs to check the OS capabilities reported in the _PDC +* buffer matches what the hypervisor driver supports. +*/ +xen_sanitize_pdc ((uint32_t *)pdc_in->pointer->buffer.pointer); status =acpi_evaluate_object (handle,"_PDC" , pdc_in,NULL );Again looking at our old XenoLinux forward port we had this inside the earlier
if(), as an _alternative_ to the &= (I don't think it's valid to apply both the kernel's and Xen's adjustments). That would also let you use "buffer" rather than re-calculating it via yet another (risky from an abstract pov) cast.
Hm, I've wondered this and decided it wasn't worth to short-circuit the boot_option_idle_override conditional because ACPI_PDC_C_C2C3_FFH and ACPI_PDC_C_C1_FFH will be set anyway by Xen in arch_acpi_set_pdc_bits() as part of ACPI_PDC_C_CAPABILITY_SMP.
I could re-use some of the code in there, but didn't want to make it more difficult to read just for the benefit of reusing buffer.
Quoted 3 lines
It was the very nature of requiring Xen-specific conditionals which I understand was the reason why so far no attempt was made to get this (incl the corresponding logic for patch 1) into any upstream kernel.
Yes, well, it's all kind of ugly. Hence my suggestion to simply avoid doing any ACPI Processor object handling in Linux with the native code and handle it all in a Xen specific driver. That requires the Xen driver being able to fetch more data itself form the ACPI Processor methods, but also unties it from the dependency on the data being filled by the generic code, and the 'tricks' is plays into fooling generic code to think certain processors are online.
Thanks, Roger.
Re: [PATCH 2/3] acpi/processor: sanitize _PDC buffer bits when running as Xen dom0
Hi, Roger,
Quoted 37 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
drivers/acpi/processor_pdc.c +0
-0@@ -137,6 +137,14 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) buffer[2 ] &= ~(ACPI_PDC_C_C2C3_FFH |ACPI_PDC_C_C1_FFH );Quoted 16 lines
drivers/acpi/processor_pdc.c acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) · line 148
Quoted 10 lines
drivers/acpi/processor_pdc.c +8
-0} +if (xen_initial_domain ()) +/* +* When Linux is running as Xen dom0 it's the hypervisor the +* entity in charge of the processor power management, and so +* Xen needs to check the OS capabilities reported in the _PDC +* buffer matches what the hypervisor driver supports. +*/ +xen_sanitize_pdc ((uint32_t *)pdc_in->pointer->buffer.pointer); status =acpi_evaluate_object (handle,"_PDC" , pdc_in,NULL );Again looking at our old XenoLinux forward port we had this inside the earlier
if(), as an _alternative_ to the &= (I don't think it's valid to apply both the kernel's and Xen's adjustments). That would also let you use "buffer" rather than re-calculating it via yet another (risky from an abstract pov) cast.Hm, I've wondered this and decided it wasn't worth to short-circuit the
boot_option_idle_overrideconditional becauseACPI_PDC_C_C2C3_FFHandACPI_PDC_C_C1_FFHwill be set anyway by Xen inarch_acpi_set_pdc_bits()as part ofACPI_PDC_C_CAPABILITY_SMP.I could re-use some of the code in there, but didn't want to make it more difficult to read just for the benefit of reusing buffer.
Quoted 3 lines
It was the very nature of requiring Xen-specific conditionals which I understand was the reason why so far no attempt was made to get this (incl the corresponding logic for patch 1) into any upstream kernel.
Quoted 7 lines
Yes, well, it's all kind of ugly. Hence my suggestion to simply avoid doing any ACPI Processor object handling in Linux with the native code and handle it all in a Xen specific driver. That requires the Xen driver being able to fetch more data itself form the ACPI Processor methods, but also unties it from the dependency on the data being filled by the generic code, and the 'tricks' is plays into fooling generic code to think certain processors are online.
Are you working on this patch anymore? My Xen HWP patches need a Linux patch like this one to set bit 12 in the PDC. I had an affected user test with this patch and it worked, serving as an equivalent of Linux commit a21211672c9a ("ACPI / processor: Request native thermal interrupt handling via _OSC").
Another idea is to use Linux's arch_acpi_set_pdc_bits() to make the hypercall to Xen. It occurs earlier:acpi_processor_set_pdc()
acpi_processor_alloc_pdc()
acpi_set_pdc_bits()
arch_acpi_set_pdc_bits()
acpi_processor_eval_pdc()So the IDLE_NOMWAIT masking in acpi_processor_eval_pdc() would still apply. arch_acpi_set_pdc_bits() is provided the buffer, so it's a little cleaner in that respect.
Thanks,
Jason
Re: [PATCH 2/3] acpi/processor: sanitize _PDC buffer bits when running as Xen dom0
Quoted 48 lines · Jason Andryuk
Hi, Roger,
Quoted 37 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
drivers/acpi/processor_pdc.c +0
-0@@ -137,6 +137,14 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) buffer[2 ] &= ~(ACPI_PDC_C_C2C3_FFH |ACPI_PDC_C_C1_FFH );Quoted 16 lines
drivers/acpi/processor_pdc.c acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) · line 148
Quoted 10 lines
drivers/acpi/processor_pdc.c +8
-0} +if (xen_initial_domain ()) +/* +* When Linux is running as Xen dom0 it's the hypervisor the +* entity in charge of the processor power management, and so +* Xen needs to check the OS capabilities reported in the _PDC +* buffer matches what the hypervisor driver supports. +*/ +xen_sanitize_pdc ((uint32_t *)pdc_in->pointer->buffer.pointer); status =acpi_evaluate_object (handle,"_PDC" , pdc_in,NULL );Again looking at our old XenoLinux forward port we had this inside the earlier
if(), as an _alternative_ to the &= (I don't think it's valid to apply both the kernel's and Xen's adjustments). That would also let you use "buffer" rather than re-calculating it via yet another (risky from an abstract pov) cast.Hm, I've wondered this and decided it wasn't worth to short-circuit the
boot_option_idle_overrideconditional becauseACPI_PDC_C_C2C3_FFHandACPI_PDC_C_C1_FFHwill be set anyway by Xen inarch_acpi_set_pdc_bits()as part ofACPI_PDC_C_CAPABILITY_SMP.I could re-use some of the code in there, but didn't want to make it more difficult to read just for the benefit of reusing buffer.
Quoted 3 lines
It was the very nature of requiring Xen-specific conditionals which I understand was the reason why so far no attempt was made to get this (incl the corresponding logic for patch 1) into any upstream kernel.
Quoted 7 lines
Yes, well, it's all kind of ugly. Hence my suggestion to simply avoid doing any ACPI Processor object handling in Linux with the native code and handle it all in a Xen specific driver. That requires the Xen driver being able to fetch more data itself form the ACPI Processor methods, but also unties it from the dependency on the data being filled by the generic code, and the 'tricks' is plays into fooling generic code to think certain processors are online.
Quoted 1 line
Are you working on this patch anymore?
Not really, I didn't get any feedback from maintainers (apart from Jans comments, which I do value), and wasn't aware of this causing issues, or being required by any other work, hence I kind of dropped it (I have plenty of other stuff to work on).
Quoted 9 lines
My Xen HWP patches need a
Linux patch like this one to set bit 12 in the PDC. I had an affected user test with this patch and it worked, serving as an equivalent of Linux commita21211672c9a("ACPI / processor: Request native thermal interrupt handling via_OSC").Another idea is to use Linux's
arch_acpi_set_pdc_bits()to make the hypercall to Xen. It occurs earlier:acpi_processor_set_pdc()
Quoted 8 lines
acpi_processor_alloc_pdc() acpi_set_pdc_bits() arch_acpi_set_pdc_bits() acpi_processor_eval_pdc()So the
IDLE_NOMWAITmasking inacpi_processor_eval_pdc()would still apply.arch_acpi_set_pdc_bits()is provided the buffer, so it's a little cleaner in that respect.
I see. My reasoning for placing the Xen filtering in acpi_processor_eval_pdc() is so that there are no further modifications to the buffer by Linux after the call to sanitize the buffer (XENPF_set_processor_pminfo).
I think if the filtering done by Xen is moved to arch_acpi_set_pdc_bits() we would then need to disable the evaluation of boot_option_idle_override in acpi_processor_eval_pdc() as we don't want dom0 choices affecting the selection of _PDC features done by Xen?
In any case, feel free to pick this patch and re-submit upstream if you want.
Thanks, Roger.
PATCH 3/3 xen/acpi: upload power and performance related data from a PVH dom0
In reply to Roger Pau MonneWhen running as a PVH dom0 the ACPI MADT is crafted by Xen in order to report the correct numbers of vCPUs that dom0 has, so the host MADT is not provided to dom0. This creates issues when parsing the power and performance related data from ACPI dynamic tables, as the ACPI Processor UIDs found on the dynamic code are likely to not match the ones crafted by Xen in the dom0 MADT.
Xen would rely on Linux having filled at least the power and performance related data of the vCPUs on the system, and would clone that information in order to setup the remaining pCPUs on the system if dom0 vCPUs < pCPUs. However when running as PVH dom0 it's likely that none of dom0 CPUs will have the power and performance data filled, and hence the Xen ACPI Processor driver needs to fetch that information by itself.
In order to do so correctly, introduce a new helper to fetch the _CST data without taking into account the system capabilities from the CPUID output, as the capabilities reported to dom0 in CPUID might be different from the ones on the host.
Note that the newly introduced code will only fetch the _CST, _PSS, _PPC and _PCT from a single CPU, and clone that information for all the other Processors. This won't work on an heterogeneous system with Processors having different power and performance related data between them.
--- arch/x86/include/asm/xen/hypervisor.h | 2 +- arch/x86/xen/enlighten.c | 2 +- drivers/xen/xen-acpi-processor.c | 225 ++++++++++++++++++++++++-- 3 files changed, 211 insertions(+), 18 deletions(-)
arch/x86/include/asm/xen/hypervisor.h +1 -1
@@ -62,7 +62,7 @@ void __init mem_map_via_hcall(struct boot_params *boot_params_p);#endif #ifdef CONFIG_XEN_DOM0 -bool __init xen_processor_present (uint32_t acpi_id); +bool xen_processor_present (uint32_t acpi_id);void xen_sanitize_pdc (uint32_t *buf);#else static inline bool xen_processor_present (uint32_t acpi_id)
arch/x86/xen/enlighten.c +1 -1
@@ -348,7 +348,7 @@ EXPORT_SYMBOL(xen_arch_unregister_cpu);#endif #ifdef CONFIG_XEN_DOM0 -bool __init xen_processor_present(uint32_t acpi_id) +bool xen_processor_present(uint32_t acpi_id) { unsigned int i, maxid; struct xen_platform_op op = {
drivers/xen/xen-acpi-processor.c +209 -16
288 lines not on this page · raw message
Signature · 1 line
2.37.3
Re: [PATCH 3/3] xen/acpi: upload power and performance related data from a PVH dom0
Quoted 15 lines · Roger Pau Monne
When running as a PVH dom0 the ACPI MADT is crafted by Xen in order to report the correct numbers of vCPUs that dom0 has, so the host MADT is not provided to dom0. This creates issues when parsing the power and performance related data from ACPI dynamic tables, as the ACPI Processor UIDs found on the dynamic code are likely to not match the ones crafted by Xen in the dom0 MADT.
Xen would rely on Linux having filled at least the power and performance related data of the vCPUs on the system, and would clone that information in order to setup the remaining pCPUs on the system if dom0 vCPUs < pCPUs. However when running as PVH dom0 it's likely that none of dom0 CPUs will have the power and performance data filled, and hence the Xen ACPI Processor driver needs to fetch that information by itself.
Quoted 6 lines
In order to do so correctly, introduce a new helper to fetch the
_CSTdata without taking into account the system capabilities from the CPUID output, as the capabilities reported to dom0 in CPUID might be different from the ones on the host.
Hi Roger,
First of all, thanks for doing the grunt work here to clear up the ACPI situation.
A bit of background, I'm trying to get an AMD APU (CPUID 0x17 (23)) to work properly under Xen. It works fine otherwise but something is amiss under Xen.
Just to make sure that the patch is working as intended, what I found when trying it out is that the first 8 CPUs have C-States, but 0, 2, 4, 6, 8, 10, 12, 14 have P-States, out of 16 CPUs. Xen tells Linux that there are 8 CPUs since it's running with nosmt.
Regards
- Josef
xen_acpi_processor: Max ACPI ID: 30xen_acpi_processor: Uploading Xen processor PM infoxen_acpi_processor: ACPI CPU0 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU0 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU1 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU2 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU2 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU3 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU4 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU4 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU5 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU6 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU6 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU7 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU0 w/ PBLK:0x0xen_acpi_processor: ACPI CPU0 w/ PST:coord_type = 254 domain = 0xen_acpi_processor: CPU with ACPI ID 1 is unavailablexen_acpi_processor: ACPI CPU2 w/ PBLK:0x0xen_acpi_processor: ACPI CPU2 w/ PST:coord_type = 254 domain = 1xen_acpi_processor: CPU with ACPI ID 3 is unavailablexen_acpi_processor: ACPI CPU4 w/ PBLK:0x0xen_acpi_processor: ACPI CPU4 w/ PST:coord_type = 254 domain = 2xen_acpi_processor: CPU with ACPI ID 5 is unavailablexen_acpi_processor: ACPI CPU6 w/ PBLK:0x0xen_acpi_processor: ACPI CPU6 w/ PST:coord_type = 254 domain = 3xen_acpi_processor: CPU with ACPI ID 7 is unavailablexen_acpi_processor: ACPI CPU8 w/ PBLK:0x0xen_acpi_processor: ACPI CPU8 w/ PST:coord_type = 254 domain = 4xen_acpi_processor: CPU with ACPI ID 9 is unavailablexen_acpi_processor: ACPI CPU10 w/ PBLK:0x0xen_acpi_processor: ACPI CPU10 w/ PST:coord_type = 254 domain = 5xen_acpi_processor: CPU with ACPI ID 11 is unavailablexen_acpi_processor: ACPI CPU12 w/ PBLK:0x0xen_acpi_processor: ACPI CPU12 w/ PST:coord_type = 254 domain = 6xen_acpi_processor: CPU with ACPI ID 13 is unavailablexen_acpi_processor: ACPI CPU14 w/ PBLK:0x0xen_acpi_processor: ACPI CPU14 w/ PST:coord_type = 254 domain = 7xen_acpi_processor: CPU with ACPI ID 15 is unavailablexen_acpi_processor: ACPI CPU8 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU10 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU12 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU14 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uS
As a bonus, here are the previous debug output on the same machine.
xen_acpi_processor: Max ACPI ID: 30xen_acpi_processor: Uploading Xen processor PM infoxen_acpi_processor: ACPI CPU0 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU0 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU1 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU2 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU2 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU3 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU4 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU4 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU5 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU6 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU6 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU7 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT 0x414 18 uS xen_acpi_processor: C3: ACPI IOPORT 0x415 350 uSxen_acpi_processor: ACPI CPU0 w/ PBLK:0x0xen_acpi_processor: ACPI CPU0 w/ PST:coord_type = 254 domain = 0xen_acpi_processor: ACPI CPU1 w/ PBLK:0x0xen_acpi_processor: ACPI CPU1 w/ PST:coord_type = 254 domain = 0xen_acpi_processor: ACPI CPU2 w/ PBLK:0x0xen_acpi_processor: ACPI CPU2 w/ PST:coord_type = 254 domain = 1xen_acpi_processor: ACPI CPU3 w/ PBLK:0x0xen_acpi_processor: ACPI CPU3 w/ PST:coord_type = 254 domain = 1xen_acpi_processor: ACPI CPU4 w/ PBLK:0x0xen_acpi_processor: ACPI CPU4 w/ PST:coord_type = 254 domain = 2xen_acpi_processor: ACPI CPU5 w/ PBLK:0x0xen_acpi_processor: ACPI CPU5 w/ PST:coord_type = 254 domain = 2xen_acpi_processor: ACPI CPU6 w/ PBLK:0x0xen_acpi_processor: ACPI CPU6 w/ PST:coord_type = 254 domain = 3xen_acpi_processor: ACPI CPU7 w/ PBLK:0x0xen_acpi_processor: ACPI CPU7 w/ PST:coord_type = 254 domain = 3xen_acpi_processor: ACPI CPU8 w/ PBLK:0x0xen_acpi_processor: ACPI CPU8 w/ PST:coord_type = 254 domain = 4xen_acpi_processor: ACPI CPU9 w/ PBLK:0x0xen_acpi_processor: ACPI CPU9 w/ PST:coord_type = 254 domain = 4xen_acpi_processor: ACPI CPU10 w/ PBLK:0x0xen_acpi_processor: ACPI CPU10 w/ PST:coord_type = 254 domain = 5xen_acpi_processor: ACPI CPU11 w/ PBLK:0x0xen_acpi_processor: ACPI CPU11 w/ PST:coord_type = 254 domain = 5xen_acpi_processor: ACPI CPU12 w/ PBLK:0x0xen_acpi_processor: ACPI CPU12 w/ PST:coord_type = 254 domain = 6xen_acpi_processor: ACPI CPU13 w/ PBLK:0x0xen_acpi_processor: ACPI CPU13 w/ PST:coord_type = 254 domain = 6xen_acpi_processor: ACPI CPU14 w/ PBLK:0x0xen_acpi_processor: ACPI CPU14 w/ PST:coord_type = 254 domain = 7xen_acpi_processor: ACPI CPU15 w/ PBLK:0x0xen_acpi_processor: ACPI CPU15 w/ PST:coord_type = 254 domain = 7xen_acpi_processor: ACPI CPU8 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU10 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU12 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU14 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uS
Re: [PATCH 3/3] xen/acpi: upload power and performance related data from a PVH dom0
Quoted 24 lines · Josef Johansson
Quoted 15 lines · Roger Pau Monne
When running as a PVH dom0 the ACPI MADT is crafted by Xen in order to report the correct numbers of vCPUs that dom0 has, so the host MADT is not provided to dom0. This creates issues when parsing the power and performance related data from ACPI dynamic tables, as the ACPI Processor UIDs found on the dynamic code are likely to not match the ones crafted by Xen in the dom0 MADT.
Xen would rely on Linux having filled at least the power and performance related data of the vCPUs on the system, and would clone that information in order to setup the remaining pCPUs on the system if dom0 vCPUs < pCPUs. However when running as PVH dom0 it's likely that none of dom0 CPUs will have the power and performance data filled, and hence the Xen ACPI Processor driver needs to fetch that information by itself.
Quoted 6 lines
In order to do so correctly, introduce a new helper to fetch the
_CSTdata without taking into account the system capabilities from the CPUID output, as the capabilities reported to dom0 in CPUID might be different from the ones on the host.
Quoted 8 lines
Hi Roger,
First of all, thanks for doing the grunt work here to clear up the ACPI situation.
A bit of background, I'm trying to get an AMD APU (CPUID
0x17(23)) to work properly
under Xen. It works fine otherwise but something is amiss under Xen.
Hello,
Sorry for the delay, I've been on paternity leave and just caching up on emails.
Quoted 55 lines
Just to make sure that the patch is working as intended, what I found when trying it out
is that the first 8 CPUs have C-States, but 0, 2, 4, 6, 8, 10, 12, 14 have P-States, out of
16 CPUs. Xen tells Linux that there are 8 CPUs since it's running with nosmt.Regards
- Josef
xen_acpi_processor: Max ACPI ID: 30xen_acpi_processor: Uploading Xen processor PM infoxen_acpi_processor: ACPI CPU0 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU0 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU1 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU2 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU2 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU3 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU4 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU4 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU5 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU6 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU6 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS
Quoted 8 lines
xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uS
xen_acpi_processor: ACPI CPU7 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU0 w/ PBLK:0x0xen_acpi_processor: ACPI CPU0 w/ PST:coord_type = 254 domain = 0xen_acpi_processor: CPU with ACPI ID 1 is unavailable
Hm, that's weird, do you think you could check why it reports the CPU is unavailable?
Overall I don't like the situation of the ACPI handling when running as dom0. It's fragile to rely on the data for dom0 CPUs to be filled by the system (by adding some band aids here and there so that the PV vCPUs are matched against the MADT objects) and then cloning the data for any physical CPU exceeding the number of dom0 virtual CPUs.
IMO it would be much better to just do the handling of ACPI processor objects in a Xen specific driver (preventing the native driver from attaching) in order to fetch the data and upload it to Xen. This is what I've attempted to do on FreeBSD, and resulted in a cleaner implementation:
https://cgit.freebsd.org/src/tree/sys/dev/xen/cpu/xen_acpi_cpu.c
I however don't have time to do this right now for Linux.
Quoted 38 lines
xen_acpi_processor: ACPI CPU2 w/ PBLK:0x0xen_acpi_processor: ACPI CPU2 w/ PST:coord_type = 254 domain = 1xen_acpi_processor: CPU with ACPI ID 3 is unavailablexen_acpi_processor: ACPI CPU4 w/ PBLK:0x0xen_acpi_processor: ACPI CPU4 w/ PST:coord_type = 254 domain = 2xen_acpi_processor: CPU with ACPI ID 5 is unavailablexen_acpi_processor: ACPI CPU6 w/ PBLK:0x0xen_acpi_processor: ACPI CPU6 w/ PST:coord_type = 254 domain = 3xen_acpi_processor: CPU with ACPI ID 7 is unavailablexen_acpi_processor: ACPI CPU8 w/ PBLK:0x0xen_acpi_processor: ACPI CPU8 w/ PST:coord_type = 254 domain = 4xen_acpi_processor: CPU with ACPI ID 9 is unavailablexen_acpi_processor: ACPI CPU10 w/ PBLK:0x0xen_acpi_processor: ACPI CPU10 w/ PST:coord_type = 254 domain = 5xen_acpi_processor: CPU with ACPI ID 11 is unavailablexen_acpi_processor: ACPI CPU12 w/ PBLK:0x0xen_acpi_processor: ACPI CPU12 w/ PST:coord_type = 254 domain = 6xen_acpi_processor: CPU with ACPI ID 13 is unavailablexen_acpi_processor: ACPI CPU14 w/ PBLK:0x0xen_acpi_processor: ACPI CPU14 w/ PST:coord_type = 254 domain = 7xen_acpi_processor: CPU with ACPI ID 15 is unavailablexen_acpi_processor: ACPI CPU8 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU10 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU12 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU14 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uS
Quoted 1 line
As a bonus, here are the previous debug output on the same machine.
I think the output below is with dom0 running as plain PV rather than PVH?
Thanks, Roger.
Re: [PATCH 3/3] xen/acpi: upload power and performance related data from a PVH dom0
Quoted 28 lines · Roger Pau Monné
Quoted 27 lines · Josef Johansson
Quoted 15 lines · Roger Pau Monne
When running as a PVH dom0 the ACPI MADT is crafted by Xen in order to report the correct numbers of vCPUs that dom0 has, so the host MADT is not provided to dom0. This creates issues when parsing the power and performance related data from ACPI dynamic tables, as the ACPI Processor UIDs found on the dynamic code are likely to not match the ones crafted by Xen in the dom0 MADT.
Xen would rely on Linux having filled at least the power and performance related data of the vCPUs on the system, and would clone that information in order to setup the remaining pCPUs on the system if dom0 vCPUs < pCPUs. However when running as PVH dom0 it's likely that none of dom0 CPUs will have the power and performance data filled, and hence the Xen ACPI Processor driver needs to fetch that information by itself.
Quoted 6 lines
In order to do so correctly, introduce a new helper to fetch the
_CSTdata without taking into account the system capabilities from the CPUID output, as the capabilities reported to dom0 in CPUID might be different from the ones on the host.Hi Roger,
First of all, thanks for doing the grunt work here to clear up the ACPI situation.
Quoted 7 lines
Quoted 3 lines
A bit of background, I'm trying to get an AMD APU (CPUID
0x17(23)) to work properly
under Xen. It works fine otherwise but something is amiss under Xen.Hello,
Sorry for the delay, I've been on paternity leave and just caching up on emails.
Hi Roger,
Congratulations! I hope you had time to really connect. It's the most important thing we can do here in life.
I came into this to understand each and every error in my boot-log, it turns out that the latest kernel+xen+firmware fixes suspend/resume for me, thus is this not related. But as I pointed out, the output does not make any sense (nor yours nor the upstream). I should check the debug output with suspend working fine now to see if there are any changes, that would be quite interesting.
Also, I should mention that your patch broke some things on my system and made it unstable. I don't remember exactly and I know you said that this is more of a PoC. Just a heads up.
Quoted 63 lines
Quoted 55 lines
Just to make sure that the patch is working as intended, what I found when trying it out
is that the first 8 CPUs have C-States, but 0, 2, 4, 6, 8, 10, 12, 14 have P-States, out of
16 CPUs. Xen tells Linux that there are 8 CPUs since it's running with nosmt.Regards
- Josef
xen_acpi_processor: Max ACPI ID: 30xen_acpi_processor: Uploading Xen processor PM infoxen_acpi_processor: ACPI CPU0 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU0 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU1 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU2 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU2 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU3 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU4 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU4 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU5 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU6 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU6 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uSQuoted 8 lines
xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uS
xen_acpi_processor: ACPI CPU7 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU0 w/ PBLK:0x0xen_acpi_processor: ACPI CPU0 w/ PST:coord_type = 254 domain = 0xen_acpi_processor: CPU with ACPI ID 1 is unavailable
Quoted 2 lines
Hm, that's weird, do you think you could check why it reports the CPU is unavailable?
If you would give me a hint at how I could check?
Right now my guess is that C state and P state is not in sync, thus P state are for every other CPU and C state is for the first 8. AFAIK AMD only have performance-cores (unlike Intel).
Quoted 7 lines
Overall I don't like the situation of the ACPI handling when running as dom0. It's fragile to rely on the data for dom0 CPUs to be filled by the system (by adding some band aids here and there so that the PV vCPUs are matched against the MADT objects) and then cloning the data for any physical CPU exceeding the number of dom0 virtual CPUs.
That's my understanding from earlier implementation as well, nobody actually like it, But the current solution is something working in a bad environment.
Quoted 10 lines
IMO it would be much better to just do the handling of ACPI processor objects in a Xen specific driver (preventing the native driver from attaching) in order to fetch the data and upload it to Xen. This is what I've attempted to do on FreeBSD, and resulted in a cleaner implementation:
<link>
I however don't have time to do this right now for Linux.
Maybe I can take a stab, I very much like the climate of the kernel but everything seem so scary :) I've been trying to understand things better, how they're all connected.
Quoted 39 lines
Quoted 39 lines
xen_acpi_processor: ACPI CPU2 w/ PBLK:0x0xen_acpi_processor: ACPI CPU2 w/ PST:coord_type = 254 domain = 1xen_acpi_processor: CPU with ACPI ID 3 is unavailablexen_acpi_processor: ACPI CPU4 w/ PBLK:0x0xen_acpi_processor: ACPI CPU4 w/ PST:coord_type = 254 domain = 2xen_acpi_processor: CPU with ACPI ID 5 is unavailablexen_acpi_processor: ACPI CPU6 w/ PBLK:0x0xen_acpi_processor: ACPI CPU6 w/ PST:coord_type = 254 domain = 3xen_acpi_processor: CPU with ACPI ID 7 is unavailablexen_acpi_processor: ACPI CPU8 w/ PBLK:0x0xen_acpi_processor: ACPI CPU8 w/ PST:coord_type = 254 domain = 4xen_acpi_processor: CPU with ACPI ID 9 is unavailablexen_acpi_processor: ACPI CPU10 w/ PBLK:0x0xen_acpi_processor: ACPI CPU10 w/ PST:coord_type = 254 domain = 5xen_acpi_processor: CPU with ACPI ID 11 is unavailablexen_acpi_processor: ACPI CPU12 w/ PBLK:0x0xen_acpi_processor: ACPI CPU12 w/ PST:coord_type = 254 domain = 6xen_acpi_processor: CPU with ACPI ID 13 is unavailablexen_acpi_processor: ACPI CPU14 w/ PBLK:0x0xen_acpi_processor: ACPI CPU14 w/ PST:coord_type = 254 domain = 7xen_acpi_processor: CPU with ACPI ID 15 is unavailablexen_acpi_processor: ACPI CPU8 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU10 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU12 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU14 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uS
Quoted 3 lines
Quoted 1 line
As a bonus, here are the previous debug output on the same machine.
I think the output below is with dom0 running as plain PV rather than PVH?
This is the upstream ACPI implementation vs yours. What would plain PV vs PVH be in dom0?
Regards
- Josef
Quoted 1 line
Thanks, Roger.
Re: [PATCH 3/3] xen/acpi: upload power and performance related data from a PVH dom0
Quoted 51 lines · Josef Johansson
Quoted 28 lines · Roger Pau Monné
Quoted 27 lines · Josef Johansson
Quoted 15 lines · Roger Pau Monne
When running as a PVH dom0 the ACPI MADT is crafted by Xen in order to report the correct numbers of vCPUs that dom0 has, so the host MADT is not provided to dom0. This creates issues when parsing the power and performance related data from ACPI dynamic tables, as the ACPI Processor UIDs found on the dynamic code are likely to not match the ones crafted by Xen in the dom0 MADT.
Xen would rely on Linux having filled at least the power and performance related data of the vCPUs on the system, and would clone that information in order to setup the remaining pCPUs on the system if dom0 vCPUs < pCPUs. However when running as PVH dom0 it's likely that none of dom0 CPUs will have the power and performance data filled, and hence the Xen ACPI Processor driver needs to fetch that information by itself.
Quoted 6 lines
In order to do so correctly, introduce a new helper to fetch the
_CSTdata without taking into account the system capabilities from the CPUID output, as the capabilities reported to dom0 in CPUID might be different from the ones on the host.Hi Roger,
First of all, thanks for doing the grunt work here to clear up the ACPI situation.
Quoted 7 lines
Quoted 3 lines
A bit of background, I'm trying to get an AMD APU (CPUID
0x17(23)) to work properly
under Xen. It works fine otherwise but something is amiss under Xen.Hello,
Sorry for the delay, I've been on paternity leave and just caching up on emails.
Hi Roger,
Congratulations! I hope you had time to really connect. It's the most important thing we can do here in life.
I came into this to understand each and every error in my boot-log, it turns out that the latest
kernel+xen+firmware fixes suspend/resume for me, thus is this not related. But as I pointed out,
the output does not make any sense (nor yours nor the upstream). I should check the debug
output with suspend working fine now to see if there are any changes, that would be quite
interesting.
Quoted 5 lines
Also, I should mention that your patch broke some things on my system and made it
unstable. I don't remember exactly and I know you said that this is more of a PoC. Just a
heads up.
Right, I don't plan to send the PVH part just now, and instead I'm focusing in the first patch that should fix _PDC evaluation for PV dom0. I will Cc you on the last version so you can give it a try and assert is not regressing stuff for you.
Quoted 63 lines
Quoted 63 lines
Quoted 63 lines
Just to make sure that the patch is working as intended, what I found when trying it out
is that the first 8 CPUs have C-States, but 0, 2, 4, 6, 8, 10, 12, 14 have P-States, out of
16 CPUs. Xen tells Linux that there are 8 CPUs since it's running with nosmt.Regards
- Josef
xen_acpi_processor: Max ACPI ID: 30xen_acpi_processor: Uploading Xen processor PM infoxen_acpi_processor: ACPI CPU0 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU0 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU1 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU2 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU2 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU3 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU4 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU4 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU5 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU6 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU6 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU7 - C-states uploaded. xen_acpi_processor: C1: ACPI HLT 1 uS xen_acpi_processor: C2: ACPI IOPORT0x41418 uS xen_acpi_processor: C3: ACPI IOPORT0x415350 uSxen_acpi_processor: ACPI CPU0 w/ PBLK:0x0xen_acpi_processor: ACPI CPU0 w/ PST:coord_type = 254 domain = 0xen_acpi_processor: CPU with ACPI ID 1 is unavailable
Quoted 3 lines
Quoted 2 lines
Hm, that's weird, do you think you could check why it reports the CPU is unavailable?
If you would give me a hint at how I could check?
It likely requires you to add printk statements to the kernel in order to figure out which conditional fails when running as a PVH dom0.
Quoted 4 lines
Right now my guess is that C state and P state is not in sync, thus P state are for every other
CPU and C state is for the first 8. AFAIK AMD only have performance-cores (unlike Intel).
Linux thinking the CPU is not online is more likely to be due to the ACPI ID differences when running as a PVH dom0. Anyway, I will try to revisit this and figure out what's wrong.
Quoted 65 lines
Quoted 7 lines
Overall I don't like the situation of the ACPI handling when running as dom0. It's fragile to rely on the data for dom0 CPUs to be filled by the system (by adding some band aids here and there so that the PV vCPUs are matched against the MADT objects) and then cloning the data for any physical CPU exceeding the number of dom0 virtual CPUs.
That's my understanding from earlier implementation as well, nobody actually like it,
But the current solution is something working in a bad environment.Quoted 10 lines
IMO it would be much better to just do the handling of ACPI processor objects in a Xen specific driver (preventing the native driver from attaching) in order to fetch the data and upload it to Xen. This is what I've attempted to do on FreeBSD, and resulted in a cleaner implementation:
<link>
I however don't have time to do this right now for Linux.
Maybe I can take a stab, I very much like the climate of the kernel but everything
seem so scary :) I've been trying to understand things better, how they're all
connected.Quoted 39 lines
Quoted 39 lines
xen_acpi_processor: ACPI CPU2 w/ PBLK:0x0xen_acpi_processor: ACPI CPU2 w/ PST:coord_type = 254 domain = 1xen_acpi_processor: CPU with ACPI ID 3 is unavailablexen_acpi_processor: ACPI CPU4 w/ PBLK:0x0xen_acpi_processor: ACPI CPU4 w/ PST:coord_type = 254 domain = 2xen_acpi_processor: CPU with ACPI ID 5 is unavailablexen_acpi_processor: ACPI CPU6 w/ PBLK:0x0xen_acpi_processor: ACPI CPU6 w/ PST:coord_type = 254 domain = 3xen_acpi_processor: CPU with ACPI ID 7 is unavailablexen_acpi_processor: ACPI CPU8 w/ PBLK:0x0xen_acpi_processor: ACPI CPU8 w/ PST:coord_type = 254 domain = 4xen_acpi_processor: CPU with ACPI ID 9 is unavailablexen_acpi_processor: ACPI CPU10 w/ PBLK:0x0xen_acpi_processor: ACPI CPU10 w/ PST:coord_type = 254 domain = 5xen_acpi_processor: CPU with ACPI ID 11 is unavailablexen_acpi_processor: ACPI CPU12 w/ PBLK:0x0xen_acpi_processor: ACPI CPU12 w/ PST:coord_type = 254 domain = 6xen_acpi_processor: CPU with ACPI ID 13 is unavailablexen_acpi_processor: ACPI CPU14 w/ PBLK:0x0xen_acpi_processor: ACPI CPU14 w/ PST:coord_type = 254 domain = 7xen_acpi_processor: CPU with ACPI ID 15 is unavailablexen_acpi_processor: ACPI CPU8 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU10 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU12 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uSxen_acpi_processor: ACPI CPU14 - P-states uploaded. xen_acpi_processor: *P0: 1700 MHz, 2071 mW, 0 uS xen_acpi_processor: P1: 1600 MHz, 1520 mW, 0 uS xen_acpi_processor: P2: 1400 MHz, 1277 mW, 0 uS
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
As a bonus, here are the previous debug output on the same machine.
I think the output below is with dom0 running as plain PV rather than PVH?
This is the upstream ACPI implementation vs yours. What would plain PV vs PVH be in dom0?
But that's always with Linux running as a dom0, or just running bare metal?
Thanks, Roger.
Quoted 15 lines · Roger Pau Monne
Hello,
This series aims to fix some shortcomings with the handling of ACPI Processors objects when running as a Xen dom0.
First two patches fix the execution of the
_PDCmethods for all CPUs on the system and not just the ones available to dom0, while also making sure that the_PDCcapabilities reported to ACPI match what the perfrmance and power drivers in Xen can handle.Final patch fixes the Xen ACPI Processor driver to also work when used in a PVH dom0, that has a custom build ACPI MADT table and mismatched Processor UIDs between the MADT and the Processor objects in the dynamic AML.
Quoted 8 lines
I don't really like the current implementation of the Xen ACPI Processor driver, it IMO relies too much on data being fetched by generic kernel code. For one the generic fetcher functions can take CPUID data into account in order to sanitize what's found in ACPI, but capabilities reported to dom0 can be different from the native ones. Also the Xen ACPI Processor code relies on cloning the data from CPUs in order to fill for the pCPUs > vCPUs, but this is wrong when running on heterogeneous systems.
Yes, these are problems (and as per reading the description of the last patch you even extend this "cloning" of data), but ...
Quoted 8 lines
Last patch introduces some helpers to Xen ACPI Processor that should allow fetching all the required data, for each ACPI Processor object on the dynamic tables. It might be helpful to explore disabling any Processor object handling done by generic drivers and just fetch all the data from the Xen Processor driver itself for every Processor object on the namespace. Likewise it might be better to just execute
_PDCfrom that same Xen ACPI Processor driver instead of polluting the generic ACPI Processor driver.
... cloning functions living elsewhere also has the genuine problem of them then needing to be kept in sync without there being any trigger to know when an original function was changed in some way.
Jan
Quoted 37 lines · Jan Beulich
Quoted 15 lines · Roger Pau Monne
Hello,
This series aims to fix some shortcomings with the handling of ACPI Processors objects when running as a Xen dom0.
First two patches fix the execution of the
_PDCmethods for all CPUs on the system and not just the ones available to dom0, while also making sure that the_PDCcapabilities reported to ACPI match what the perfrmance and power drivers in Xen can handle.Final patch fixes the Xen ACPI Processor driver to also work when used in a PVH dom0, that has a custom build ACPI MADT table and mismatched Processor UIDs between the MADT and the Processor objects in the dynamic AML.
Quoted 8 lines
I don't really like the current implementation of the Xen ACPI Processor driver, it IMO relies too much on data being fetched by generic kernel code. For one the generic fetcher functions can take CPUID data into account in order to sanitize what's found in ACPI, but capabilities reported to dom0 can be different from the native ones. Also the Xen ACPI Processor code relies on cloning the data from CPUs in order to fill for the pCPUs > vCPUs, but this is wrong when running on heterogeneous systems.
Yes, these are problems (and as per reading the description of the last patch you even extend this "cloning" of data), but ...
Quoted 8 lines
Last patch introduces some helpers to Xen ACPI Processor that should allow fetching all the required data, for each ACPI Processor object on the dynamic tables. It might be helpful to explore disabling any Processor object handling done by generic drivers and just fetch all the data from the Xen Processor driver itself for every Processor object on the namespace. Likewise it might be better to just execute
_PDCfrom that same Xen ACPI Processor driver instead of polluting the generic ACPI Processor driver.
Quoted 3 lines
... cloning functions living elsewhere also has the genuine problem of them then needing to be kept in sync without there being any trigger to know when an original function was changed in some way.
Well, yes, but using generic functions also has the risk of them being modified to take into account CPUID data for example and then the result would no longer be suitable for Xen's usage without us noticing.
Also has the downside of parsing the data into Linux structures which then need to be translated into Xen format. It might be more straight forward to just evaluate the required ACPI methods and parse the ACPI data from the Xen ACPI Processor driver into the format used by Xen and upload that to the hypervisor.
I realize however this is a big change, and would mean almost a rewrite from scratch of the Xen ACPI Processor driver. I wouldn't want to start that task without having agreement that this is the correct way forward.
Roger.