Re: [Xen-devel] [PATCH v1 11/13] tools: implemet new get value interface suitable for all psr allocation features

2017-08-22 Thread Chao Peng
On Tue, 2017-08-22 at 10:24 +0800, Yi Sun wrote:
> On 17-08-21 18:14:49, Chao Peng wrote:
> > 
> > 
> > > 
> > >  
> > > -static void libxl__psr_cat_log_err_msg(libxl__gc *gc, int err)
> > > +static void libxl__psr_alloc_log_err_msg(libxl__gc *gc,
> > > + int err,
> > > + libxl_psr_cbm_type type)
> > >  {
> > > +/*
> > > + * Index is 'libxl_psr_cbm_type' so we set two 'CDP' to
> > > correspond to
> > > + * DATA and CODE.
> > > + */
> > 
> > Or just use "CDP CODE" and "CDP DATA" respectively?
> > 
> They are just value type but not feature name. So, I duplicate 'CDP'
> here.

I'm fine.

Chao
> 
> > 
> > > 
> > > +const char * const feat_name[6] = {
> > > +"UNKNOWN",
> > > +"L3 CAT",
> > > +"CDP",
> > > +"CDP",
> > > +"L2 CAT",
> > > +"MBA",
> > > +};
> > >  char *msg;
> > >  

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v1 11/13] tools: implemet new get value interface suitable for all psr allocation features

2017-08-21 Thread Yi Sun
On 17-08-21 18:14:49, Chao Peng wrote:
> 
> >  
> > -static void libxl__psr_cat_log_err_msg(libxl__gc *gc, int err)
> > +static void libxl__psr_alloc_log_err_msg(libxl__gc *gc,
> > + int err,
> > + libxl_psr_cbm_type type)
> >  {
> > +/*
> > + * Index is 'libxl_psr_cbm_type' so we set two 'CDP' to
> > correspond to
> > + * DATA and CODE.
> > + */
> 
> Or just use "CDP CODE" and "CDP DATA" respectively?
> 
They are just value type but not feature name. So, I duplicate 'CDP'
here.

> > +const char * const feat_name[6] = {
> > +"UNKNOWN",
> > +"L3 CAT",
> > +"CDP",
> > +"CDP",
> > +"L2 CAT",
> > +"MBA",
> > +};
> >  char *msg;
> >  

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v1 11/13] tools: implemet new get value interface suitable for all psr allocation features

2017-08-21 Thread Chao Peng

>  
> -static void libxl__psr_cat_log_err_msg(libxl__gc *gc, int err)
> +static void libxl__psr_alloc_log_err_msg(libxl__gc *gc,
> + int err,
> + libxl_psr_cbm_type type)
>  {
> +/*
> + * Index is 'libxl_psr_cbm_type' so we set two 'CDP' to
> correspond to
> + * DATA and CODE.
> + */

Or just use "CDP CODE" and "CDP DATA" respectively?

> +const char * const feat_name[6] = {
> +"UNKNOWN",
> +"L3 CAT",
> +"CDP",
> +"CDP",
> +"L2 CAT",
> +"MBA",
> +};
>  char *msg;
>  

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v1 11/13] tools: implemet new get value interface suitable for all psr allocation features

2017-08-15 Thread Wei Liu
On Wed, Aug 09, 2017 at 03:41:50PM +0800, Yi Sun wrote:
> This patch implements a new get value interface in tools suitable for all psr
> allocation features and the whole flow. It also enables MBA support in tools
> to get MBA value.
> 
> Signed-off-by: Yi Sun 

Again, I would appreciate you write down what is done in this patch in
the commit message.

Luckily this patch doesn't look too complex so:

Acked-by: Wei Liu 

I would also like an ack or review from Chao on the xl bits, to confirm
he is okay with the command line interface.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v1 11/13] tools: implemet new get value interface suitable for all psr allocation features

2017-08-09 Thread Yi Sun
This patch implements a new get value interface in tools suitable for all psr
allocation features and the whole flow. It also enables MBA support in tools
to get MBA value.

