Browse Source
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>pull/273/head
committed by
Paolo Bonzini
9 changed files with 1098 additions and 1 deletions
@ -0,0 +1,155 @@ |
|||
================ |
|||
RAPL MSR support |
|||
================ |
|||
|
|||
The RAPL interface (Running Average Power Limit) is 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. |
|||
|
|||
Thanks to the MSR Filtering patch [#a]_ not all MSRs are handled by KVM. Some |
|||
of them can now be handled by the userspace (QEMU). It uses a mechanism called |
|||
"MSR filtering" where a list of MSRs is given at init time of a VM to KVM so |
|||
that a callback is put in place. The design of this patch uses only this |
|||
mechanism for handling the MSRs between guest/host. |
|||
|
|||
At the moment the following MSRs are involved: |
|||
|
|||
.. code:: C |
|||
|
|||
#define MSR_RAPL_POWER_UNIT 0x00000606 |
|||
#define MSR_PKG_POWER_LIMIT 0x00000610 |
|||
#define MSR_PKG_ENERGY_STATUS 0x00000611 |
|||
#define MSR_PKG_POWER_INFO 0x00000614 |
|||
|
|||
The ``*_POWER_UNIT``, ``*_POWER_LIMIT``, ``*_POWER INFO`` are part of the RAPL |
|||
spec and specify the power limit of the package, provide range of parameter(min |
|||
power, max power,..) and also the information of the multiplier for the energy |
|||
counter to calculate the power. Those MSRs are populated once at the beginning |
|||
by reading the host CPU MSRs and are given back to the guest 1:1 when |
|||
requested. |
|||
|
|||
The MSR_PKG_ENERGY_STATUS is a counter; it represents the total amount of |
|||
energy consumed since the last time the register was cleared. If you multiply |
|||
it with the UNIT provided above you'll get the power in micro-joules. This |
|||
counter is always increasing and it increases more or less faster depending on |
|||
the consumption of the package. This counter is supposed to overflow at some |
|||
point. |
|||
|
|||
Each core belonging to the same Package reading the MSR_PKG_ENERGY_STATUS (i.e |
|||
"rdmsr 0x611") will retrieve the same value. The value represents the energy |
|||
for the whole package. Whatever Core reading it will get the same value and a |
|||
core that belongs to PKG-0 will not be able to get the value of PKG-1 and |
|||
vice-versa. |
|||
|
|||
High level implementation |
|||
------------------------- |
|||
|
|||
In order to update the value of the virtual MSR, a QEMU thread is created. |
|||
The thread is basically just an infinity loop that does: |
|||
|
|||
1. Snapshot of the time metrics of all QEMU threads (Time spent scheduled in |
|||
Userspace and System) |
|||
|
|||
2. Snapshot of the actual MSR_PKG_ENERGY_STATUS counter of all packages where |
|||
the QEMU threads are running on. |
|||
|
|||
3. Sleep for 1 second - During this pause the vcpu and other non-vcpu threads |
|||
will do what they have to do and so the energy counter will increase. |
|||
|
|||
4. Repeat 2. and 3. and calculate the delta of every metrics representing the |
|||
time spent scheduled for each QEMU thread *and* the energy spent by the |
|||
packages during the pause. |
|||
|
|||
5. Filter the vcpu threads and the non-vcpu threads. |
|||
|
|||
6. Retrieve the topology of the Virtual Machine. This helps identify which |
|||
vCPU is running on which virtual package. |
|||
|
|||
7. The total energy spent by the non-vcpu threads is divided by the number |
|||
of vcpu threads so that each vcpu thread will get an equal part of the |
|||
energy spent by the QEMU workers. |
|||
|
|||
8. Calculate the ratio of energy spent per vcpu threads. |
|||
|
|||
9. Calculate the energy for each virtual package. |
|||
|
|||
10. The virtual MSRs are updated for each virtual package. Each vCPU that |
|||
belongs to the same package will return the same value when accessing the |
|||
the MSR. |
|||
|
|||
11. Loop back to 1. |
|||
|
|||
Ratio calculation |
|||
----------------- |
|||
|
|||
In Linux, a process has an execution time associated with it. The scheduler is |
|||
dividing the time in clock ticks. The number of clock ticks per second can be |
|||
found by the sysconf system call. A typical value of clock ticks per second is |
|||
100. So a core can run a process at the maximum of 100 ticks per second. If a |
|||
package has 4 cores, 400 ticks maximum can be scheduled on all the cores |
|||
of the package for a period of 1 second. |
|||
|
|||
The /proc/[pid]/stat [#b]_ is a sysfs file that can give the executed time of a |
|||
process with the [pid] as the process ID. It gives the amount of ticks the |
|||
process has been scheduled in userspace (utime) and kernel space (stime). |
|||
|
|||
By reading those metrics for a thread, one can calculate the ratio of time the |
|||
package has spent executing the thread. |
|||
|
|||
Example: |
|||
|
|||
A 4 cores package can schedule a maximum of 400 ticks per second with 100 ticks |
|||
per second per core. If a thread was scheduled for 100 ticks between a second |
|||
on this package, that means my thread has been scheduled for 1/4 of the whole |
|||
package. With that, the calculation of the energy spent by the thread on this |
|||
package during this whole second is 1/4 of the total energy spent by the |
|||
package. |
|||
|
|||
Usage |
|||
----- |
|||
|
|||
Currently this feature is only working on an Intel CPU that has the RAPL driver |
|||
mounted and available in the sysfs. if not, QEMU fails at start-up. |
|||
|
|||
This feature is activated with -accel |
|||
kvm,rapl=true,rapl-helper-socket=/path/sock.sock |
|||
|
|||
It is important that the socket path is the same as the one |
|||
:program:`qemu-vmsr-helper` is listening to. |
|||
|
|||
qemu-vmsr-helper |
|||
---------------- |
|||
|
|||
The qemu-vmsr-helper is working very much like the qemu-pr-helper. Instead of |
|||
making persistent reservation, qemu-vmsr-helper is here to overcome the |
|||
CVE-2020-8694 which remove user access to the rapl msr attributes. |
|||
|
|||
A socket communication is established between QEMU processes that has the RAPL |
|||
MSR support activated and the qemu-vmsr-helper. A systemd service and socket |
|||
activation is provided in contrib/systemd/qemu-vmsr-helper.(service/socket). |
|||
|
|||
The systemd socket uses 600, like contrib/systemd/qemu-pr-helper.socket. The |
|||
socket can be passed via SCM_RIGHTS by libvirt, or its permissions can be |
|||
changed (e.g. 660 and root:kvm for a Debian system for example). Libvirt could |
|||
also start a separate helper if needed. All in all, the policy is left to the |
|||
user. |
|||
|
|||
See the qemu-pr-helper documentation or manpage for further details. |
|||
|
|||
Current Limitations |
|||
------------------- |
|||
|
|||
- Works only on Intel host CPUs because AMD CPUs are using different MSR |
|||
addresses. |
|||
|
|||
- Only the Package Power-Plane (MSR_PKG_ENERGY_STATUS) is reported at the |
|||
moment. |
|||
|
|||
References |
|||
---------- |
|||
|
|||
.. [#a] https://patchwork.kernel.org/project/kvm/patch/20200916202951.23760-7-graf@amazon.com/ |
|||
.. [#b] https://man7.org/linux/man-pages/man5/proc.5.html |
|||
@ -0,0 +1,345 @@ |
|||
/*
|
|||
* QEMU KVM support -- x86 virtual RAPL msr |
|||
* |
|||
* Copyright 2024 Red Hat, Inc. 2024 |
|||
* |
|||
* Author: |
|||
* Anthony Harivel <aharivel@redhat.com> |
|||
* |
|||
* This work is licensed under the terms of the GNU GPL, version 2 or later. |
|||
* See the COPYING file in the top-level directory. |
|||
* |
|||
*/ |
|||
|
|||
#include "qemu/osdep.h" |
|||
#include "qemu/error-report.h" |
|||
#include "vmsr_energy.h" |
|||
#include "io/channel.h" |
|||
#include "io/channel-socket.h" |
|||
#include "hw/boards.h" |
|||
#include "cpu.h" |
|||
#include "host-cpu.h" |
|||
|
|||
char *vmsr_compute_default_paths(void) |
|||
{ |
|||
g_autofree char *state = qemu_get_local_state_dir(); |
|||
|
|||
return g_build_filename(state, "run", "qemu-vmsr-helper.sock", NULL); |
|||
} |
|||
|
|||
bool is_host_cpu_intel(void) |
|||
{ |
|||
int family, model, stepping; |
|||
char vendor[CPUID_VENDOR_SZ + 1]; |
|||
|
|||
host_cpu_vendor_fms(vendor, &family, &model, &stepping); |
|||
|
|||
return strcmp(vendor, CPUID_VENDOR_INTEL); |
|||
} |
|||
|
|||
int is_rapl_enabled(void) |
|||
{ |
|||
const char *path = "/sys/class/powercap/intel-rapl/enabled"; |
|||
FILE *file = fopen(path, "r"); |
|||
int value = 0; |
|||
|
|||
if (file != NULL) { |
|||
if (fscanf(file, "%d", &value) != 1) { |
|||
error_report("INTEL RAPL not enabled"); |
|||
} |
|||
fclose(file); |
|||
} else { |
|||
error_report("Error opening %s", path); |
|||
} |
|||
|
|||
return value; |
|||
} |
|||
|
|||
QIOChannelSocket *vmsr_open_socket(const char *path) |
|||
{ |
|||
g_autofree char *socket_path = NULL; |
|||
|
|||
socket_path = g_strdup(path); |
|||
|
|||
SocketAddress saddr = { |
|||
.type = SOCKET_ADDRESS_TYPE_UNIX, |
|||
.u.q_unix.path = socket_path |
|||
}; |
|||
|
|||
QIOChannelSocket *sioc = qio_channel_socket_new(); |
|||
Error *local_err = NULL; |
|||
|
|||
qio_channel_set_name(QIO_CHANNEL(sioc), "vmsr-helper"); |
|||
qio_channel_socket_connect_sync(sioc, |
|||
&saddr, |
|||
&local_err); |
|||
if (local_err) { |
|||
/* Close socket. */ |
|||
qio_channel_close(QIO_CHANNEL(sioc), NULL); |
|||
object_unref(OBJECT(sioc)); |
|||
sioc = NULL; |
|||
goto out; |
|||
} |
|||
|
|||
qio_channel_set_delay(QIO_CHANNEL(sioc), false); |
|||
out: |
|||
return sioc; |
|||
} |
|||
|
|||
uint64_t vmsr_read_msr(uint32_t reg, uint32_t cpu_id, uint32_t tid, |
|||
QIOChannelSocket *sioc) |
|||
{ |
|||
uint64_t data = 0; |
|||
int r = 0; |
|||
Error *local_err = NULL; |
|||
uint32_t buffer[3]; |
|||
/*
|
|||
* Send the required arguments: |
|||
* 1. RAPL MSR register to read |
|||
* 2. On which CPU ID |
|||
* 3. From which vCPU (Thread ID) |
|||
*/ |
|||
buffer[0] = reg; |
|||
buffer[1] = cpu_id; |
|||
buffer[2] = tid; |
|||
|
|||
r = qio_channel_write_all(QIO_CHANNEL(sioc), |
|||
(char *)buffer, sizeof(buffer), |
|||
&local_err); |
|||
if (r < 0) { |
|||
goto out_close; |
|||
} |
|||
|
|||
r = qio_channel_read(QIO_CHANNEL(sioc), |
|||
(char *)&data, sizeof(data), |
|||
&local_err); |
|||
if (r < 0) { |
|||
data = 0; |
|||
goto out_close; |
|||
} |
|||
|
|||
out_close: |
|||
return data; |
|||
} |
|||
|
|||
/* Retrieve the max number of physical package */ |
|||
unsigned int vmsr_get_max_physical_package(unsigned int max_cpus) |
|||
{ |
|||
const char *dir = "/sys/devices/system/cpu/"; |
|||
const char *topo_path = "topology/physical_package_id"; |
|||
g_autofree int *uniquePackages = g_new0(int, max_cpus); |
|||
unsigned int packageCount = 0; |
|||
FILE *file = NULL; |
|||
|
|||
for (int i = 0; i < max_cpus; i++) { |
|||
g_autofree char *filePath = NULL; |
|||
g_autofree char *cpuid = g_strdup_printf("cpu%d", i); |
|||
|
|||
filePath = g_build_filename(dir, cpuid, topo_path, NULL); |
|||
|
|||
file = fopen(filePath, "r"); |
|||
|
|||
if (file == NULL) { |
|||
error_report("Error opening physical_package_id file"); |
|||
return 0; |
|||
} |
|||
|
|||
char packageId[10]; |
|||
if (fgets(packageId, sizeof(packageId), file) == NULL) { |
|||
packageCount = 0; |
|||
} |
|||
|
|||
fclose(file); |
|||
|
|||
int currentPackageId = atoi(packageId); |
|||
|
|||
bool isUnique = true; |
|||
for (int j = 0; j < packageCount; j++) { |
|||
if (uniquePackages[j] == currentPackageId) { |
|||
isUnique = false; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (isUnique) { |
|||
uniquePackages[packageCount] = currentPackageId; |
|||
packageCount++; |
|||
|
|||
if (packageCount >= max_cpus) { |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return (packageCount == 0) ? 1 : packageCount; |
|||
} |
|||
|
|||
/* Retrieve the max number of physical cpu on the host */ |
|||
unsigned int vmsr_get_maxcpus(void) |
|||
{ |
|||
GDir *dir; |
|||
const gchar *entry_name; |
|||
unsigned int cpu_count = 0; |
|||
const char *path = "/sys/devices/system/cpu/"; |
|||
|
|||
dir = g_dir_open(path, 0, NULL); |
|||
if (dir == NULL) { |
|||
error_report("Unable to open cpu directory"); |
|||
return -1; |
|||
} |
|||
|
|||
while ((entry_name = g_dir_read_name(dir)) != NULL) { |
|||
if (g_ascii_strncasecmp(entry_name, "cpu", 3) == 0 && |
|||
isdigit(entry_name[3])) { |
|||
cpu_count++; |
|||
} |
|||
} |
|||
|
|||
g_dir_close(dir); |
|||
|
|||
return cpu_count; |
|||
} |
|||
|
|||
/* Count the number of physical cpu on each packages */ |
|||
unsigned int vmsr_count_cpus_per_package(unsigned int *package_count, |
|||
unsigned int max_pkgs) |
|||
{ |
|||
g_autofree char *file_contents = NULL; |
|||
g_autofree char *path = NULL; |
|||
g_autofree char *path_name = NULL; |
|||
gsize length; |
|||
|
|||
/* Iterate over cpus and count cpus in each package */ |
|||
for (int cpu_id = 0; ; cpu_id++) { |
|||
path_name = g_strdup_printf("/sys/devices/system/cpu/cpu%d/" |
|||
"topology/physical_package_id", cpu_id); |
|||
|
|||
path = g_build_filename(path_name, NULL); |
|||
|
|||
if (!g_file_get_contents(path, &file_contents, &length, NULL)) { |
|||
break; /* No more cpus */ |
|||
} |
|||
|
|||
/* Get the physical package ID for this CPU */ |
|||
int package_id = atoi(file_contents); |
|||
|
|||
/* Check if the package ID is within the known number of packages */ |
|||
if (package_id >= 0 && package_id < max_pkgs) { |
|||
/* If yes, count the cpu for this package*/ |
|||
package_count[package_id]++; |
|||
} |
|||
} |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
/* Get the physical package id from a given cpu id */ |
|||
int vmsr_get_physical_package_id(int cpu_id) |
|||
{ |
|||
g_autofree char *file_contents = NULL; |
|||
g_autofree char *file_path = NULL; |
|||
int package_id = -1; |
|||
gsize length; |
|||
|
|||
file_path = g_strdup_printf("/sys/devices/system/cpu/cpu%d" |
|||
"/topology/physical_package_id", cpu_id); |
|||
|
|||
if (!g_file_get_contents(file_path, &file_contents, &length, NULL)) { |
|||
goto out; |
|||
} |
|||
|
|||
package_id = atoi(file_contents); |
|||
|
|||
out: |
|||
return package_id; |
|||
} |
|||
|
|||
/* Read the scheduled time for a given thread of a give pid */ |
|||
void vmsr_read_thread_stat(pid_t pid, |
|||
unsigned int thread_id, |
|||
unsigned long long *utime, |
|||
unsigned long long *stime, |
|||
unsigned int *cpu_id) |
|||
{ |
|||
g_autofree char *path = NULL; |
|||
g_autofree char *path_name = NULL; |
|||
|
|||
path_name = g_strdup_printf("/proc/%u/task/%d/stat", pid, thread_id); |
|||
|
|||
path = g_build_filename(path_name, NULL); |
|||
|
|||
FILE *file = fopen(path, "r"); |
|||
if (file == NULL) { |
|||
pid = -1; |
|||
return; |
|||
} |
|||
|
|||
if (fscanf(file, "%*d (%*[^)]) %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u" |
|||
" %llu %llu %*d %*d %*d %*d %*d %*d %*u %*u %*d %*u %*u" |
|||
" %*u %*u %*u %*u %*u %*u %*u %*u %*u %*d %*u %*u %u", |
|||
utime, stime, cpu_id) != 3) |
|||
{ |
|||
pid = -1; |
|||
return; |
|||
} |
|||
|
|||
fclose(file); |
|||
return; |
|||
} |
|||
|
|||
/* Read QEMU stat task folder to retrieve all QEMU threads ID */ |
|||
pid_t *vmsr_get_thread_ids(pid_t pid, unsigned int *num_threads) |
|||
{ |
|||
g_autofree char *task_path = g_strdup_printf("%d/task", pid); |
|||
g_autofree char *path = g_build_filename("/proc", task_path, NULL); |
|||
|
|||
DIR *dir = opendir(path); |
|||
if (dir == NULL) { |
|||
error_report("Error opening /proc/qemu/task"); |
|||
return NULL; |
|||
} |
|||
|
|||
pid_t *thread_ids = NULL; |
|||
unsigned int thread_count = 0; |
|||
|
|||
g_autofree struct dirent *ent = NULL; |
|||
while ((ent = readdir(dir)) != NULL) { |
|||
if (ent->d_name[0] == '.') { |
|||
continue; |
|||
} |
|||
pid_t tid = atoi(ent->d_name); |
|||
if (pid != tid) { |
|||
thread_ids = g_renew(pid_t, thread_ids, (thread_count + 1)); |
|||
thread_ids[thread_count] = tid; |
|||
thread_count++; |
|||
} |
|||
} |
|||
|
|||
closedir(dir); |
|||
|
|||
*num_threads = thread_count; |
|||
return thread_ids; |
|||
} |
|||
|
|||
void vmsr_delta_ticks(vmsr_thread_stat *thd_stat, int i) |
|||
{ |
|||
thd_stat[i].delta_ticks = (thd_stat[i].utime[1] + thd_stat[i].stime[1]) |
|||
- (thd_stat[i].utime[0] + thd_stat[i].stime[0]); |
|||
} |
|||
|
|||
double vmsr_get_ratio(uint64_t e_delta, |
|||
unsigned long long delta_ticks, |
|||
unsigned int maxticks) |
|||
{ |
|||
return (e_delta / 100.0) * ((100.0 / maxticks) * delta_ticks); |
|||
} |
|||
|
|||
void vmsr_init_topo_info(X86CPUTopoInfo *topo_info, |
|||
const MachineState *ms) |
|||
{ |
|||
topo_info->dies_per_pkg = ms->smp.dies; |
|||
topo_info->modules_per_die = ms->smp.modules; |
|||
topo_info->cores_per_module = ms->smp.cores; |
|||
topo_info->threads_per_core = ms->smp.threads; |
|||
} |
|||
|
|||
@ -0,0 +1,99 @@ |
|||
/*
|
|||
* QEMU KVM support -- x86 virtual energy-related MSR. |
|||
* |
|||
* Copyright 2024 Red Hat, Inc. 2024 |
|||
* |
|||
* Author: |
|||
* Anthony Harivel <aharivel@redhat.com> |
|||
* |
|||
* This work is licensed under the terms of the GNU GPL, version 2 or later. |
|||
* See the COPYING file in the top-level directory. |
|||
* |
|||
*/ |
|||
|
|||
#ifndef VMSR_ENERGY_H |
|||
#define VMSR_ENERGY_H |
|||
|
|||
#include <stdint.h> |
|||
#include "qemu/osdep.h" |
|||
#include "io/channel-socket.h" |
|||
#include "hw/i386/topology.h" |
|||
|
|||
/*
|
|||
* Define the interval time in micro seconds between 2 samples of |
|||
* energy related MSRs |
|||
*/ |
|||
#define MSR_ENERGY_THREAD_SLEEP_US 1000000.0 |
|||
|
|||
/*
|
|||
* Thread statistic |
|||
* @ thread_id: TID (thread ID) |
|||
* @ is_vcpu: true if TID is vCPU thread |
|||
* @ cpu_id: CPU number last executed on |
|||
* @ pkg_id: package number of the CPU |
|||
* @ vcpu_id: vCPU ID |
|||
* @ vpkg: virtual package number |
|||
* @ acpi_id: APIC id of the vCPU |
|||
* @ utime: amount of clock ticks the thread |
|||
* has been scheduled in User mode |
|||
* @ stime: amount of clock ticks the thread |
|||
* has been scheduled in System mode |
|||
* @ delta_ticks: delta of utime+stime between |
|||
* the two samples (before/after sleep) |
|||
*/ |
|||
struct vmsr_thread_stat { |
|||
unsigned int thread_id; |
|||
bool is_vcpu; |
|||
unsigned int cpu_id; |
|||
unsigned int pkg_id; |
|||
unsigned int vpkg_id; |
|||
unsigned int vcpu_id; |
|||
unsigned long acpi_id; |
|||
unsigned long long *utime; |
|||
unsigned long long *stime; |
|||
unsigned long long delta_ticks; |
|||
}; |
|||
|
|||
/*
|
|||
* Package statistic |
|||
* @ e_start: package energy counter before the sleep |
|||
* @ e_end: package energy counter after the sleep |
|||
* @ e_delta: delta of package energy counter |
|||
* @ e_ratio: store the energy ratio of non-vCPU thread |
|||
* @ nb_vcpu: number of vCPU running on this package |
|||
*/ |
|||
struct vmsr_package_energy_stat { |
|||
uint64_t e_start; |
|||
uint64_t e_end; |
|||
uint64_t e_delta; |
|||
uint64_t e_ratio; |
|||
unsigned int nb_vcpu; |
|||
}; |
|||
|
|||
typedef struct vmsr_thread_stat vmsr_thread_stat; |
|||
typedef struct vmsr_package_energy_stat vmsr_package_energy_stat; |
|||
|
|||
char *vmsr_compute_default_paths(void); |
|||
void vmsr_read_thread_stat(pid_t pid, |
|||
unsigned int thread_id, |
|||
unsigned long long *utime, |
|||
unsigned long long *stime, |
|||
unsigned int *cpu_id); |
|||
|
|||
QIOChannelSocket *vmsr_open_socket(const char *path); |
|||
uint64_t vmsr_read_msr(uint32_t reg, uint32_t cpu_id, |
|||
uint32_t tid, QIOChannelSocket *sioc); |
|||
void vmsr_delta_ticks(vmsr_thread_stat *thd_stat, int i); |
|||
unsigned int vmsr_get_maxcpus(void); |
|||
unsigned int vmsr_get_max_physical_package(unsigned int max_cpus); |
|||
unsigned int vmsr_count_cpus_per_package(unsigned int *package_count, |
|||
unsigned int max_pkgs); |
|||
int vmsr_get_physical_package_id(int cpu_id); |
|||
pid_t *vmsr_get_thread_ids(pid_t pid, unsigned int *num_threads); |
|||
double vmsr_get_ratio(uint64_t e_delta, |
|||
unsigned long long delta_ticks, |
|||
unsigned int maxticks); |
|||
void vmsr_init_topo_info(X86CPUTopoInfo *topo_info, const MachineState *ms); |
|||
bool is_host_cpu_intel(void); |
|||
int is_rapl_enabled(void); |
|||
#endif /* VMSR_ENERGY_H */ |
|||
Loading…
Reference in new issue