Cache Monitoring Technology (aka CMT) provides the capability
to report cache utilization information of system task.
This patch introduces the concept of resctrl monitor through
data structure virResctrlMonitor.
Signed-off-by: Wang Huaqiang <huaqiang.wang(a)intel.com>
---
src/libvirt_private.syms | 1 +
src/util/virresctrl.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
src/util/virresctrl.h | 7 ++++++
3 files changed, 64 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 335210c..d2573c5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2680,6 +2680,7 @@ virResctrlInfoGetCache;
virResctrlInfoGetMonitorPrefix;
virResctrlInfoMonFree;
virResctrlInfoNew;
+virResctrlMonitorNew;
# util/virrotatingfile.h
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 697424c..18ee560 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -105,6 +105,7 @@ typedef virResctrlAllocMemBW *virResctrlAllocMemBWPtr;
/* Class definitions and initializations */
static virClassPtr virResctrlInfoClass;
static virClassPtr virResctrlAllocClass;
+static virClassPtr virResctrlMonitorClass;
/* virResctrlInfo */
@@ -319,6 +320,35 @@ struct _virResctrlAlloc {
char *path;
};
+/* virResctrlMonitor */
+
+/*
+ * virResctrlMonitor is the data structure for resctrl monitor. Resctrl
+ * monitor represents a resctrl monitoring group, which can be used to
+ * monitor the resource utilization information for either cache or
+ * memory bandwidth.
+ *
+ * From hardware perspective, cache monitoring technology (CMT), memory
+ * bandwidth technology (MBM), as well as the CAT and MBA, are all orthogonal
+ * features. The monitor will be created under the scope of default allocation
+ * if no CAT or MBA supported in the system.
+ */
+struct _virResctrlMonitor {
+ virObject parent;
+
+ /* In resctrl, each monitor is associated with one specific allocation,
+ * either the allocation under /sys/fs/resctrl or the default allocation.
+ * If this pointer is NULL, then the monitor will be associated with
+ * default allocation, otherwise, this pointer points to the allocation
+ * this monitor associated with. */
+ virResctrlAllocPtr alloc;
+ /* The monitor identifier */
+ char *id;
+ /* libvirt-generated path in /sys/fs/resctrl for this particular
+ * monitor */
+ char *path;
+};
+
static void
virResctrlAllocDispose(void *obj)
@@ -368,6 +398,17 @@ virResctrlAllocDispose(void *obj)
}
+static void
+virResctrlMonitorDispose(void *obj)
+{
+ virResctrlMonitorPtr monitor = obj;
+
+ virObjectUnref(monitor->alloc);
+ VIR_FREE(monitor->id);
+ VIR_FREE(monitor->path);
+}
+
+
/* Global initialization for classes */
static int
virResctrlOnceInit(void)
@@ -378,6 +419,9 @@ virResctrlOnceInit(void)
if (!VIR_CLASS_NEW(virResctrlAlloc, virClassForObject()))
return -1;
+ if (!VIR_CLASS_NEW(virResctrlMonitor, virClassForObject()))
+ return -1;
+
return 0;
}
@@ -2372,3 +2416,15 @@ virResctrlAllocRemove(virResctrlAllocPtr alloc)
return ret;
}
+
+
+/* virResctrlMonitor-related definitions */
+
+virResctrlMonitorPtr
+virResctrlMonitorNew(void)
+{
+ if (virResctrlInitialize() < 0)
+ return NULL;
+
+ return virObjectNew(virResctrlMonitorClass);
+}
diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h
index 10505e9..f59a9aa 100644
--- a/src/util/virresctrl.h
+++ b/src/util/virresctrl.h
@@ -185,4 +185,11 @@ int
virResctrlInfoGetMonitorPrefix(virResctrlInfoPtr resctrl,
const char *prefix,
virResctrlInfoMonPtr *monitor);
+
+/* Monitor-related things */
+typedef struct _virResctrlMonitor virResctrlMonitor;
+typedef virResctrlMonitor *virResctrlMonitorPtr;
+
+virResctrlMonitorPtr
+virResctrlMonitorNew(void);
#endif /* __VIR_RESCTRL_H__ */
--
2.7.4