Signed-off-by: Yi Sun 
---
 tools/libxc/include/xenctrl.h |   7 +-
 tools/libxc/xc_psr.c  |   9 ++-
 tools/libxl/libxl_psr.c   |  51 +++-
 tools/xl/xl.h |   1 +
 tools/xl/xl_cmdtable.c|   5 ++
 tools/xl/xl_psr.c | 179 +-
 6 files changed, 173 insertions(+), 79 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index f1c629e..d7eabfb 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2455,6 +2455,7 @@ enum xc_psr_val_type {
 XC_PSR_CAT_L3_CBM_CODE = 2,
 XC_PSR_CAT_L3_CBM_DATA = 3,
 XC_PSR_CAT_L2_CBM  = 4,
+XC_PSR_MBA_THRTL   = 5,
 };
 typedef enum xc_psr_val_type xc_psr_val_type;
 
@@ -2501,9 +2502,9 @@ int xc_psr_cmt_enabled(xc_interface *xch);
 int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
xc_psr_val_type type, uint32_t target,
uint64_t data);
-int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
-   xc_psr_val_type type, uint32_t target,
-   uint64_t *data);
+int xc_psr_get_domain_data(xc_interface *xch, uint32_t domid,
+   xc_psr_val_type type, uint32_t target,
+   uint64_t *data);
 int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
xc_psr_feat_type type, xc_psr_hw_info *hw_info);
 
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index c69e943..de501b0 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -283,9 +283,9 @@ int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t 
domid,
 return do_domctl(xch, );
 }
 
-int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
-   xc_psr_val_type type, uint32_t target,
-   uint64_t *data)
+int xc_psr_get_domain_data(xc_interface *xch, uint32_t domid,
+   xc_psr_val_type type, uint32_t target,
+   uint64_t *data)
 {
 int rc;
 DECLARE_DOMCTL;
@@ -305,6 +305,9 @@ int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t 
domid,
 case XC_PSR_CAT_L2_CBM:
 cmd = XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM;
 break;
+case XC_PSR_MBA_THRTL:
+cmd = XEN_DOMCTL_PSR_MBA_OP_GET_THRTL;
+break;
 default:
 errno = EINVAL;
 return -1;
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index 1d75f33..4b91e9b 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -71,16 +71,30 @@ static void libxl__psr_cmt_log_err_msg(libxl__gc *gc, int 
err)
 LOGE(ERROR, "%s", msg);
 }
 
-static void libxl__psr_cat_log_err_msg(libxl__gc *gc, int err)
+static void libxl__psr_alloc_log_err_msg(libxl__gc *gc,
+ int err,
+ libxl_psr_cbm_type type)
 {
+/*
+ * Index is 'libxl_psr_cbm_type' so we set two 'CDP' to correspond to
+ * DATA and CODE.
+ */
+const char * const feat_name[6] = {
+"UNKNOWN",
+"L3 CAT",
+"CDP",
+"CDP",
+"L2 CAT",
+"MBA",
+};
 char *msg;
 
 switch (err) {
 case ENODEV:
-msg = "CAT is not supported in this system";
+msg = "is not supported in this system";
 break;
 case ENOENT:
-msg = "CAT is not enabled on the socket";
+msg = "is not enabled on the socket";
 break;
 case EOVERFLOW:
 msg = "no free COS available";
@@ -106,7 +120,7 @@ static void libxl__psr_cat_log_err_msg(libxl__gc *gc, int 
err)
 return;
 }
 
-LOGE(ERROR, "%s", msg);
+LOGE(ERROR, "%s: %s", feat_name[type], msg);
 }
 
 static int libxl__pick_socket_cpu(libxl__gc *gc, uint32_t socketid)
@@ -333,7 +347,7 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
 xc_type = libxl__psr_cbm_type_to_libxc_psr_val_type(type);
 if (xc_psr_cat_set_domain_data(ctx->xch, domid, xc_type,
socketid, cbm)) {
-libxl__psr_cat_log_err_msg(gc, errno);
+libxl__psr_alloc_log_err_msg(gc, errno, type);
 rc = ERROR_FAIL;
 }
 }
@@ -347,18 +361,7 @@ int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
   libxl_psr_cbm_type type, uint32_t target,
   uint64_t *cbm_r)
 {
-GC_INIT(ctx);
-int rc = 0;
-xc_psr_val_type xc_type = libxl__psr_cbm_type_to_libxc_psr_val_type(type);
-
-if (xc_psr_cat_get_domain_data(ctx->xch, domid, xc_type,
-   target, cbm_r)) {
-