[libvirt] [PATCHv7 02/18] util: Introduce resctrl monitor for CMT

Wang Huaqiang posted 18 patches 4 years, 7 months ago
[libvirt] [PATCHv7 02/18] util: Introduce resctrl monitor for CMT
Posted by Wang Huaqiang 4 years, 7 months ago
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@intel.com>
---
 src/libvirt_private.syms |  1 +
 src/util/virresctrl.c    | 79 ++++++++++++++++++++++++++++++++++++++++++++----
 src/util/virresctrl.h    |  9 ++++++
 3 files changed, 83 insertions(+), 6 deletions(-)

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 91bd341..6530801 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -36,9 +36,9 @@ VIR_LOG_INIT("util.virresctrl")
 
 
 /* Resctrl is short for Resource Control.  It might be implemented for various
- * resources. Currently this supports cache allocation technology (aka CAT) and
- * memory bandwidth allocation (aka MBA). More resources technologies may be
- * added in the future.
+ * resources. Currently this supports cache allocation technology (aka CAT),
+ * memory bandwidth allocation (aka MBA) and cache monitoring technology (aka
+ * CMT). More resources technologies may be added in the future.
  */
 
 
@@ -105,6 +105,7 @@ typedef virResctrlAllocMemBW *virResctrlAllocMemBWPtr;
 /* Class definitions and initializations */
 static virClassPtr virResctrlInfoClass;
 static virClassPtr virResctrlAllocClass;
+static virClassPtr virResctrlMonitorClass;
 
 
 /* virResctrlInfo */
@@ -224,11 +225,16 @@ virResctrlInfoMonFree(virResctrlInfoMonPtr mon)
 }
 
 
-/* virResctrlAlloc */
+/* virResctrlAlloc and virResctrlMonitor*/
 
 /*
- * virResctrlAlloc represents one allocation (in XML under cputune/cachetune and
- * consequently a directory under /sys/fs/resctrl).  Since it can have multiple
+ * virResctrlAlloc and virResctrlMonitor are representing a resource control
+ * group (in XML under cputune/cachetune and consequently a directory under
+ * /sys/fs/resctrl). virResctrlAlloc is the data structure for resource
+ * allocation, while the virResctrlMonitor represents the resource monitoring
+ * part.
+ *
+ * virResctrlAlloc represents one allocation. Since it can have multiple
  * parts of multiple caches allocated it is represented as bunch of nested
  * sparse arrays (by sparse I mean array of pointers so that each might be NULL
  * in case there is no allocation for that particular cache allocation (level,
@@ -275,6 +281,18 @@ virResctrlInfoMonFree(virResctrlInfoMonPtr mon)
  * a sparse array to represent whether a memory bandwidth allocation happens
  * on corresponding node. The available memory controller number is collected
  * in 'virResctrlInfo'.
+ *
+ * =====Cache monitoring technology (CMT)=====
+ *
+ * Cache monitoring technology is used to perceive how many cache the process
+ * is using actually. virResctrlMonitor represents the resource control
+ * monitoring group, it is supported to monitor resource utilization
+ * information on granularity of vcpu.
+ *
+ * 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 resctl
+ * group if no specific CAT or MBA entries are provided for the guest."
  */
 struct _virResctrlAllocPerType {
     /* There could be bool saying whether this is set or not, but since everything
@@ -320,6 +338,29 @@ struct _virResctrlAlloc {
     char *path;
 };
 
+/*
+ * 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.
+ */
+struct _virResctrlMonitor {
+    virObject parent;
+
+    /* In resctrl, each monitor is associated with one specific allocation,
+     * either the allocation under / sys / fs / resctrl or allocation of the
+     * root directory itself. This pointer points to the allocation
+     * this monitor associated with. */
+    virResctrlAllocPtr alloc;
+    /* The monitor identifier. For a monitor has the same @path name as its
+     * @alloc, the @id will be set to the same value as it is in @alloc->id.
+     */
+    char *id;
+    /* libvirt-generated path in /sys/fs/resctrl for this particular
+     * monitor */
+    char *path;
+};
+
 
 static void
 virResctrlAllocDispose(void *obj)
@@ -369,6 +410,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)
@@ -379,6 +431,9 @@ virResctrlOnceInit(void)
     if (!VIR_CLASS_NEW(virResctrlAlloc, virClassForObject()))
         return -1;
 
+    if (!VIR_CLASS_NEW(virResctrlMonitor, virClassForObject()))
+        return -1;
+
     return 0;
 }
 
@@ -2373,3 +2428,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..eaa077d 100644
--- a/src/util/virresctrl.h
+++ b/src/util/virresctrl.h
@@ -185,4 +185,13 @@ 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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv7 02/18] util: Introduce resctrl monitor for CMT
Posted by John Ferlan 4 years, 7 months ago

On 10/22/18 4:01 AM, Wang Huaqiang wrote:
> 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@intel.com>
> ---
>  src/libvirt_private.syms |  1 +
>  src/util/virresctrl.c    | 79 ++++++++++++++++++++++++++++++++++++++++++++----
>  src/util/virresctrl.h    |  9 ++++++
>  3 files changed, 83 insertions(+), 6 deletions(-)
> 
> 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

[...]

> @@ -275,6 +281,18 @@ virResctrlInfoMonFree(virResctrlInfoMonPtr mon)
>   * a sparse array to represent whether a memory bandwidth allocation happens
>   * on corresponding node. The available memory controller number is collected
>   * in 'virResctrlInfo'.
> + *
> + * =====Cache monitoring technology (CMT)=====
> + *
> + * Cache monitoring technology is used to perceive how many cache the process
> + * is using actually. virResctrlMonitor represents the resource control
> + * monitoring group, it is supported to monitor resource utilization
> + * information on granularity of vcpu.
> + *
> + * From hardware perspective, cache monitoring technology (CMT), memory

>From a

> + * bandwidth technology (MBM), as well as the CAT and MBA, are all orthogonal
> + * features. The monitor will be created under the scope of default resctl

*resctrl

> + * group if no specific CAT or MBA entries are provided for the guest."
>   */
>  struct _virResctrlAllocPerType {
>      /* There could be bool saying whether this is set or not, but since everything
> @@ -320,6 +338,29 @@ struct _virResctrlAlloc {
>      char *path;
>  };
>  
> +/*
> + * 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.
> + */
> +struct _virResctrlMonitor {
> +    virObject parent;
> +
> +    /* In resctrl, each monitor is associated with one specific allocation,

Each ResctrlMonitor is associated...

> +     * either the allocation under / sys / fs / resctrl or allocation of the

either the root directory allocation /sys/fs/resctrl or a specific
allocation defined under the root directory.


With these simple changes that I can make for you,

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

[...]

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list