diff mbox

[v4,22/24] tools: L2 CAT: support show cbm for L2 CAT.

Message ID 1481688484-5093-23-git-send-email-yi.y.sun@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yi Sun Dec. 14, 2016, 4:08 a.m. UTC
This patch implements changes in xl/xc changes to support
showing CBM of L2 CAT.

The new level option is introduced to original CAT showing
command in order to show CBM for specified level CAT.
- 'xl psr-cat-show' is updated to show CBM of a domain
  according to input cache level.

Examples:
root@:~$ xl psr-cat-show -l2 1
Socket ID       : 0
Default CBM     : 0xff
   ID                     NAME             CBM
    1                 ubuntu14            0x7f

Signed-off-by: He Chen <he.chen@linux.intel.com>
Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
---
 tools/libxc/include/xenctrl.h |  1 +
 tools/libxc/xc_psr.c          |  3 ++
 tools/libxl/libxl_types.idl   |  1 +
 tools/libxl/xl_cmdimpl.c      | 81 ++++++++++++++++++++++++++++---------------
 tools/libxl/xl_cmdtable.c     |  3 +-
 5 files changed, 60 insertions(+), 29 deletions(-)

Comments

Wei Liu Jan. 6, 2017, 12:04 p.m. UTC | #1
On Wed, Dec 14, 2016 at 12:08:02PM +0800, Yi Sun wrote:
> This patch implements changes in xl/xc changes to support
> showing CBM of L2 CAT.
> 
> The new level option is introduced to original CAT showing
> command in order to show CBM for specified level CAT.
> - 'xl psr-cat-show' is updated to show CBM of a domain
>   according to input cache level.
> 
> Examples:
> root@:~$ xl psr-cat-show -l2 1
> Socket ID       : 0
> Default CBM     : 0xff
>    ID                     NAME             CBM
>     1                 ubuntu14            0x7f
> 
> Signed-off-by: He Chen <he.chen@linux.intel.com>
> Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
> ---
>  tools/libxc/include/xenctrl.h |  1 +
>  tools/libxc/xc_psr.c          |  3 ++
>  tools/libxl/libxl_types.idl   |  1 +
>  tools/libxl/xl_cmdimpl.c      | 81 ++++++++++++++++++++++++++++---------------
>  tools/libxl/xl_cmdtable.c     |  3 +-
>  5 files changed, 60 insertions(+), 29 deletions(-)
> 
> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> index 5b7df22..c1675d8 100644
> --- a/tools/libxc/include/xenctrl.h
> +++ b/tools/libxc/include/xenctrl.h
> @@ -2602,6 +2602,7 @@ enum xc_psr_cat_type {
>      XC_PSR_CAT_L3_CBM      = 1,
>      XC_PSR_CAT_L3_CBM_CODE = 2,
>      XC_PSR_CAT_L3_CBM_DATA = 3,
> +    XC_PSR_CAT_L2_CBM      = 4,
>  };
>  typedef enum xc_psr_cat_type xc_psr_cat_type;
>  
> diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
> index 7af17d9..fe494b0 100644
> --- a/tools/libxc/xc_psr.c
> +++ b/tools/libxc/xc_psr.c
> @@ -299,6 +299,9 @@ int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
>      case XC_PSR_CAT_L3_CBM_DATA:
>          cmd = XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA;
>          break;
> +    case XC_PSR_CAT_L2_CBM:
> +        cmd = XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM;
> +        break;
>      default:
>          errno = EINVAL;
>          return -1;
> diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> index a32c751..944b7d4 100644
> --- a/tools/libxl/libxl_types.idl
> +++ b/tools/libxl/libxl_types.idl
> @@ -898,6 +898,7 @@ libxl_psr_cbm_type = Enumeration("psr_cbm_type", [
>      (1, "L3_CBM"),
>      (2, "L3_CBM_CODE"),
>      (3, "L3_CBM_DATA"),
> +    (4, "L2_CBM"),

Need a LIBXL_HAVE macro.

And a very stupid question: where is the libxl code to use this?

Wei.
Yi Sun Jan. 9, 2017, 1:24 a.m. UTC | #2
On 17-01-06 12:04:43, Wei Liu wrote:
> On Wed, Dec 14, 2016 at 12:08:02PM +0800, Yi Sun wrote:
> > - 'xl psr-cat-show' is updated to show CBM of a domain
> >   according to input cache level.
> > 
> > Examples:
> > root@:~$ xl psr-cat-show -l2 1
> > Socket ID       : 0
> > Default CBM     : 0xff
> >    ID                     NAME             CBM
> >     1                 ubuntu14            0x7f
> > 
> > Signed-off-by: He Chen <he.chen@linux.intel.com>
> > Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
> > ---
> >  tools/libxc/include/xenctrl.h |  1 +
> >  tools/libxc/xc_psr.c          |  3 ++
> >  tools/libxl/libxl_types.idl   |  1 +
> >  tools/libxl/xl_cmdimpl.c      | 81 ++++++++++++++++++++++++++++---------------
> >  tools/libxl/xl_cmdtable.c     |  3 +-
> >  5 files changed, 60 insertions(+), 29 deletions(-)
> > 
> > diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> > index a32c751..944b7d4 100644
> > --- a/tools/libxl/libxl_types.idl
> > +++ b/tools/libxl/libxl_types.idl
> > @@ -898,6 +898,7 @@ libxl_psr_cbm_type = Enumeration("psr_cbm_type", [
> >      (1, "L3_CBM"),
> >      (2, "L3_CBM_CODE"),
> >      (3, "L3_CBM_DATA"),
> > +    (4, "L2_CBM"),
> 
> Need a LIBXL_HAVE macro.
> 
It has been defined in pathc 21, like below.
tools/libxl/libxl.h
#define LIBXL_HAVE_PSR_L2_CAT 1

> And a very stupid question: where is the libxl code to use this?
> 
> Wei.

L2_CBM is used in xl_cmdimpl.c, like below.
static void psr_cat_print_one_domain_cbm(uint32_t domid, uint32_t socketid,
                                         bool cdp_enabled, unsigned int lvl)
{
......
    case 2:
        psr_cat_print_one_domain_cbm_type(domid, socketid,
                                          LIBXL_PSR_CBM_TYPE_L2_CBM);
......
}

int main_psr_cat_cbm_set(int argc, char **argv)
{
......
    if (lvl == 2)
        type = LIBXL_PSR_CBM_TYPE_L2_CBM;
......
}

Thanks,
Sun Yi
Wei Liu Jan. 9, 2017, 10:08 a.m. UTC | #3
On Mon, Jan 09, 2017 at 09:24:54AM +0800, Yi Sun wrote:
> On 17-01-06 12:04:43, Wei Liu wrote:
> > On Wed, Dec 14, 2016 at 12:08:02PM +0800, Yi Sun wrote:
> > > - 'xl psr-cat-show' is updated to show CBM of a domain
> > >   according to input cache level.
> > > 
> > > Examples:
> > > root@:~$ xl psr-cat-show -l2 1
> > > Socket ID       : 0
> > > Default CBM     : 0xff
> > >    ID                     NAME             CBM
> > >     1                 ubuntu14            0x7f
> > > 
> > > Signed-off-by: He Chen <he.chen@linux.intel.com>
> > > Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
> > > ---
> > >  tools/libxc/include/xenctrl.h |  1 +
> > >  tools/libxc/xc_psr.c          |  3 ++
> > >  tools/libxl/libxl_types.idl   |  1 +
> > >  tools/libxl/xl_cmdimpl.c      | 81 ++++++++++++++++++++++++++++---------------
> > >  tools/libxl/xl_cmdtable.c     |  3 +-
> > >  5 files changed, 60 insertions(+), 29 deletions(-)
> > > 
> > > diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> > > index a32c751..944b7d4 100644
> > > --- a/tools/libxl/libxl_types.idl
> > > +++ b/tools/libxl/libxl_types.idl
> > > @@ -898,6 +898,7 @@ libxl_psr_cbm_type = Enumeration("psr_cbm_type", [
> > >      (1, "L3_CBM"),
> > >      (2, "L3_CBM_CODE"),
> > >      (3, "L3_CBM_DATA"),
> > > +    (4, "L2_CBM"),
> > 
> > Need a LIBXL_HAVE macro.
> > 
> It has been defined in pathc 21, like below.
> tools/libxl/libxl.h
> #define LIBXL_HAVE_PSR_L2_CAT 1
> 

In that case please move this to patch #21.

Wei.
Yi Sun Jan. 10, 2017, 7:47 a.m. UTC | #4
On 17-01-09 10:08:04, Wei Liu wrote:
> On Mon, Jan 09, 2017 at 09:24:54AM +0800, Yi Sun wrote:
> > On 17-01-06 12:04:43, Wei Liu wrote:
> > > On Wed, Dec 14, 2016 at 12:08:02PM +0800, Yi Sun wrote:
> > > > diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> > > > index a32c751..944b7d4 100644
> > > > --- a/tools/libxl/libxl_types.idl
> > > > +++ b/tools/libxl/libxl_types.idl
> > > > @@ -898,6 +898,7 @@ libxl_psr_cbm_type = Enumeration("psr_cbm_type", [
> > > >      (1, "L3_CBM"),
> > > >      (2, "L3_CBM_CODE"),
> > > >      (3, "L3_CBM_DATA"),
> > > > +    (4, "L2_CBM"),
> > > 
> > > Need a LIBXL_HAVE macro.
> > > 
> > It has been defined in pathc 21, like below.
> > tools/libxl/libxl.h
> > #define LIBXL_HAVE_PSR_L2_CAT 1
> > 
> 
> In that case please move this to patch #21.
> 
> Wei.

Thank you! Will move it to previous patch with the macro together.

BRs,
Sun Yi
diff mbox

Patch

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 5b7df22..c1675d8 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2602,6 +2602,7 @@  enum xc_psr_cat_type {
     XC_PSR_CAT_L3_CBM      = 1,
     XC_PSR_CAT_L3_CBM_CODE = 2,
     XC_PSR_CAT_L3_CBM_DATA = 3,
+    XC_PSR_CAT_L2_CBM      = 4,
 };
 typedef enum xc_psr_cat_type xc_psr_cat_type;
 
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index 7af17d9..fe494b0 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -299,6 +299,9 @@  int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
     case XC_PSR_CAT_L3_CBM_DATA:
         cmd = XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA;
         break;
+    case XC_PSR_CAT_L2_CBM:
+        cmd = XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM;
+        break;
     default:
         errno = EINVAL;
         return -1;
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index a32c751..944b7d4 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -898,6 +898,7 @@  libxl_psr_cbm_type = Enumeration("psr_cbm_type", [
     (1, "L3_CBM"),
     (2, "L3_CBM_CODE"),
     (3, "L3_CBM_DATA"),
+    (4, "L2_CBM"),
     ])
 
 libxl_psr_cat_info = Struct("psr_cat_info", [
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index c210b05..4d6f32a 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -9381,7 +9381,7 @@  static void psr_cat_print_one_domain_cbm_type(uint32_t domid, uint32_t socketid,
 }
 
 static void psr_cat_print_one_domain_cbm(uint32_t domid, uint32_t socketid,
-                                         bool cdp_enabled)
+                                         bool cdp_enabled, unsigned int lvl)
 {
     char *domain_name;
 
@@ -9389,27 +9389,38 @@  static void psr_cat_print_one_domain_cbm(uint32_t domid, uint32_t socketid,
     printf("%5d%25s", domid, domain_name);
     free(domain_name);
 
-    if (!cdp_enabled) {
-        psr_cat_print_one_domain_cbm_type(domid, socketid,
-                                          LIBXL_PSR_CBM_TYPE_L3_CBM);
-    } else {
-        psr_cat_print_one_domain_cbm_type(domid, socketid,
-                                          LIBXL_PSR_CBM_TYPE_L3_CBM_CODE);
+    switch (lvl) {
+    case 3:
+        if (!cdp_enabled) {
+            psr_cat_print_one_domain_cbm_type(domid, socketid,
+                                              LIBXL_PSR_CBM_TYPE_L3_CBM);
+        } else {
+            psr_cat_print_one_domain_cbm_type(domid, socketid,
+                                              LIBXL_PSR_CBM_TYPE_L3_CBM_CODE);
+            psr_cat_print_one_domain_cbm_type(domid, socketid,
+                                              LIBXL_PSR_CBM_TYPE_L3_CBM_DATA);
+        }
+        break;
+    case 2:
         psr_cat_print_one_domain_cbm_type(domid, socketid,
-                                          LIBXL_PSR_CBM_TYPE_L3_CBM_DATA);
+                                          LIBXL_PSR_CBM_TYPE_L2_CBM);
+        break;
+    default:
+        printf("Input lvl %d is wrong!", lvl);
+        break;
     }
 
     printf("\n");
 }
 
 static int psr_cat_print_domain_cbm(uint32_t domid, uint32_t socketid,
-                                    bool cdp_enabled)
+                                    bool cdp_enabled, unsigned int lvl)
 {
     int i, nr_domains;
     libxl_dominfo *list;
 
     if (domid != INVALID_DOMID) {
-        psr_cat_print_one_domain_cbm(domid, socketid, cdp_enabled);
+        psr_cat_print_one_domain_cbm(domid, socketid, cdp_enabled, lvl);
         return 0;
     }
 
@@ -9419,49 +9430,55 @@  static int psr_cat_print_domain_cbm(uint32_t domid, uint32_t socketid,
     }
 
     for (i = 0; i < nr_domains; i++)
-        psr_cat_print_one_domain_cbm(list[i].domid, socketid, cdp_enabled);
+        psr_cat_print_one_domain_cbm(list[i].domid, socketid, cdp_enabled, lvl);
     libxl_dominfo_list_free(list, nr_domains);
 
     return 0;
 }
 
-static int psr_cat_print_socket(uint32_t domid, libxl_psr_cat_info *info)
+static int psr_cat_print_socket(uint32_t domid, libxl_psr_cat_info *info,
+                                unsigned int lvl)
 {
     int rc;
     uint32_t l3_cache_size;
 
-    rc = libxl_psr_cmt_get_l3_cache_size(ctx, info->id, &l3_cache_size);
-    if (rc) {
-        fprintf(stderr, "Failed to get l3 cache size for socket:%d\n",
-                info->id);
-        return -1;
+    printf("%-16s: %u\n", "Socket ID", info->id);
+
+    /* So far, CMT only supports L3 cache. */
+    if (lvl == 3)
+    {
+        rc = libxl_psr_cmt_get_l3_cache_size(ctx, info->id, &l3_cache_size);
+        if (rc) {
+            fprintf(stderr, "Failed to get l3 cache size for socket:%d\n",
+                    info->id);
+            return -1;
+        }
+        printf("%-16s: %uKB\n", "L3 Cache", l3_cache_size);
     }
 
-    printf("%-16s: %u\n", "Socket ID", info->id);
-    printf("%-16s: %uKB\n", "L3 Cache", l3_cache_size);
     printf("%-16s: %#llx\n", "Default CBM", (1ull << info->cbm_len) - 1);
     if (info->cdp_enabled)
         printf("%5s%25s%16s%16s\n", "ID", "NAME", "CBM (code)", "CBM (data)");
     else
         printf("%5s%25s%16s\n", "ID", "NAME", "CBM");
 
-    return psr_cat_print_domain_cbm(domid, info->id, info->cdp_enabled);
+    return psr_cat_print_domain_cbm(domid, info->id, info->cdp_enabled, lvl);
 }
 
-static int psr_cat_show(uint32_t domid)
+static int psr_cat_show(uint32_t domid, unsigned int lvl)
 {
     int i, nr;
     int rc;
     libxl_psr_cat_info *info;
 
-    rc = libxl_psr_cat_get_info(ctx, &info, &nr, 3);
+    rc = libxl_psr_cat_get_info(ctx, &info, &nr, lvl);
     if (rc) {
-        fprintf(stderr, "Failed to get cat info\n");
+        fprintf(stderr, "Failed to get %s cat info\n", (lvl == 3)?"L3":"L2");
         return rc;
     }
 
     for (i = 0; i < nr; i++) {
-        rc = psr_cat_print_socket(domid, info + i);
+        rc = psr_cat_print_socket(domid, info + i, lvl);
         if (rc)
             goto out;
     }
@@ -9574,11 +9591,19 @@  int main_psr_cat_cbm_set(int argc, char **argv)
 
 int main_psr_cat_show(int argc, char **argv)
 {
-    int opt;
+    int opt = 0;
     uint32_t domid;
+    unsigned int lvl = 3;
 
-    SWITCH_FOREACH_OPT(opt, "", NULL, "psr-cat-show", 0) {
-        /* No options */
+    static struct option opts[] = {
+        {"level", 1, 0, 'l'},
+        COMMON_LONG_OPTS
+    };
+
+    SWITCH_FOREACH_OPT(opt, "l:", opts, "psr-cat-show", 0) {
+    case 'l':
+        lvl = atoi(optarg);
+        break;
     }
 
     if (optind >= argc)
@@ -9590,7 +9615,7 @@  int main_psr_cat_show(int argc, char **argv)
         return 2;
     }
 
-    return psr_cat_show(domid);
+    return psr_cat_show(domid, lvl);
 }
 
 int main_psr_hwinfo(int argc, char **argv)
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index 588d5d9..c5fbad4 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -556,7 +556,8 @@  struct cmd_spec cmd_table[] = {
     { "psr-cat-show",
       &main_psr_cat_show, 0, 1,
       "Show Cache Allocation Technology information",
-      "<Domain>",
+      "[options] <Domain>",
+      "-l <level>        Specify the cache level to process, otherwise L3 cache is processed\n"
     },
 
 #endif