On 5/14/26 16:41, Jedrzej Wasiukiewicz wrote:
Linux 7.0 introduced in resctrl PERF_PKG_MON interface that exposes per-package energy and performance counters. This patch extends virresctrl implementation to discover and read energy counters from this new resource type. (core_energy - Joules, activity - Farads)
Changes: - Add Energy features allow-list virResctrlEnergyFeatures since PERF_PKG_MON is not prefix-based. - Added perf_monitor_info to _virResctrlInfo to contain _virResctrlInfo capabilities - New virResctrlGetPerfMonitorInfo following earlier virResctrlGetMonitorInfo to check new resource capabilities - Added VIR_RESCTRL_MONITOR_TYPE_ENERGY and mapped it to energy allow-list - Added dvals/ndvals pair to _virResctrlMonitorStats to support floating-point counters and integer counters in single monitor (to support integer perf counters in the future). - Added floating-point read + parse in virResctrlMonitorGetStats for energy counters - Stubbed VIR_RESCTRL_MONITOR_TYPE_ENERGY in qemu_driver
Signed-off-by: Jedrzej Wasiukiewicz <jedrzej.wasiukiewicz@intel.com> Signed-off-by: Christopher M. Cantalupo <christopher.m.cantalupo@intel.com> --- src/qemu/qemu_driver.c | 1 + src/util/virresctrl.c | 180 ++++++++++++++++++++++++++++++++++------- src/util/virresctrl.h | 10 ++- 3 files changed, 158 insertions(+), 33 deletions(-)
diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index c70b112864..857afe6f1e 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -38,6 +38,7 @@ typedef enum { VIR_RESCTRL_MONITOR_TYPE_UNSUPPORT, VIR_RESCTRL_MONITOR_TYPE_CACHE, VIR_RESCTRL_MONITOR_TYPE_MEMBW, + VIR_RESCTRL_MONITOR_TYPE_ENERGY,
VIR_RESCTRL_MONITOR_TYPE_LAST } virResctrlMonitorType; @@ -196,11 +197,16 @@ struct _virResctrlMonitorStats { /* @features is a NULL terminal string list tracking the statistical record * name.*/ char **features; - /* @vals store the statistical record values and @val[0] is the value for - * @features[0], @val[1] for@features[1] ... respectively */ + /* @vals store the statistical record values for integer-valued resources. Entries correspond 1:1 with + * @features; empty when the resource reports floating-point data. */
Long lines.
unsigned long long *vals; /* The length of @vals array */ size_t nvals; + /* @dvals store double-precision values for floating-point resources. + * Entries correspond 1:1 with @features; empty when the resource reports integer data. */
Again.
+ double *dvals; + /* The length of @dvals array */ + size_t ndvals; };
virResctrlMonitor *
Michal