From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: [RFC PATCH 7/7] xl: allow for attaching and detaching a CPU to CMT Date: Sat, 04 Apr 2015 04:15:14 +0200 Message-ID: <20150404021514.22875.55856.stgit@Solace.station> References: <20150404020423.22875.23590.stgit@Solace.station> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150404020423.22875.23590.stgit@Solace.station> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: wei.liu2@citrix.com, Ian.Campbell@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, Dongxiao Xu , JBeulich@suse.com, Chao Peng List-Id: xen-devel@lists.xenproject.org Now that the functionallity is wired, from within Xen up to libxl, use that to implement a new mode for `xl psr-cmt-attach' and `xl psr-cmt-detach', by means of a new '-c' switch: [root@redbrick ~]# xl psr-cmt-detach -c 4 [root@redbrick ~]# xl psr-cmt-attach -c 121 Signed-off-by: Dario Faggioli --- tools/libxl/xl_cmdimpl.c | 44 ++++++++++++++++++++++++++++++++++---------- tools/libxl/xl_cmdtable.c | 12 ++++++++---- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index d314947..7f7d995 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -8233,30 +8233,54 @@ static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid) int main_psr_cmt_attach(int argc, char **argv) { - uint32_t domid; + uint32_t id; + bool cpu = false; int opt, ret = 0; + static struct option opts[] = { + {"cpu", 0, 0, 'c'}, + COMMON_LONG_OPTS, + {0, 0, 0, 0} + }; - SWITCH_FOREACH_OPT(opt, "", NULL, "psr-cmt-attach", 1) { - /* No options */ + SWITCH_FOREACH_OPT(opt, "c", opts, "psr-cmt-attach", 1) { + case 'c': + cpu = true; + break; } - domid = find_domain(argv[optind]); - ret = libxl_psr_cmt_attach(ctx, domid); + if (cpu) { + id = atoi(argv[optind]); + return libxl_psr_cmt_cpu_attach(ctx, id); + } + id = find_domain(argv[optind]); + ret = libxl_psr_cmt_attach(ctx, id); return ret; } int main_psr_cmt_detach(int argc, char **argv) { - uint32_t domid; + uint32_t id; + bool cpu = false; int opt, ret = 0; + static struct option opts[] = { + {"cpu", 0, 0, 'c'}, + COMMON_LONG_OPTS, + {0, 0, 0, 0} + }; - SWITCH_FOREACH_OPT(opt, "", NULL, "psr-cmt-detach", 1) { - /* No options */ + SWITCH_FOREACH_OPT(opt, "c", opts, "psr-cmt-detach", 1) { + case 'c': + cpu = true; + break; } - domid = find_domain(argv[optind]); - ret = libxl_psr_cmt_detach(ctx, domid); + if (cpu) { + id = atoi(argv[optind]); + return libxl_psr_cmt_cpu_detach(ctx, id); + } + id = find_domain(argv[optind]); + ret = libxl_psr_cmt_detach(ctx, id); return ret; } diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index 5bbe406..886dd8a 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -526,13 +526,17 @@ struct cmd_spec cmd_table[] = { #ifdef LIBXL_HAVE_PSR_CMT { "psr-cmt-attach", &main_psr_cmt_attach, 0, 1, - "Attach Cache Monitoring Technology service to a domain", - "", + "Attach Cache Monitoring Technology service to a domain or a pCPU", + "[-c|--cpu] ", + "By default (no -c), is the domain id of the domain to start monitoring.\n" + "-c|--cpu Attach monitoring to CPU ." }, { "psr-cmt-detach", &main_psr_cmt_detach, 0, 1, - "Detach Cache Monitoring Technology service from a domain", - "", + "Detach Cache Monitoring Technology service from a domain or a pCPU", + "[-c|--cpu] ", + "By default (no -c), is the domain id of the domain to stop monitoring.\n" + "-c|--cpu Detach monitoring from CPU ." }, { "psr-cmt-show", &main_psr_cmt_show, 0, 1,