[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC 13/16] tools: implemet get hw info flow for MBA.



This patch implements get HW info flow in tools for MBA.

Signed-off-by: Yi Sun <yi.y.sun@xxxxxxxxxxxxxxx>
---
 tools/libxc/include/xenctrl.h |  7 +++++++
 tools/libxc/xc_psr.c          | 14 +++++++++++++
 tools/libxl/libxl_psr.c       | 12 ++++++++++-
 tools/libxl/libxl_types.idl   |  6 ++++++
 tools/libxl/xl_cmdimpl.c      | 46 +++++++++++++++++++++++++++++++++++++++++--
 tools/libxl/xl_cmdtable.c     |  3 +++
 6 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 9233b86..ffd0f63 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2610,6 +2610,7 @@ enum xc_psr_feat_type {
     XC_PSR_FEAT_UNKNOWN    = 0,
     XC_PSR_FEAT_CAT_L3     = 1,
     XC_PSR_FEAT_CAT_L2     = 2,
+    XC_PSR_FEAT_MBA        = 3,
 };
 typedef enum xc_psr_feat_type xc_psr_feat_type;
 
@@ -2620,6 +2621,12 @@ struct xc_psr_hw_info {
             uint32_t cbm_len;
             bool     cdp_enabled;
         } xc_cat_info;
+
+        struct {
+            uint32_t cos_max;
+            uint32_t thrtl_max;
+            bool     linear;
+        } xc_mba_info;
     } u;
 };
 typedef struct xc_psr_hw_info xc_psr_hw_info;
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index a7ffb1b..381ef01 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -362,6 +362,20 @@ int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
                         XEN_SYSCTL_PSR_CAT_L3_CDP;
         }
         break;
