From patchwork Tue Jan 10 07:42:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9506647 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 73D1E606E1 for ; Tue, 10 Jan 2017 07:45:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6752228156 for ; Tue, 10 Jan 2017 07:45:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BFC828485; Tue, 10 Jan 2017 07:45:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DA01628156 for ; Tue, 10 Jan 2017 07:45:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQr61-0004B2-Le; Tue, 10 Jan 2017 07:43:53 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQr60-00049G-L9 for xen-devel@lists.xenproject.org; Tue, 10 Jan 2017 07:43:52 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id 0A/A2-14551-7B094785; Tue, 10 Jan 2017 07:43:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPLMWRWlGSWpSXmKPExsVywNykWHf7hJI Ig0ULeSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy3a3sYC65aV8x6f46pgfGoVhcjJ4eQQKXE /vMvmEFsCQFeiSPLZrBC2P4SjYtageJcQDUNjBIb9v9nB0mwCahLPP7awwRiiwgoSdxbNZkJp IhZYD+jxPzjx8EmCQvYSUz9PZMRxGYRUJV4NmkX2FReAQ+JFxuOMkFskJM4eWwyWJwTKN5ydR 0jxEXuEs1v7zNOYORdwMiwilGjOLWoLLVI19hAL6koMz2jJDcxM0fX0MBYLze1uDgxPTUnMal YLzk/dxMjMCDqGRgYdzB2nvA7xCjJwaQkypuiWxIhxJeUn1KZkVicEV9UmpNafIhRhoNDSYK3 qh8oJ1iUmp5akZaZAwxNmLQEB4+SCC8LSJq3uCAxtzgzHSJ1ilFRSpw3ECQhAJLIKM2Da4PFw yVGWSlhXkYGBgYhnoLUotzMElT5V4ziHIxKwryuIFN4MvNK4Ka/AlrMBLQ40q4YZHFJIkJKqo GR9U7BFrZMV939nFu/vWNbIdbZ9GF7ysn4i2rVhrVPu3c8qEsRCz2ianK86tLjhS2HTiTuWBn +yD2EYffflg0hJcJyTZ0SG/tdfM0+ury0sv1e9dr2zlbnz2Xf+S7yn0ietlFScM7jjfpX0+tY n+9dw1nWvPh9ypmDiVfbI04XFqR7uc1LfrNUiaU4I9FQi7moOBEA5pXu+YICAAA= X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1484034224!62972679!3 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33339 invoked from network); 10 Jan 2017 07:43:50 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-12.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 10 Jan 2017 07:43:50 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 09 Jan 2017 23:43:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,343,1477983600"; d="scan'208";a="211583260" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.63]) by fmsmga004.fm.intel.com with ESMTP; 09 Jan 2017 23:43:48 -0800 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Tue, 10 Jan 2017 15:42:32 +0800 Message-Id: <1484034155-4521-14-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1484034155-4521-1-git-send-email-yi.y.sun@linux.intel.com> References: <1484034155-4521-1-git-send-email-yi.y.sun@linux.intel.com> Cc: wei.liu2@citrix.com, he.chen@linux.intel.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, Yi Sun , jbeulich@suse.com, chao.p.peng@linux.intel.com Subject: [Xen-devel] [RFC 13/16] tools: implemet get hw info flow for MBA. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch implements get HW info flow in tools for MBA. Signed-off-by: Yi Sun --- 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,