Re: [libvirt] [PATCHv2 1/4] util: Introduce monitor capability interface

2018-10-09 Thread Wang, Huaqiang
Hi Jano,

Recognized there was already a commit for a  fixing: 
7bff646d71aa90ed8727ef99be29d6d2ab5d8f06.
And now I got your idea.

Thanks
Huaqiang

> -Original Message-
> From: Wang, Huaqiang
> Sent: Tuesday, October 9, 2018 5:55 PM
> To: 'Ján Tomko' ; John Ferlan 
> Cc: libvir-list@redhat.com; Feng, Shaohe ; Niu, Bing
> ; Ding, Jian-feng ; Zang, Rui
> 
> Subject: RE: [libvirt] [PATCHv2 1/4] util: Introduce monitor capability 
> interface
> 
> 
> 
> > -Original Message-
> > From: Ján Tomko [mailto:jto...@redhat.com]
> > Sent: Friday, October 5, 2018 10:42 PM
> > To: John Ferlan 
> > Cc: Wang, Huaqiang ; libvir-list@redhat.com;
> > Feng, Shaohe ; Niu, Bing ;
> > Ding, Jian- feng ; Zang, Rui
> > 
> > Subject: Re: [libvirt] [PATCHv2 1/4] util: Introduce monitor
> > capability interface
> >
> > On Tue, Sep 18, 2018 at 03:38:44PM -0400, John Ferlan wrote:
> > >On 09/14/2018 09:30 PM, Wang Huaqiang wrote:
> > >> This patch introduces the resource monitor and creates the
> > >> interface for getting host capability of resource monitor from the
> > >> system resource control file system.
> > >>
> > >> The resource monitor take the role of RDT monitoring group, could
> > >> be
> > >
> > >*takes...
> > >
> > >s/, could/ and could/
> > >
> > >> used to monitor the resource consumption information, such as the
> > >> last level cache occupancy and the utilization of memory bandwidth.
> > >>
> > >> Signed-off-by: Wang Huaqiang 
> > >> ---
> > >>  src/util/virresctrl.c | 124
> > >> ++
> > >>  1 file changed, 124 insertions(+)
> > >>
> >
> > [...]
> >
> > >> +
> > >> +rv = virFileReadValueUint(_monitor->max_monitor,
> > >> +  SYSFS_RESCTRL_PATH 
> > >> "/info/L3_MON/num_rmids");
> > >> +if (rv == -2) {
> > >> +/* The file doesn't exist, so it's unusable for us, probably 
> > >> resource
> > >> + * monitor unsupported */
> > >> +VIR_INFO("The path '" SYSFS_RESCTRL_PATH
> > "/info/L3_MON/num_rmids' "
> > >> + "does not exist");
> > >
> > >Add virResetLastError()
> > >
> > >[avoids having this error in Last and something else failing and
> > >spewing the error]
> > >
> >
> > The return value of -2 means no error was set, so there is nothing to do 
> > here.
> 
> A return value of -2 means no error, rather than executing remaining part of
> function, it requires to return to the caller without reporting any error.
> 
> Here, a return value of -2 means "/info/L3_MON/num_rmids" is not exists, this
> could happen if CMT is not supported by host. This is a valid scenario and 
> does
> not mean an error, and this function should not report any error to its 
> caller, and
> the caller, which is virResctrlGetInfo, will continue to run its remaining
> statements normally.
> 
> >
> > Also, virResetLastError is meant to be used before starting an API.
> > It only resets the thread-local error object (which can only contain
> > one error), it cannot possibly unlog an error that was logged earlier.
> > In that case, creating a Quiet version of the function is the proper 
> > solution.
> 
> Do you mean the message reported by 'VIR_INFO' should be removed and also
> not adding the 'virResetLastError' line?
> 
> It might be more consistent if we keep the 'VIR_INFO' lines, because the 
> similar
> message has been emitted in checking the memory bandwidth information and
> cache allocation information. But if you insist that this message should not 
> be
> shown to user or developer, I could accept that and make change to it.
> 
> @@ -704,12 +704,7 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl)
>  rv = virFileReadValueUint(_monitor->max_monitor,
>SYSFS_RESCTRL_PATH "/info/L3_MON/num_rmids");
>  if (rv == -2) {
> /* The file doesn't exist, so it's unusable for us, probably resource
>  * monitor unsupported */
> VIR_INFO("The file '" SYSFS_RESCTRL_PATH "/info/L3_MON/num_rmids' "
>  "does not exist");
>  ret = 0;
> -virResetLastError();
>  goto cleanup;
>  } else if (rv < 0) {
>  /* Other failures are fatal, so just quit */
> 
> >
> > Jano
> >
> > >> +ret = 0;
> > >> +goto cleanup;

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


Re: [libvirt] [PATCHv2 1/4] util: Introduce monitor capability interface

2018-10-09 Thread Wang, Huaqiang



> -Original Message-
> From: Ján Tomko [mailto:jto...@redhat.com]
> Sent: Friday, October 5, 2018 10:42 PM
> To: John Ferlan 
> Cc: Wang, Huaqiang ; libvir-list@redhat.com; Feng,
> Shaohe ; Niu, Bing ; Ding, Jian-
> feng ; Zang, Rui 
> Subject: Re: [libvirt] [PATCHv2 1/4] util: Introduce monitor capability 
> interface
> 
> On Tue, Sep 18, 2018 at 03:38:44PM -0400, John Ferlan wrote:
> >On 09/14/2018 09:30 PM, Wang Huaqiang wrote:
> >> This patch introduces the resource monitor and creates the interface
> >> for getting host capability of resource monitor from the system
> >> resource control file system.
> >>
> >> The resource monitor take the role of RDT monitoring group, could be
> >
> >*takes...
> >
> >s/, could/ and could/
> >
> >> used to monitor the resource consumption information, such as the
> >> last level cache occupancy and the utilization of memory bandwidth.
> >>
> >> Signed-off-by: Wang Huaqiang 
> >> ---
> >>  src/util/virresctrl.c | 124
> >> ++
> >>  1 file changed, 124 insertions(+)
> >>
> 
> [...]
> 
> >> +
> >> +rv = virFileReadValueUint(_monitor->max_monitor,
> >> +  SYSFS_RESCTRL_PATH 
> >> "/info/L3_MON/num_rmids");
> >> +if (rv == -2) {
> >> +/* The file doesn't exist, so it's unusable for us, probably 
> >> resource
> >> + * monitor unsupported */
> >> +VIR_INFO("The path '" SYSFS_RESCTRL_PATH
> "/info/L3_MON/num_rmids' "
> >> + "does not exist");
> >
> >Add virResetLastError()
> >
> >[avoids having this error in Last and something else failing and
> >spewing the error]
> >
> 
> The return value of -2 means no error was set, so there is nothing to do here.

A return value of -2 means no error, rather than executing remaining part of 
function,
it requires to return to the caller without reporting any error.

Here, a return value of -2 means "/info/L3_MON/num_rmids" is not exists, this
could happen if CMT is not supported by host. This is a valid scenario and does
not mean an error, and this function should not report any error to its caller, 
and
the caller, which is virResctrlGetInfo, will continue to run its remaining 
statements
normally.

> 
> Also, virResetLastError is meant to be used before starting an API.
> It only resets the thread-local error object (which can only contain one 
> error), it
> cannot possibly unlog an error that was logged earlier.
> In that case, creating a Quiet version of the function is the proper solution.

Do you mean the message reported by 'VIR_INFO' should be removed and also not
adding the 'virResetLastError' line?

It might be more consistent if we keep the 'VIR_INFO' lines, because the similar
message has been emitted in checking the memory bandwidth information and
cache allocation information. But if you insist that this message should not be
shown to user or developer, I could accept that and make change to it.

@@ -704,12 +704,7 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl)
 rv = virFileReadValueUint(_monitor->max_monitor,
   SYSFS_RESCTRL_PATH "/info/L3_MON/num_rmids");
 if (rv == -2) {
/* The file doesn't exist, so it's unusable for us, probably resource
 * monitor unsupported */
VIR_INFO("The file '" SYSFS_RESCTRL_PATH "/info/L3_MON/num_rmids' "
 "does not exist");
 ret = 0;
-virResetLastError();
 goto cleanup;
 } else if (rv < 0) {
 /* Other failures are fatal, so just quit */

> 
> Jano
> 
> >> +ret = 0;
> >> +goto cleanup;

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


Re: [libvirt] [PATCHv2 1/4] util: Introduce monitor capability interface

2018-10-05 Thread Ján Tomko

On Tue, Sep 18, 2018 at 03:38:44PM -0400, John Ferlan wrote:

On 09/14/2018 09:30 PM, Wang Huaqiang wrote:

This patch introduces the resource monitor and creates the interface
for getting host capability of resource monitor from the system resource
control file system.

The resource monitor take the role of RDT monitoring group, could be


*takes...

s/, could/ and could/


used to monitor the resource consumption information, such as the last
level cache occupancy and the utilization of memory bandwidth.

Signed-off-by: Wang Huaqiang 
---
 src/util/virresctrl.c | 124 ++
 1 file changed, 124 insertions(+)



[...]


+
+rv = virFileReadValueUint(_monitor->max_monitor,
+  SYSFS_RESCTRL_PATH "/info/L3_MON/num_rmids");
+if (rv == -2) {
+/* The file doesn't exist, so it's unusable for us, probably resource
+ * monitor unsupported */
+VIR_INFO("The path '" SYSFS_RESCTRL_PATH "/info/L3_MON/num_rmids' "
+ "does not exist");


Add virResetLastError()

[avoids having this error in Last and something else failing and spewing
the error]



The return value of -2 means no error was set, so there is nothing to do
here.

Also, virResetLastError is meant to be used before starting an API.
It only resets the thread-local error object (which can only contain one
error), it cannot possibly unlog an error that was logged earlier.
In that case, creating a Quiet version of the function is the proper
solution.

Jano


+ret = 0;
+goto cleanup;


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCHv2 1/4] util: Introduce monitor capability interface

2018-09-20 Thread Wang, Huaqiang


> -Original Message-
> From: John Ferlan [mailto:jfer...@redhat.com]
> Sent: Wednesday, September 19, 2018 3:39 AM
> To: Wang, Huaqiang ; libvir-list@redhat.com
> Cc: Feng, Shaohe ; Niu, Bing ;
> Ding, Jian-feng ; Zang, Rui 
> Subject: Re: [PATCHv2 1/4] util: Introduce monitor capability interface
> 
> 
> 
> On 09/14/2018 09:30 PM, Wang Huaqiang wrote:
> > This patch introduces the resource monitor and creates the interface
> > for getting host capability of resource monitor from the system
> > resource control file system.
> >
> > The resource monitor take the role of RDT monitoring group, could be
> 
> *takes...
> 
> s/, could/ and could/
> 
> > used to monitor the resource consumption information, such as the last
> > level cache occupancy and the utilization of memory bandwidth.
> >
> > Signed-off-by: Wang Huaqiang 
> > ---
> >  src/util/virresctrl.c | 124
> > ++
> >  1 file changed, 124 insertions(+)
> >
> > diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index
> > 4b5442f..4601f69 100644
> > --- a/src/util/virresctrl.c
> > +++ b/src/util/virresctrl.c
> > @@ -83,6 +83,9 @@ typedef virResctrlInfoPerLevel
> > *virResctrlInfoPerLevelPtr;  typedef struct _virResctrlInfoMemBW
> > virResctrlInfoMemBW;  typedef virResctrlInfoMemBW
> > *virResctrlInfoMemBWPtr;
> >
> > +typedef struct _virResctrlInfoMongrp virResctrlInfoMongrp; typedef
> > +virResctrlInfoMongrp *virResctrlInfoMongrpPtr;
> > +
> >  typedef struct _virResctrlAllocPerType virResctrlAllocPerType;
> > typedef virResctrlAllocPerType *virResctrlAllocPerTypePtr;
> >
> > @@ -139,6 +142,28 @@ struct _virResctrlInfoMemBW {
> >  unsigned int max_id;
> >  };
> >
> > +struct _virResctrlInfoMongrp {
> > +/* Maximum number of simultaneous monitors */
> > +unsigned int max_monitor;
> > +/* null-terminal string list for monitor features */
> > +char **features;
> > +/* Number of monitor features */
> > +size_t nfeatures;
> > +
> > +/* Last level cache related information */
> > +
> > +/* This Adjustable value affects the final reuse of resources used by
> > + * monitor. After the action of removing a monitor, the kernel may not
> > + * release all hardware resources that monitor used immediately if the
> > + * cache occupancy value associated with 'removed' monitor is above 
> > this
> > + * threshold. Once the cache occupancy is below this threshold, the
> > + * underlying hardware resource will be reclaimed and be put into the
> > + * resource pool for next reusing.*/
> > +unsigned int cache_reuse_threshold;
> > +/* The cache 'level' that has the monitor capability */
> > +unsigned int cache_level;
> > +};
> > +
> >  struct _virResctrlInfo {
> >  virObject parent;
> >
> > @@ -146,6 +171,8 @@ struct _virResctrlInfo {
> >  size_t nlevels;
> >
> >  virResctrlInfoMemBWPtr membw_info;
> > +
> > +virResctrlInfoMongrpPtr monitor_info;
> >  };
> >
> >
> > @@ -171,8 +198,12 @@ virResctrlInfoDispose(void *obj)
> >  VIR_FREE(level);
> >  }
> >
> > +if (resctrl->monitor_info)
> > +VIR_FREE(resctrl->monitor_info->features);
> 
> virStringListFree
> 
> > +
> >  VIR_FREE(resctrl->membw_info);
> >  VIR_FREE(resctrl->levels);
> > +VIR_FREE(resctrl->monitor_info);
> >  }
> >
> >
> > @@ -555,6 +586,92 @@
> > virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr resctrl)  }
> >
> >
> > +/*
> > + * Retrieve monitor capability from the resource control file system.
> > + *
> > + * The monitor capability is exposed through
> "SYSFS_RESCTRL_PATH/info/L3_MON"
> > + * directory under the resource control file system. The monitor
> > +capability is
> > + * parsed by reading the interface files and stored in the structure
> > + * 'virResctrlInfoMongrp'.
> > + *
> > + * Not all host supports the resource monitor, leave the pointer
> > + * @resctrl->monitor_info empty if not supported.
> > + */
> > +static int
> > +virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl) {
> > +int ret = -1;
> > +int rv = -1;
> > +char *featurestr = NULL;
> > +char **features = NULL;
> > +size_t nfeatures = 0;
> > +virResctrlInfoMongrpPtr info_monitor = NULL;
> > +
> > +if (VIR_ALLOC(info_monitor) < 0)
> > +return -1;
> > +
> > +/* monitor only exists in leve 3 cache */
> 
> *level
> 
> Let's say, "For now, monitor only exists in level 3 cache"
> 
> > +info_monitor->cache_level = 3;
> 
> So I think in the last review I was thinking that if we ever see a different 
> level,
> then the L3 below would need to change. Although for now I wonder if it should
> be removed. I'll leave it unless you really think it should be removed. I 
> think I was
> being ultra careful/paranoid.
> 
> Perhaps the future is GetMonitorInfo takes in the cache_level as a parameter 
> in
> order to build up the path and save the level in a structure.  I think to a 
> degree
> we're good to have that level of 

Re: [libvirt] [PATCHv2 1/4] util: Introduce monitor capability interface

2018-09-18 Thread John Ferlan



On 09/14/2018 09:30 PM, Wang Huaqiang wrote:
> This patch introduces the resource monitor and creates the interface
> for getting host capability of resource monitor from the system resource
> control file system.
> 
> The resource monitor take the role of RDT monitoring group, could be

*takes...

s/, could/ and could/

> used to monitor the resource consumption information, such as the last
> level cache occupancy and the utilization of memory bandwidth.
> 
> Signed-off-by: Wang Huaqiang 
> ---
>  src/util/virresctrl.c | 124 
> ++
>  1 file changed, 124 insertions(+)
> 
> diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
> index 4b5442f..4601f69 100644
> --- a/src/util/virresctrl.c
> +++ b/src/util/virresctrl.c
> @@ -83,6 +83,9 @@ typedef virResctrlInfoPerLevel *virResctrlInfoPerLevelPtr;
>  typedef struct _virResctrlInfoMemBW virResctrlInfoMemBW;
>  typedef virResctrlInfoMemBW *virResctrlInfoMemBWPtr;
>  
> +typedef struct _virResctrlInfoMongrp virResctrlInfoMongrp;
> +typedef virResctrlInfoMongrp *virResctrlInfoMongrpPtr;
> +
>  typedef struct _virResctrlAllocPerType virResctrlAllocPerType;
>  typedef virResctrlAllocPerType *virResctrlAllocPerTypePtr;
>  
> @@ -139,6 +142,28 @@ struct _virResctrlInfoMemBW {
>  unsigned int max_id;
>  };
>  
> +struct _virResctrlInfoMongrp {
> +/* Maximum number of simultaneous monitors */
> +unsigned int max_monitor;
> +/* null-terminal string list for monitor features */
> +char **features;
> +/* Number of monitor features */
> +size_t nfeatures;
> +
> +/* Last level cache related information */
> +
> +/* This Adjustable value affects the final reuse of resources used by
> + * monitor. After the action of removing a monitor, the kernel may not
> + * release all hardware resources that monitor used immediately if the
> + * cache occupancy value associated with 'removed' monitor is above this
> + * threshold. Once the cache occupancy is below this threshold, the
> + * underlying hardware resource will be reclaimed and be put into the
> + * resource pool for next reusing.*/
> +unsigned int cache_reuse_threshold;
> +/* The cache 'level' that has the monitor capability */
> +unsigned int cache_level;
> +};
> +
>  struct _virResctrlInfo {
>  virObject parent;
>  
> @@ -146,6 +171,8 @@ struct _virResctrlInfo {
>  size_t nlevels;
>  
>  virResctrlInfoMemBWPtr membw_info;
> +
> +virResctrlInfoMongrpPtr monitor_info;
>  };
>  
>  
> @@ -171,8 +198,12 @@ virResctrlInfoDispose(void *obj)
>  VIR_FREE(level);
>  }
>  
> +if (resctrl->monitor_info)
> +VIR_FREE(resctrl->monitor_info->features);

virStringListFree

> +
>  VIR_FREE(resctrl->membw_info);
>  VIR_FREE(resctrl->levels);
> +VIR_FREE(resctrl->monitor_info);
>  }
>  
>  
> @@ -555,6 +586,92 @@ virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr 
> resctrl)
>  }
>  
>  
> +/*
> + * Retrieve monitor capability from the resource control file system.
> + *
> + * The monitor capability is exposed through "SYSFS_RESCTRL_PATH/info/L3_MON"
> + * directory under the resource control file system. The monitor capability 
> is
> + * parsed by reading the interface files and stored in the structure
> + * 'virResctrlInfoMongrp'.
> + *
> + * Not all host supports the resource monitor, leave the pointer
> + * @resctrl->monitor_info empty if not supported.
> + */
> +static int
> +virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl)
> +{
> +int ret = -1;
> +int rv = -1;
> +char *featurestr = NULL;
> +char **features = NULL;
> +size_t nfeatures = 0;
> +virResctrlInfoMongrpPtr info_monitor = NULL;
> +
> +if (VIR_ALLOC(info_monitor) < 0)
> +return -1;
> +
> +/* monitor only exists in leve 3 cache */

*level

Let's say, "For now, monitor only exists in level 3 cache"

> +info_monitor->cache_level = 3;

So I think in the last review I was thinking that if we ever see a
different level, then the L3 below would need to change. Although for
now I wonder if it should be removed. I'll leave it unless you really
think it should be removed. I think I was being ultra careful/paranoid.

Perhaps the future is GetMonitorInfo takes in the cache_level as a
parameter in order to build up the path and save the level in a
structure.  I think to a degree we're good to have that level of
indirection with these latest changes.  I don't mind removing it
completely from this pile, but don't want to mess you up for the future
either!

> +
> +rv = virFileReadValueUint(_monitor->max_monitor,
> +  SYSFS_RESCTRL_PATH "/info/L3_MON/num_rmids");
> +if (rv == -2) {
> +/* The file doesn't exist, so it's unusable for us, probably resource
> + * monitor unsupported */
> +VIR_INFO("The path '" SYSFS_RESCTRL_PATH "/info/L3_MON/num_rmids' "
> + "does not exist");

Add 

[libvirt] [PATCHv2 1/4] util: Introduce monitor capability interface

2018-09-14 Thread Wang Huaqiang
This patch introduces the resource monitor and creates the interface
for getting host capability of resource monitor from the system resource
control file system.

The resource monitor take the role of RDT monitoring group, could be
used to monitor the resource consumption information, such as the last
level cache occupancy and the utilization of memory bandwidth.

Signed-off-by: Wang Huaqiang 
---
 src/util/virresctrl.c | 124 ++
 1 file changed, 124 insertions(+)

diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 4b5442f..4601f69 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -83,6 +83,9 @@ typedef virResctrlInfoPerLevel *virResctrlInfoPerLevelPtr;
 typedef struct _virResctrlInfoMemBW virResctrlInfoMemBW;
 typedef virResctrlInfoMemBW *virResctrlInfoMemBWPtr;
 
+typedef struct _virResctrlInfoMongrp virResctrlInfoMongrp;
+typedef virResctrlInfoMongrp *virResctrlInfoMongrpPtr;
+
 typedef struct _virResctrlAllocPerType virResctrlAllocPerType;
 typedef virResctrlAllocPerType *virResctrlAllocPerTypePtr;
 
@@ -139,6 +142,28 @@ struct _virResctrlInfoMemBW {
 unsigned int max_id;
 };
 
+struct _virResctrlInfoMongrp {
+/* Maximum number of simultaneous monitors */
+unsigned int max_monitor;
+/* null-terminal string list for monitor features */
+char **features;
+/* Number of monitor features */
+size_t nfeatures;
+
+/* Last level cache related information */
+
+/* This Adjustable value affects the final reuse of resources used by
+ * monitor. After the action of removing a monitor, the kernel may not
+ * release all hardware resources that monitor used immediately if the
+ * cache occupancy value associated with 'removed' monitor is above this
+ * threshold. Once the cache occupancy is below this threshold, the
+ * underlying hardware resource will be reclaimed and be put into the
+ * resource pool for next reusing.*/
+unsigned int cache_reuse_threshold;
+/* The cache 'level' that has the monitor capability */
+unsigned int cache_level;
+};
+
 struct _virResctrlInfo {
 virObject parent;
 
@@ -146,6 +171,8 @@ struct _virResctrlInfo {
 size_t nlevels;
 
 virResctrlInfoMemBWPtr membw_info;
+
+virResctrlInfoMongrpPtr monitor_info;
 };
 
 
@@ -171,8 +198,12 @@ virResctrlInfoDispose(void *obj)
 VIR_FREE(level);
 }
 
+if (resctrl->monitor_info)
+VIR_FREE(resctrl->monitor_info->features);
+
 VIR_FREE(resctrl->membw_info);
 VIR_FREE(resctrl->levels);
+VIR_FREE(resctrl->monitor_info);
 }
 
 
@@ -555,6 +586,92 @@ virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr resctrl)
 }
 
 
