From: Yi Sun <yi.y.sun@linux.intel.com>
To: xen-devel@lists.xenproject.org
Cc: wei.liu2@citrix.com, he.chen@linux.intel.com,
andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com,
Yi Sun <yi.y.sun@linux.intel.com>,
jbeulich@suse.com, chao.p.peng@linux.intel.com
Subject: [RFC 13/16] tools: implemet get hw info flow for MBA.
Date: Tue, 10 Jan 2017 15:42:32 +0800 [thread overview]
Message-ID: <1484034155-4521-14-git-send-email-yi.y.sun@linux.intel.com> (raw)
In-Reply-To: <1484034155-4521-1-git-send-email-yi.y.sun@linux.intel.com>
This patch implements get HW info flow in tools for MBA.
Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
---
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@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-01-10 7:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-10 7:42 [RFC 00/16] Enable Memory Bandwidth Allocation in Xen Yi Sun
2017-01-10 7:42 ` [RFC 01/16] docs: create Memory Bandwidth Allocation (MBA) feature document Yi Sun
2017-02-23 20:46 ` Meng Xu
2017-02-24 5:07 ` Yi Sun
2017-02-24 15:53 ` Meng Xu
2017-02-27 4:39 ` Yi Sun
2017-01-10 7:42 ` [RFC 02/16] Rename sysctl/domctl interface and xsm policy to make them general Yi Sun
2017-01-10 7:42 ` [RFC 03/16] x86: change 'cbm_type' to 'psr_val_type' to make it general Yi Sun
2017-01-10 7:42 ` [RFC 04/16] x86: implement data structure of MBA Yi Sun
2017-01-10 7:42 ` [RFC 05/16] x86: parse config parameters for MBA Yi Sun
2017-01-10 7:42 ` [RFC 06/16] x86: implement init flow " Yi Sun
2017-01-10 7:42 ` [RFC 07/16] x86: implement get hw info " Yi Sun
2017-01-10 7:42 ` [RFC 08/16] x86: implement get value " Yi Sun
2017-01-10 7:42 ` [RFC 09/16] x86: implement set " Yi Sun
2017-01-10 7:42 ` [RFC 10/16] tools: refactor codes to make get hw info interface be general Yi Sun
2017-01-10 7:42 ` [RFC 11/16] tools: refactor codes to make get val be more general Yi Sun
2017-01-10 7:42 ` [RFC 12/16] tools: refactor codes to make set " Yi Sun
2017-01-10 7:42 ` Yi Sun [this message]
2017-01-10 7:42 ` [RFC 14/16] tools: implemet get value flow for MBA Yi Sun
2017-01-10 7:42 ` [RFC 15/16] tools: implemet set " Yi Sun
2017-01-10 7:42 ` [RFC 16/16] docs: add MBA description in docs Yi Sun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1484034155-4521-14-git-send-email-yi.y.sun@linux.intel.com \
--to=yi.y.sun@linux.intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=chao.p.peng@linux.intel.com \
--cc=he.chen@linux.intel.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).