qemu/docs/specs
Anthony Harivel 0418f90809 Add support for RAPL MSRs in KVM/Qemu
Starting with the "Sandy Bridge" generation, Intel CPUs provide a RAPL
interface (Running Average Power Limit) for advertising the accumulated
energy consumption of various power domains (e.g. CPU packages, DRAM,
etc.).

The consumption is reported via MSRs (model specific registers) like
MSR_PKG_ENERGY_STATUS for the CPU package power domain. These MSRs are
64 bits registers that represent the accumulated energy consumption in
micro Joules. They are updated by microcode every ~1ms.

For now, KVM always returns 0 when the guest requests the value of
these MSRs. Use the KVM MSR filtering mechanism to allow QEMU handle
these MSRs dynamically in userspace.

To limit the amount of system calls for every MSR call, create a new
thread in QEMU that updates the "virtual" MSR values asynchronously.

Each vCPU has its own vMSR to reflect the independence of vCPUs. The
thread updates the vMSR values with the ratio of energy consumed of
the whole physical CPU package the vCPU thread runs on and the
thread's utime and stime values.

All other non-vCPU threads are also taken into account. Their energy
consumption is evenly distributed among all vCPUs threads running on
the same physical CPU package.

To overcome the problem that reading the RAPL MSR requires priviliged
access, a socket communication between QEMU and the qemu-vmsr-helper is
mandatory. You can specified the socket path in the parameter.

This feature is activated with -accel kvm,rapl=true,path=/path/sock.sock

Actual limitation:
- Works only on Intel host CPU because AMD CPUs are using different MSR
  adresses.

- Only the Package Power-Plane (MSR_PKG_ENERGY_STATUS) is reported at
  the moment.

Signed-off-by: Anthony Harivel <aharivel@redhat.com>
Link: https://lore.kernel.org/r/20240522153453.1230389-4-aharivel@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-07-22 19:19:37 +02:00
..
acpi_cpu_hotplug.rst docs/specs/acpu_cpu_hotplug: Convert to rST 2021-08-26 17:01:59 +01:00
acpi_erst.rst Fix some typos in documentation (most of them found by codespell) 2022-08-12 11:20:42 +01:00
acpi_hest_ghes.rst docs: APEI GHES generation and CPER record description 2020-05-14 15:03:09 +01:00
acpi_hw_reduced_hotplug.rst hw/arm/virt: Add nvdimm hotplug support 2020-05-04 10:25:02 -04:00
acpi_mem_hotplug.rst docs/specs/acpi_mem_hotplug: Convert to rST 2021-08-26 17:01:59 +01:00
acpi_nvdimm.rst docs/specs/acpi_nvdimm: Convert to rST 2021-08-26 17:02:00 +01:00
acpi_pci_hotplug.rst docs/specs/acpi_pci_hotplug: Convert to rST 2021-08-26 17:02:00 +01:00
edu.rst docs/specs/edu: Convert to rST 2023-11-02 12:52:06 +00:00
fsi.rst hw/fsi: Added FSI documentation 2024-02-01 08:33:18 +01:00
fw_cfg.rst Convert fw_cfg.rst to reStructuredText syntax 2022-07-01 12:13:08 +02:00
index.rst Add support for RAPL MSRs in KVM/Qemu 2024-07-22 19:19:37 +02:00
ivshmem-spec.rst docs/specs/ivshmem-spec: Convert to rST 2023-11-02 12:52:06 +00:00
pci-ids.rst docs/specs/ivshmem-spec: Convert to rST 2023-11-02 12:52:06 +00:00
pci-serial.rst docs/specs: Convert pci-serial.txt to rst 2023-04-24 22:56:55 -04:00
pci-testdev.rst docs/specs: Convert pci-testdev.txt to rst 2023-04-24 22:56:55 -04:00
ppc-spapr-hcalls.rst docs: Clarifications and formatting changes in ppc docs. 2022-01-12 11:28:26 +01:00
ppc-spapr-hotplug.rst docs: Rename ppc-spapr-hotplug.txt to ppc-spapr-hotplug.rst. 2022-01-18 12:56:30 +01:00
ppc-spapr-numa.rst docs: Fix some typos (found by codespell) 2020-11-18 09:29:41 +01:00
ppc-spapr-uv-hcalls.rst Rename ppc-spapr-uv-hcalls.txt to ppc-spapr-uv-hcalls.rst. 2022-01-18 12:56:30 +01:00
ppc-spapr-xive.rst docs/: fix some comment spelling errors 2020-09-17 20:37:13 +02:00
ppc-xive.rst global: Squash 'the the' 2019-11-06 17:19:40 +01:00
pvpanic.rst Revert "docs/specs/pvpanic: mark shutdown event as not implemented" 2024-07-01 17:16:04 -04:00
rapl-msr.rst Add support for RAPL MSRs in KVM/Qemu 2024-07-22 19:19:37 +02:00
rocker.txt Fix some typos found by codespell 2016-05-18 15:04:27 +03:00
sev-guest-firmware.rst docs: Add spec of OVMF GUIDed table for SEV guests 2022-03-04 11:27:49 +01:00
standard-vga.rst docs/specs/standard-vga: Convert to rST 2023-11-02 12:52:06 +00:00
tpm.rst docs, tests: do not specify scsi=off 2024-06-05 11:00:56 +02:00
virt-ctlr.rst docs/specs/virt-ctlr: Convert to rST 2023-11-02 12:52:06 +00:00
vmcoreinfo.rst docs/specs/vmcoreinfo: Convert to rST 2023-11-02 12:52:06 +00:00
vmgenid.rst docs/specs/vmgenid: Convert to rST 2023-11-02 13:36:45 +00:00
vmw_pvscsi-spec.rst docs/specs/vmw_pvscsi-spec: Convert to rST 2023-11-02 12:52:06 +00:00