From patchwork Tue Aug 1 08:48:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9873887 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 E36C260365 for ; Tue, 1 Aug 2017 09:06:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E97DB2582C for ; Tue, 1 Aug 2017 09:06:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB8BA28670; Tue, 1 Aug 2017 09:06:55 +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 27EFA2582C for ; Tue, 1 Aug 2017 09:06:55 +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 1dcT72-0005qG-4i; Tue, 01 Aug 2017 09:05:12 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dcT70-0005nL-Ny for xen-devel@lists.xenproject.org; Tue, 01 Aug 2017 09:05:10 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 55/37-01732-54440895; Tue, 01 Aug 2017 09:05:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPLMWRWlGSWpSXmKPExsXS1tYhouvq0hB psPGwqMX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmnF88y6mgosOFU8bzjI1MO7U62Lk4hASmMYo caf9PHsXIyeHhACvxJFlM1ghbH+JOR+OMYLYQgINjBKXDteA2GwC6hKPv/YwgdgiAkoS91ZNZ gIZxCxwmEni+q0vYM3CAm4SC0+tBRvKIqAqsfnhSrAGXgEPiT1XOpghFshJnDw2GayeEyi+4+ YNoDgH0DJ3iZ0zEycw8i5gZFjFqF6cWlSWWqRrqpdUlJmeUZKbmJmja2hgqpebWlycmJ6ak5h UrJecn7uJERgMDECwg/FLv/MhRkkOJiVRXsWe+kghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErwS zg2RQoJFqempFWmZOcCwhElLcPAoifBecAJK8xYXJOYWZ6ZDpE4xGnNsWL3+CxPHqwn/vzEJs eTl56VKifNeBCkVACnNKM2DGwSLl0uMslLCvIxApwnxFKQW5WaWoMq/YhTnYFQS5pUFuYcnM6 8Ebt8roFOYgE6RLK0FOaUkESEl1cBoO2/P8nU79Y99UnuV83LrvLrtJw0erZq4aMI/7arJRz4 terlYMPzqttPbpOZVaPs3Gt1WTi00frAnadZJZfdgVxYD5dySSUt4qtjehOziSGcKj6h5YTAx Pps7P8nYL+nQ9S/3FlyN3t6T9pRnhqaOPc/dRr3FXu8amWt5DTr4y5iLJKeeL2VRYinOSDTUY i4qTgQA2SS0I5ICAAA= X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1501578248!89431283!22 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57249 invoked from network); 1 Aug 2017 09:05:08 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-16.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Aug 2017 09:05:08 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Aug 2017 02:05:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,305,1498546800"; d="scan'208";a="118061845" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.80]) by orsmga002.jf.intel.com with ESMTP; 01 Aug 2017 02:05:05 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Tue, 1 Aug 2017 16:48:52 +0800 Message-Id: <1501577334-7431-22-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501577334-7431-1-git-send-email-yi.y.sun@linux.intel.com> References: <1501577334-7431-1-git-send-email-yi.y.sun@linux.intel.com> Cc: kevin.tian@intel.com, wei.liu2@citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, He Chen , ian.jackson@eu.citrix.com, Yi Sun , mengxu@cis.upenn.edu, jbeulich@suse.com, chao.p.peng@linux.intel.com, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v15 21/23] tools: L2 CAT: support show cbm for L2 CAT. 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 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 Signed-off-by: Yi Sun Acked-by: Wei Liu --- v9: - move xl_cmdimpl.c changes into xl/xl_psr.c. - move xl_cmdtable.c changes into xl/xl_cmdtable.c. v6: - check if input level is correct. - adjust '{' postion for 'if'. (suggested by Wei Liu) v5: - remove 'L2_CBM' in idl because it has been moved to patch 21: "tools: L2 CAT: support get HW info for L2 CAT". (suggested by Wei Liu) v4: - create this patch because of codes architecture change. --- tools/libxc/include/xenctrl.h | 1 + tools/libxc/xc_psr.c | 3 ++ tools/xl/xl_cmdtable.c | 3 +- tools/xl/xl_psr.c | 85 +++++++++++++++++++++++++++++-------------- 4 files changed, 63 insertions(+), 29 deletions(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index d88642e..c7710b8 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -2454,6 +2454,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 84a08c4..04f5927 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/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 30eb93c..539cb64 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -557,7 +557,8 @@ struct cmd_spec cmd_table[] = { { "psr-cat-show", &main_psr_cat_show, 0, 1, "Show Cache Allocation Technology information", - "", + "[options] ", + "-l Specify the cache level to process, otherwise L3 cache is processed\n" }, #endif diff --git a/tools/xl/xl_psr.c b/tools/xl/xl_psr.c index 271b88f..575f4a0 100644 --- a/tools/xl/xl_psr.c +++ b/tools/xl/xl_psr.c @@ -342,7 +342,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; @@ -350,27 +350,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; } @@ -380,49 +391,59 @@ 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); + if (lvl != 2 && lvl != 3) { + fprintf(stderr, "Input lvl %d is wrong\n", lvl); + return EXIT_FAILURE; + } + + 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; } @@ -533,11 +554,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) @@ -549,7 +578,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)