From patchwork Fri Apr 1 04:59:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chong Li X-Patchwork-Id: 8720251 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 884809F36E for ; Fri, 1 Apr 2016 05:03:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0294520384 for ; Fri, 1 Apr 2016 05:03:05 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 5005220279 for ; Fri, 1 Apr 2016 05:03:03 +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 1alrBq-00056n-Ot; Fri, 01 Apr 2016 05:00:10 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1alrBp-00055h-Ga for xen-devel@lists.xen.org; Fri, 01 Apr 2016 05:00:09 +0000 Received: from [193.109.254.147] by server-10.bemta-14.messagelabs.com id FF/7A-02986-8500EF65; Fri, 01 Apr 2016 05:00:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsVyMfTqVt0Ihn9 hBv3nWCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oz/KyawFXydw1ixr30/cwPjwswuRi4OIYFJ jBKXfjazgTgsAi9ZJNYeOMIO4kgI9LNKNB7pYu5i5ARyYiQ+tM9hh7ArJf7umcwKYgsJKEucu ruLHWLUYiaJDfteMoIk2ARUJa7uescCYosISEtc+3yZEaSIWeAlo8TGxReA9nFwCAt4Scw44g NSwwJUP3f1C7B6XgFnid6Xl9kglslJnDwGsYxTwEXi5p3nUIudJW5teMwygVFgASPDKkb14tS istQiXSO9pKLM9IyS3MTMHF1DQxO93NTi4sT01JzEpGK95PzcTYzA4GIAgh2MLXOcDzFKcjAp ifK+uv03TIgvKT+lMiOxOCO+qDQntfgQowwHh5IEr9J/oJxgUWp6akVaZg4wzGHSEhw8SiK8N f+A0rzFBYm5xZnpEKlTjMYcW35fW8vEsW3qvbVMQix5+XmpUuK8b0FKBUBKM0rz4AbB4u8So6 yUMC8j0GlCPAWpRbmZJajyrxjFORiVhHmlQO7hycwrgdv3CugUJqBTtmr8AjmlJBEhJQWM54l ZwvstJ4aJL9LjrEwIZmRfsyahKpnv8+Wyoi63jiim/yrTYl8GG2lvk3wUFPKU21FRSHOzxH7R t4EL1v2R0z055+S6sxPZ7hqwbI7pn+1Q5rV638byOdUtom9u2KtFn1+5i5VrkazulGORDXLv9 h+10fxz9viXcuVW39Xbdip+CL97LqRQiaU4I9FQi7moOBEAnmxHQ7oCAAA= X-Env-Sender: lichong659@gmail.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1459486806!34961110!1 X-Originating-IP: [209.85.213.181] X-SpamReason: No, hits=0.3 required=7.0 tests=MAILTO_TO_SPAM_ADDR X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40658 invoked from network); 1 Apr 2016 05:00:07 -0000 Received: from mail-ig0-f181.google.com (HELO mail-ig0-f181.google.com) (209.85.213.181) by server-13.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Apr 2016 05:00:07 -0000 Received: by mail-ig0-f181.google.com with SMTP id ui10so5374038igc.1 for ; Thu, 31 Mar 2016 22:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8LnaFRO1HluQhVzxSYGWOosSSguFbJIuoEVL8lGPo1c=; b=V/faOiDyMMpHBi6e2VB0665JaWwIw46QmDclVKma3G1oGCIxNE3FIE3VOYl50Kv9Ab zD9MxSoQ9R2/oKbbtZuzxkWkTL+qax2hIoSKjSkwNL6mvHV9tNBqIo5VauXuIe2bhNM3 nLf2DaUztDLiHVvRJzpNKGJ/lpRLC8FKZHNzfDTq6N8PDPA9JYuuD6GUChjCC94UuTwr HF/x+XCX83TussrZZNEbsNgTZ+vaSe3NCmq85FMI9vnnQRtPvu4axOqCGWGiDHDd00mn E5v4yazwLaGrr78BCHghs4KBbtm0nouv6vyxoTYrxoplvAnfR6KgTbMtHwqtMSD85Q1/ ROkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8LnaFRO1HluQhVzxSYGWOosSSguFbJIuoEVL8lGPo1c=; b=adGecMGrf3cpTD2q7xLomAx7j38PfSTHBFFrR2N09434dt0MNCXlFMPeO9W+J60ZAj kNwgepoBC8gVNa59kUdXBudPoBWsUonsm1Amma633YMe+xxv5PrbethuItqT11tEI0Xz VAwzkFpa3HuxE7z40qzcBRA7h3mPRNevykg05R0k8GDzTYZx7B17f8jsjHDCXalMm5wT sLX5yOw9lH+4wexWLKHGsYikgrxpfhzHOpL/hH2BRG3cLFuAS6zqVx6bZeDoRB5KczdR S82ungF6++BVqjsZyJDSxVEVgQb7kIMufq0MpRPI60XVm8ZIqAffuqJZz4vE8KK+lZ2A avbw== X-Gm-Message-State: AD7BkJJZ+zoiEgfmv4f888jwptgJx84j1G/p6FMxwkNvy0jXReRSGX1CCGS0Ps1Wt16D6Q== X-Received: by 10.50.143.105 with SMTP id sd9mr1118259igb.73.1459486806269; Thu, 31 Mar 2016 22:00:06 -0700 (PDT) Received: from chong-OptiPlex-960.seas.wustl.edu (admin998.cec.wustl.edu. [128.252.20.193]) by smtp.googlemail.com with ESMTPSA id z200sm5192945iod.26.2016.03.31.22.00.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Mar 2016 22:00:05 -0700 (PDT) From: Chong Li To: xen-devel@lists.xen.org Date: Thu, 31 Mar 2016 23:59:46 -0500 Message-Id: <1459486786-3085-5-git-send-email-lichong659@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459486786-3085-1-git-send-email-lichong659@gmail.com> References: <1459486786-3085-1-git-send-email-lichong659@gmail.com> Cc: Chong Li , wei.liu2@citrix.com, Sisu Xi , george.dunlap@eu.citrix.com, dario.faggioli@citrix.com, Meng Xu , lichong659@gmail.com, dgolomb@seas.upenn.edu Subject: [Xen-devel] [PATCH v9 for Xen 4.7 4/4] xl: enable per-VCPU parameter for RTDS 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change main_sched_rtds and related output functions to support per-VCPU settings. Signed-off-by: Chong Li Signed-off-by: Meng Xu Signed-off-by: Sisu Xi Acked-by: Wei Liu Reviewed-by: Dario Faggioli --- Changes on PATCH v8: 1) Improve the example in xl.pod.1 2) Add sched_rtds_vcpu_output_all() and sched_vcpu_get_all() to output all vcpus of a domain 3) Fix some coding style issues Changes on PATCH v7: 1) Add example to xl.pod.1 Changes on PATCH v6: 1) More explain in xl.pod.1 and cmdtable.c 2) Resolve some coding sytle issues Changes on PATCH v5: 1) Add sched_vcpu_set_all() for the cases that all vcpus of a domain need to be changed together. Changes on PATCH v4: 1) Coding style changes Changes on PATCH v3: 1) Support commands, e.g., "xl sched-rtds -d vm1" to output the default scheduling parameters Changes on PATCH v2: 1) Remove per-domain output functions for RTDS scheduler. 2) Users now use '-v all' to specify all VCPUs. 3) Support outputting a subset of the parameters of the VCPUs of a specific domain. 4) When setting all VCPUs with the same parameters (by only one command), no per-domain function is invoked. CC: CC: CC: CC: CC: CC: --- docs/man/xl.pod.1 | 67 +++++++++ tools/libxl/xl_cmdimpl.c | 365 +++++++++++++++++++++++++++++++++++++++++----- tools/libxl/xl_cmdtable.c | 4 +- 3 files changed, 400 insertions(+), 36 deletions(-) diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1 index 4d4b333..9e89e0a 100644 --- a/docs/man/xl.pod.1 +++ b/docs/man/xl.pod.1 @@ -1056,6 +1056,10 @@ B Specify domain for which scheduler parameters are to be modified or retrieved. Mandatory for modifying scheduler parameters. +=item B<-v VCPUID/all>, B<--vcpuid=VCPUID/all> + +Specify vcpu for which scheduler parameters are to be modified or retrieved. + =item B<-p PERIOD>, B<--period=PERIOD> Period of time, in microseconds, over which to replenish the budget. @@ -1071,6 +1075,69 @@ Restrict output to domains in the specified cpupool. =back +B + +=over 4 + +1) Use B<-v all> to see the budget and period of all the VCPUs of +all the domains: + + xl sched-rtds -v all + Cpupool Pool-0: sched=RTDS + Name ID VCPU Period Budget + Domain-0 0 0 10000 4000 + vm1 1 0 300 150 + vm1 1 1 400 200 + vm1 1 2 10000 4000 + vm1 1 3 1000 500 + vm2 2 0 10000 4000 + vm2 2 1 10000 4000 + +Without any arguments, it will output the default scheduing +parameters for each domain: + + xl sched-rtds + Cpupool Pool-0: sched=RTDS + Name ID Period Budget + Domain-0 0 10000 4000 + vm1 1 10000 4000 + vm2 2 10000 4000 + + +2) Use, for instance B<-d vm1, -v all> to see the budget and +period of all VCPUs of a specific domain (B): + + xl sched-rtds -d vm1 -v all + Name ID VCPU Period Budget + vm1 1 0 300 150 + vm1 1 1 400 200 + vm1 1 2 10000 4000 + vm1 1 3 1000 500 + +To see the parameters of a subset of the VCPUs of a domain, use: + + xl sched-rtds -d vm1 -v 0 -v 3 + Name ID VCPU Period Budget + vm1 1 0 300 150 + vm1 1 3 1000 500 + +If no B<-v> is speficified, the default scheduling parameter for the +domain are shown: + + xl sched-rtds -d vm1 + Name ID Period Budget + vm1 1 10000 4000 + + +3) Users can set the budget and period of multiple VCPUs of a +specific domain with only one command, +e.g., "xl sched-rtds -d vm1 -v 0 -p 100 -b 50 -v 3 -p 300 -b 150". + +To change the parameters of all the VCPUs of a domain, use B<-v all>, +e.g., "xl sched-rtds -d vm1 -v all -p 500 -b 250". + +=back + =back =head1 CPUPOOLS COMMANDS diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 7750995..dc77689 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -6159,6 +6159,72 @@ static int sched_domain_set(int domid, const libxl_domain_sched_params *scinfo) return 0; } +static int sched_vcpu_get(libxl_scheduler sched, int domid, + libxl_vcpu_sched_params *scinfo) +{ + int rc; + + rc = libxl_vcpu_sched_params_get(ctx, domid, scinfo); + if (rc) { + fprintf(stderr, "libxl_vcpu_sched_params_get failed.\n"); + exit(EXIT_FAILURE); + } + if (scinfo->sched != sched) { + fprintf(stderr, "libxl_vcpu_sched_params_get returned %s not %s.\n", + libxl_scheduler_to_string(scinfo->sched), + libxl_scheduler_to_string(sched)); + return 1; + } + + return 0; +} + +static int sched_vcpu_get_all(libxl_scheduler sched, int domid, + libxl_vcpu_sched_params *scinfo) +{ + int rc; + + rc = libxl_vcpu_sched_params_get_all(ctx, domid, scinfo); + if (rc) { + fprintf(stderr, "libxl_vcpu_sched_params_get_all failed.\n"); + exit(EXIT_FAILURE); + } + if (scinfo->sched != sched) { + fprintf(stderr, "libxl_vcpu_sched_params_get_all returned %s not %s.\n", + libxl_scheduler_to_string(scinfo->sched), + libxl_scheduler_to_string(sched)); + return 1; + } + + return 0; +} + +static int sched_vcpu_set(int domid, const libxl_vcpu_sched_params *scinfo) +{ + int rc; + + rc = libxl_vcpu_sched_params_set(ctx, domid, scinfo); + if (rc) { + fprintf(stderr, "libxl_vcpu_sched_params_set failed.\n"); + exit(EXIT_FAILURE); + } + + return 0; +} + +static int sched_vcpu_set_all(int domid, const libxl_vcpu_sched_params *scinfo) +{ + int rc; + + rc = libxl_vcpu_sched_params_set_all(ctx, domid, scinfo); + if (rc) { + fprintf(stderr, "libxl_vcpu_sched_params_set_all failed.\n"); + exit(EXIT_FAILURE); + } + + return 0; +} + static int sched_credit_params_set(int poolid, libxl_sched_credit_params *scinfo) { if (libxl_sched_credit_params_set(ctx, poolid, scinfo)) { @@ -6278,6 +6344,66 @@ static int sched_rtds_domain_output( return 0; } +static int sched_rtds_vcpu_output(int domid, libxl_vcpu_sched_params *scinfo) +{ + char *domname; + int rc = 0; + int i; + + if (domid < 0) { + printf("%-33s %4s %4s %9s %9s\n", "Name", "ID", + "VCPU", "Period", "Budget"); + return 0; + } + + rc = sched_vcpu_get(LIBXL_SCHEDULER_RTDS, domid, scinfo); + if (rc) + return 1; + + domname = libxl_domid_to_name(ctx, domid); + for ( i = 0; i < scinfo->num_vcpus; i++ ) { + printf("%-33s %4d %4d %9"PRIu32" %9"PRIu32"\n", + domname, + domid, + scinfo->vcpus[i].vcpuid, + scinfo->vcpus[i].period, + scinfo->vcpus[i].budget); + } + free(domname); + return 0; +} + +static int sched_rtds_vcpu_output_all(int domid, + libxl_vcpu_sched_params *scinfo) +{ + char *domname; + int rc = 0; + int i; + + if (domid < 0) { + printf("%-33s %4s %4s %9s %9s\n", "Name", "ID", + "VCPU", "Period", "Budget"); + return 0; + } + + scinfo->num_vcpus = 0; + rc = sched_vcpu_get_all(LIBXL_SCHEDULER_RTDS, domid, scinfo); + if (rc) + return 1; + + domname = libxl_domid_to_name(ctx, domid); + for ( i = 0; i < scinfo->num_vcpus; i++ ) { + printf("%-33s %4d %4d %9"PRIu32" %9"PRIu32"\n", + domname, + domid, + scinfo->vcpus[i].vcpuid, + scinfo->vcpus[i].period, + scinfo->vcpus[i].budget); + } + free(domname); + return 0; +} + static int sched_rtds_pool_output(uint32_t poolid) { char *poolname; @@ -6351,6 +6477,61 @@ static int sched_domain_output(libxl_scheduler sched, int (*output)(int), return 0; } +static int sched_vcpu_output(libxl_scheduler sched, + int (*output)(int, libxl_vcpu_sched_params *), + int (*pooloutput)(uint32_t), const char *cpupool) +{ + libxl_dominfo *info; + libxl_cpupoolinfo *poolinfo = NULL; + uint32_t poolid; + int nb_domain, n_pools = 0, i, p; + int rc = 0; + + if (cpupool) { + if (libxl_cpupool_qualifier_to_cpupoolid(ctx, cpupool, &poolid, NULL) + || !libxl_cpupoolid_is_valid(ctx, poolid)) { + fprintf(stderr, "unknown cpupool \'%s\'\n", cpupool); + return 1; + } + } + + info = libxl_list_domain(ctx, &nb_domain); + if (!info) { + fprintf(stderr, "libxl_list_domain failed.\n"); + return 1; + } + poolinfo = libxl_list_cpupool(ctx, &n_pools); + if (!poolinfo) { + fprintf(stderr, "error getting cpupool info\n"); + libxl_dominfo_list_free(info, nb_domain); + return 1; + } + + for (p = 0; !rc && (p < n_pools); p++) { + if ((poolinfo[p].sched != sched) || + (cpupool && (poolid != poolinfo[p].poolid))) + continue; + + pooloutput(poolinfo[p].poolid); + + output(-1, NULL); + for (i = 0; i < nb_domain; i++) { + libxl_vcpu_sched_params scinfo; + if (info[i].cpupool != poolinfo[p].poolid) + continue; + libxl_vcpu_sched_params_init(&scinfo); + rc = output(info[i].domid, &scinfo); + libxl_vcpu_sched_params_dispose(&scinfo); + if (rc) + break; + } + } + + libxl_cpupoolinfo_list_free(poolinfo, n_pools); + libxl_dominfo_list_free(info, nb_domain); + return 0; +} + /* * : List all domain params and sched params from all pools * -d [domid] : List domain params for domain @@ -6554,84 +6735,198 @@ int main_sched_credit2(int argc, char **argv) /* * : List all domain paramters and sched params - * -d [domid] : List domain params for domain + * -d [domid] : List default domain params for domain * -d [domid] [params] : Set domain params for domain + * -d [domid] -v [vcpuid 1] -v [vcpuid 2] ... : + * List per-VCPU params for domain + * -d [domid] -v all : List all per-VCPU params for domain + * -v all : List all per-VCPU params for all domains + * -d [domid] -v [vcpuid 1] [params] -v [vcpuid 2] [params] ... : + * Set per-VCPU params for domain + * -d [domid] -v all [params] : Set all per-VCPU params for domain */ int main_sched_rtds(int argc, char **argv) { const char *dom = NULL; const char *cpupool = NULL; - int period = 0; /* period is in microsecond */ - int budget = 0; /* budget is in microsecond */ + int *vcpus = (int *)xmalloc(sizeof(int)); /* IDs of VCPUs that change */ + int *periods = (int *)xmalloc(sizeof(int)); /* period is in microsecond */ + int *budgets = (int *)xmalloc(sizeof(int)); /* budget is in microsecond */ + int v_size = 1; /* size of vcpus array */ + int p_size = 1; /* size of periods array */ + int b_size = 1; /* size of budgets array */ + int v_index = 0; /* index in vcpus array */ + int p_index =0; /* index in periods array */ + int b_index =0; /* index for in budgets array */ bool opt_p = false; bool opt_b = false; - int opt, rc; + bool opt_v = false; + bool opt_all = false; /* output per-dom parameters */ + int opt, i, rc, r; static struct option opts[] = { {"domain", 1, 0, 'd'}, {"period", 1, 0, 'p'}, {"budget", 1, 0, 'b'}, + {"vcpuid",1, 0, 'v'}, {"cpupool", 1, 0, 'c'}, COMMON_LONG_OPTS }; - SWITCH_FOREACH_OPT(opt, "d:p:b:c:", opts, "sched-rtds", 0) { + SWITCH_FOREACH_OPT(opt, "d:p:b:v:c", opts, "sched-rtds", 0) { case 'd': dom = optarg; break; case 'p': - period = strtol(optarg, NULL, 10); - opt_p = true; + if (p_index >= p_size) { + /* + * periods array is full + * double the array size for new elements + */ + p_size *= 2; + periods = xrealloc(periods, p_size); + } + periods[p_index++] = strtol(optarg, NULL, 10); + opt_p = 1; break; case 'b': - budget = strtol(optarg, NULL, 10); - opt_b = true; + if (b_index >= b_size) { /* budgets array is full */ + b_size *= 2; + budgets = xrealloc(budgets, b_size); + } + budgets[b_index++] = strtol(optarg, NULL, 10); + opt_b = 1; + break; + case 'v': + if (!strcmp(optarg, "all")) { /* get or set all vcpus of a domain */ + opt_all = 1; + break; + } + if (v_index >= v_size) { /* vcpus array is full */ + v_size *= 2; + vcpus = xrealloc(vcpus, v_size); + } + vcpus[v_index++] = strtol(optarg, NULL, 10); + opt_v = 1; break; case 'c': cpupool = optarg; break; } - if (cpupool && (dom || opt_p || opt_b)) { + if (cpupool && (dom || opt_p || opt_b || opt_v || opt_all)) { fprintf(stderr, "Specifying a cpupool is not allowed with " "other options.\n"); - return EXIT_FAILURE; + r = EXIT_FAILURE; + goto out; } - if (!dom && (opt_p || opt_b)) { - fprintf(stderr, "Must specify a domain.\n"); - return EXIT_FAILURE; + if (!dom && (opt_p || opt_b || opt_v)) { + fprintf(stderr, "Missing parameters.\n"); + r = EXIT_FAILURE; + goto out; } - if (opt_p != opt_b) { - fprintf(stderr, "Must specify period and budget\n"); - return EXIT_FAILURE; + if (dom && !opt_v && !opt_all && (opt_p || opt_b)) { + fprintf(stderr, "Must specify VCPU.\n"); + r = EXIT_FAILURE; + goto out; + } + if (opt_v && opt_all) { + fprintf(stderr, "Incorrect VCPU IDs.\n"); + r = EXIT_FAILURE; + goto out; + } + if (((v_index > b_index) && opt_b) || ((v_index > p_index) && opt_p) + || p_index != b_index) { + fprintf(stderr, "Incorrect number of period and budget\n"); + r = EXIT_FAILURE; + goto out; } - if (!dom) { /* list all domain's rt scheduler info */ - if (sched_domain_output(LIBXL_SCHEDULER_RTDS, - sched_rtds_domain_output, + if ((!dom) && opt_all) { + /* get all domain's per-vcpu rtds scheduler parameters */ + rc = -sched_vcpu_output(LIBXL_SCHEDULER_RTDS, + sched_rtds_vcpu_output_all, sched_rtds_pool_output, - cpupool)) - return EXIT_FAILURE; + cpupool); + if (rc) { + r = EXIT_FAILURE; + goto out; + } + } else if (!dom && !opt_all) { + /* list all domain's default scheduling parameters */ + rc = -sched_domain_output(LIBXL_SCHEDULER_RTDS, + sched_rtds_domain_output, + sched_rtds_pool_output, + cpupool); + if (rc) { + r = EXIT_FAILURE; + goto out; + } } else { uint32_t domid = find_domain(dom); - if (!opt_p && !opt_b) { /* output rt scheduler info */ + if (!opt_v && !opt_all) { /* output default scheduling parameters */ sched_rtds_domain_output(-1); - if (sched_rtds_domain_output(domid)) - return EXIT_FAILURE; - } else { /* set rt scheduler paramaters */ - libxl_domain_sched_params scinfo; - libxl_domain_sched_params_init(&scinfo); + rc = -sched_rtds_domain_output(domid); + if (rc) { + r = EXIT_FAILURE; + goto out; + } + } else if (!opt_p && !opt_b) { + /* get per-vcpu rtds scheduling parameters */ + libxl_vcpu_sched_params scinfo; + libxl_vcpu_sched_params_init(&scinfo); + sched_rtds_vcpu_output(-1, &scinfo); + scinfo.num_vcpus = v_index; + if (v_index > 0) { + scinfo.vcpus = (libxl_sched_params *) + xmalloc(sizeof(libxl_sched_params) * (v_index)); + for (i = 0; i < v_index; i++) + scinfo.vcpus[i].vcpuid = vcpus[i]; + rc = -sched_rtds_vcpu_output(domid, &scinfo); + } else /* get params for all vcpus */ + rc = -sched_rtds_vcpu_output_all(domid, &scinfo); + libxl_vcpu_sched_params_dispose(&scinfo); + if (rc) { + r = EXIT_FAILURE; + goto out; + } + } else if (opt_v || opt_all) { + /* set per-vcpu rtds scheduling parameters */ + libxl_vcpu_sched_params scinfo; + libxl_vcpu_sched_params_init(&scinfo); scinfo.sched = LIBXL_SCHEDULER_RTDS; - scinfo.period = period; - scinfo.budget = budget; + if (v_index > 0) { + scinfo.num_vcpus = v_index; + scinfo.vcpus = (libxl_sched_params *) + xmalloc(sizeof(libxl_sched_params) * (v_index)); + for (i = 0; i < v_index; i++) { + scinfo.vcpus[i].vcpuid = vcpus[i]; + scinfo.vcpus[i].period = periods[i]; + scinfo.vcpus[i].budget = budgets[i]; + } + rc = sched_vcpu_set(domid, &scinfo); + } else { /* set params for all vcpus */ + scinfo.num_vcpus = 1; + scinfo.vcpus = (libxl_sched_params *) + xmalloc(sizeof(libxl_sched_params)); + scinfo.vcpus[0].period = periods[0]; + scinfo.vcpus[0].budget = budgets[0]; + rc = sched_vcpu_set_all(domid, &scinfo); + } - rc = sched_domain_set(domid, &scinfo); - libxl_domain_sched_params_dispose(&scinfo); - if (rc) - return EXIT_FAILURE; + libxl_vcpu_sched_params_dispose(&scinfo); + if (rc) { + r = EXIT_FAILURE; + goto out; + } } } - return EXIT_SUCCESS; + r = EXIT_SUCCESS; +out: + free(vcpus); + free(periods); + free(budgets); + return r; } int main_domid(int argc, char **argv) diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index 7880a9c..859af78 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -269,8 +269,10 @@ struct cmd_spec cmd_table[] = { { "sched-rtds", &main_sched_rtds, 0, 1, "Get/set rtds scheduler parameters", - "[-d [-p[=PERIOD]] [-b[=BUDGET]]]", + "[-d [-v[=VCPUID/all]] [-p[=PERIOD]] [-b[=BUDGET]]]", "-d DOMAIN, --domain=DOMAIN Domain to modify\n" + "-v VCPUID/all, --vcpuid=VCPUID/all VCPU to modify or output;\n" + " Using '-v all' to modify/output all vcpus\n" "-p PERIOD, --period=PERIOD Period (us)\n" "-b BUDGET, --budget=BUDGET Budget (us)\n" },