+/*
+ * Retrieve monitor capability from the resource control file system.
+ *
+ * The monitor capability is exposed through "SYSFS_RESCTRL_PATH/info/L3_MON"
+ * directory under the resource control file system. The monitor capability is
+ * parsed by reading the interface files and stored in the structure
+ * 'virResctrlInfoMongrp'.
+ *
+ * Not all host supports the resource monitor, leave the pointer
+ * @resctrl->monitor_info empty if not supported.
+ */
+static int
+virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl)
+{
+int ret = -1;
+int rv = -1;
+char *featurestr = NULL;
+char **features = NULL;
+size_t nfeatures = 0;
+virResctrlInfoMongrpPtr info_monitor = NULL;
+
+if (VIR_ALLOC(info_monitor) < 0)
+return -1;
+
+/* monitor only exists in leve 3 cache */
+info_monitor->cache_level = 3;
+
+rv = virFileReadValueUint(_monitor->max_monitor,
+  SYSFS_RESCTRL_PATH "/info/L3_MON/num_rmids");
+if (rv == -2) {
+/* The file doesn't exist, so it's unusable for us, probably resource
+ * monitor unsupported */
+VIR_INFO("The path '" SYSFS_RESCTRL_PATH "/info/L3_MON/num_rmids' "
+ "does not exist");
+ret = 0;
+goto cleanup;
+} else if (rv < 0) {
+/* Other failures are fatal, so just quit */
+goto cleanup;
+}
+
+rv = virFileReadValueUint(_monitor->cache_reuse_threshold,
+  SYSFS_RESCTRL_PATH
+  "/info/L3_MON/max_threshold_occupancy");
+if (rv == -2) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Cannot get max_threshold_occupancy from resctrl"
+ " info"));
+}
+if (rv < 0)
+goto cleanup;
+
+rv = virFileReadValueString(,
+SYSFS_RESCTRL_PATH
+"/info/L3_MON/mon_features");
+if (rv == -2)
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Cannot get mon_features from resctrl info"));
+if (rv < 0)
+goto cleanup;
+
+if (!featurestr) {
+/* if no feature found in "/info/L3_MON/mon_features",
+ * some error happens */
+