+    case XC_PSR_FEAT_MBA:
+        sysctl.u.psr_alloc_op.cmd = XEN_SYSCTL_PSR_MBA_get_info;
+        rc = xc_sysctl(xch, &sysctl);
+        if ( !rc )
+        {
+            hw_info->u.xc_mba_info.cos_max =
+                        sysctl.u.psr_alloc_op.u.mba_info.cos_max;
+            hw_info->u.xc_mba_info.thrtl_max =
+                        sysctl.u.psr_alloc_op.u.mba_info.thrtl_max;
+            hw_info->u.xc_mba_info.linear =
+                        sysctl.u.psr_alloc_op.u.mba_info.linear &
+                        XEN_SYSCTL_PSR_MBA_LINEAR;
+        }
+        break;
     default:
         errno = EOPNOTSUPP;
         return rc;
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index 1245e1e..13d44b6 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -132,6 +132,9 @@ static void libxl__psr_hw_info_log_err_msg(libxl__gc *gc, 
int lvl,
         else
             feat = "L2 CAT";
         break;
+    case LIBXL_PSR_FEAT_TYPE_MBA_INFO:
+        feat = "MBA";
+        break;
     default:
         LOGE(ERROR, "Input type %d is wrong!\n", type);
         libxl__psr_log_err_msg(gc, err);
@@ -414,6 +417,8 @@ static inline xc_psr_feat_type 
libxl__psr_feat_type_to_libxc_psr_feat_type(
         if (lvl == 2)
             xc_type = XC_PSR_FEAT_CAT_L2;
         break;
+    case LIBXL_PSR_FEAT_TYPE_MBA_INFO:
+        xc_type = XC_PSR_FEAT_MBA;
     default:
         break;
     }
@@ -432,6 +437,11 @@ static inline int libxc__psr_hw_info_to_libxl_psr_hw_info(
         xl_hw_info->u.cat_info.cdp_enabled =
                                         xc_hw_info->u.xc_cat_info.cdp_enabled;
         break;
+    case LIBXL_PSR_FEAT_TYPE_MBA_INFO:
+        xl_hw_info->u.mba_info.cos_max = xc_hw_info->u.xc_mba_info.cos_max;
+        xl_hw_info->u.mba_info.thrtl_max = xc_hw_info->u.xc_mba_info.thrtl_max;
+        xl_hw_info->u.mba_info.linear = xc_hw_info->u.xc_mba_info.linear;
+        break;
     default:
         return -1;
     }
@@ -452,7 +462,7 @@ int libxl_psr_get_hw_info(libxl_ctx *ctx, libxl_psr_hw_info 
**info,
 
     libxl_bitmap_init(&socketmap);
 
-    if ( lvl != 3 && lvl != 2) {
+    if ( type == LIBXL_PSR_FEAT_TYPE_CAT_INFO && lvl != 3 && lvl != 2) {
         LOGE(ERROR, "input lvl %d is wrong!\n", lvl);
         rc = ERROR_FAIL;
         goto out;
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index a15d9ef..bd8d2b8 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -911,6 +911,7 @@ libxl_psr_cat_info = Struct("psr_cat_info", [
 
 libxl_psr_feat_type = Enumeration("psr_feat_type", [
     (1, "CAT_INFO"),
+    (2, "MBA_INFO"),
     ])
 
 libxl_psr_hw_info = Struct("psr_hw_info", [
@@ -921,5 +922,10 @@ libxl_psr_hw_info = Struct("psr_hw_info", [
                                           ("cbm_len",     uint32),
                                           ("cdp_enabled", bool),
                                    ])),
+            ("mba_info", Struct(None, [
+                                          ("cos_max",     uint32),
+                                          ("thrtl_max",   uint32),
+                                          ("linear",      bool),
+                                   ])),
            ]))
     ])
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 5bf56e8..21ef2cf 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -9521,6 +9521,38 @@ static int psr_l2_cat_hwinfo(void)
     return rc;
 }
 
+
+#ifdef LIBXL_HAVE_PSR_MBA
+static int psr_mba_hwinfo(void)
+{
+    int rc;
+    int i, nr;
+    libxl_psr_hw_info *info;
+
+    printf("Memory Bandwidth Allocation (MBA):\n");
+
+    rc = libxl_psr_get_hw_info(ctx, &info, &nr,
+                               LIBXL_PSR_FEAT_TYPE_MBA_INFO, 0);
+    if (rc) {
+        fprintf(stderr, "Failed to get mba info\n");
+        return rc;
+    }
+
+    for (i = 0; i < nr; i++) {
+        printf("%-16s: %u\n", "Socket ID", info[i].id);
+        printf("%-16s: %s\n", "Linear Mode",
+               info[i].u.mba_info.linear ? "Enabled" : "Disabled");
+        printf("%-16s: %u\n", "Maximum COS", info[i].u.mba_info.cos_max);
+        printf("%-16s: %u\n", "Maximum Throttling Value",
+               info[i].u.mba_info.thrtl_max);
+        printf("%-16s: %u\n", "Default Throttling Value", 0);
+    }
+
+    libxl_psr_hw_info_list_free(info, nr);
+    return rc;
+}
+#endif
+
 int main_psr_cat_cbm_set(int argc, char **argv)
 {
     uint32_t domid;
@@ -9635,20 +9667,24 @@ int main_psr_cat_show(int argc, char **argv)
 int main_psr_hwinfo(int argc, char **argv)
 {
     int opt, ret = 0;
-    bool all = true, cmt = false, cat = false;
+    bool all = true, cmt = false, cat = false, mba = false;
     static struct option opts[] = {
         {"cmt", 0, 0, 'm'},
         {"cat", 0, 0, 'a'},
+        {"mba", 0, 0, 'b'},
         COMMON_LONG_OPTS
     };
 
-    SWITCH_FOREACH_OPT(opt, "ma", opts, "psr-hwinfo", 0) {
+    SWITCH_FOREACH_OPT(opt, "mab", opts, "psr-hwinfo", 0) {
     case 'm':
         all = false; cmt = true;
         break;
     case 'a':
         all = false; cat = true;
         break;
+    case 'b':
+        all = false; mba = true;
+        break;
     }
 
     if (!ret && (all || cmt))
@@ -9661,6 +9697,12 @@ int main_psr_hwinfo(int argc, char **argv)
     if (all || cat)
         ret = psr_l2_cat_hwinfo();
 
+#ifdef LIBXL_HAVE_PSR_MBA
+    /* MBA is independent of CMT and CAT */
+    if (all || mba)
+        ret = psr_mba_hwinfo();
+#endif
+
     return ret;
 }
 
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index 32c3ee5..9e1ee6f 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -523,6 +523,9 @@ struct cmd_spec cmd_table[] = {
       "[options]",
       "-m, --cmt       Show Cache Monitoring Technology (CMT) hardware info\n"
       "-a, --cat       Show Cache Allocation Technology (CAT) hardware info\n"
+#ifdef LIBXL_HAVE_PSR_MBA
+      "-b, --mba       Show Memory Bandwidth Allocation (MBA) hardware info\n"
+#endif
     },
     { "psr-cmt-attach",
       &main_psr_cmt_attach, 0, 1,
-- 
1.9.1


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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.