From patchwork Wed Oct 11 18:02:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meng Xu X-Patchwork-Id: 10000297 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 B5ACE60216 for ; Wed, 11 Oct 2017 18:04:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B246428B00 for ; Wed, 11 Oct 2017 18:04:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6FB228B03; Wed, 11 Oct 2017 18:04:52 +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 B2B0328B00 for ; Wed, 11 Oct 2017 18:04:51 +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 1e2LL0-0002vj-Og; Wed, 11 Oct 2017 18:02:34 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2LKz-0002uQ-89 for xen-devel@lists.xen.org; Wed, 11 Oct 2017 18:02:33 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id 28/59-26618-8BC5ED95; Wed, 11 Oct 2017 18:02:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCLMWRWlGSWpSXmKPExsUyr8m9UXd7zL1 IgyudOhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8btnfeYClYXVSz4vIepgfGzRxcjF4eQQD+T xKnWuYxdjJwcbAIqEsc3PGIFsUUEpCWufb7MCFLELLCRUWL38XfsIAlhAWeJ2zu+sIHYLAKqE s/e/QVr5gWK398wDywuISAncfLYZLBBnAIuEs//tTJ3MXIAbXOW+N1lDFESKrFm8XkmmPLHDx 8wTmDkWcDIsIpRozi1qCy1SNfQSC+pKDM9oyQ3MTNH19DAVC83tbg4MT01JzGpWC85P3cTI9D vDECwg7FvlvMhRkkOJiVR3mC9e5FCfEn5KZUZicUZ8UWlOanFhxhlODiUJHh3RAPlBItS01Mr 0jJzgAEIk5bg4FES4dUFSfMWFyTmFmemQ6ROMRpzHNt0+Q8TR8fNu3+YhFjy8vNSpcR5r4OUC oCUZpTmwQ2CRcYlRlkpYV5GoNOEeApSi3IzS1DlXzGKczAqCfPKgUzhycwrgdv3CugUJqBTRN PugJxSkoiQkmpgXGoT61bsL/hRVf/9n/XqblsvZ8o0q0TqPGwMNrn93jxA/9G5t5XObWc7Gxo m3DxZYij8cPt9nvyZUS+/Fy1aa3zr+us95S1OPCpmEltkJ1gu8ktMOiCpbOiSsTrtsgX/2fDI 088fH36Wmh165pNhdKP76doNV3pVftp/SZ5s9yND/ZuvduYnJZbijERDLeai4kQAfeNlrocCA AA= X-Env-Sender: mengxu@cis.upenn.edu X-Msg-Ref: server-9.tower-206.messagelabs.com!1507744951!106654853!1 X-Originating-IP: [158.130.71.129] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12591 invoked from network); 11 Oct 2017 18:02:31 -0000 Received: from renard.seas.upenn.edu (HELO fox.seas.upenn.edu) (158.130.71.129) by server-9.tower-206.messagelabs.com with SMTP; 11 Oct 2017 18:02:31 -0000 Received: from panda-6c.cis.upenn.edu (SEASnet-48-12.cis.upenn.edu [158.130.48.13]) (authenticated bits=0) by fox.seas.upenn.edu (8.15.2/8.14.5) with ESMTPSA id v9BI2DV4017412 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT); Wed, 11 Oct 2017 14:02:14 -0400 From: Meng Xu To: xen-devel@lists.xen.org Date: Wed, 11 Oct 2017 14:02:04 -0400 Message-Id: <1507744926-3950-4-git-send-email-mengxu@cis.upenn.edu> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507744926-3950-1-git-send-email-mengxu@cis.upenn.edu> References: <1507744926-3950-1-git-send-email-mengxu@cis.upenn.edu> X-Proofpoint-Virus-Version: vendor=nai engine=5600 definitions=5800 signatures=585085 X-Proofpoint-Spam-Reason: safe Cc: wei.liu2@citrix.com, george.dunlap@eu.citrix.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, xumengpanda@gmail.com, Meng Xu Subject: [Xen-devel] [PATCH v4 3/5] xl: enable per-VCPU extratime flag 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-Virus-Scanned: ClamAV using ClamSMTP Change main_sched_rtds and related output functions to support per-VCPU extratime flag. Signed-off-by: Meng Xu Reviewed-by: Dario Faggioli Acked-by: Wei Liu --- Changes from v2 Validate the -e option input that can only be 0 or 1 Update docs/man/xl.pod.1.in Change EXTRATIME to Extratime Changes from v1 No change because we agree on using -e 0/1 option to set if a vcpu will get extra time or not Changes from RFC v1 Changes work_conserving flag to extratime flag --- docs/man/xl.pod.1.in | 59 +++++++++++++++++++++++++---------------------- tools/xl/xl_cmdtable.c | 3 ++- tools/xl/xl_sched.c | 62 +++++++++++++++++++++++++++++++++++--------------- 3 files changed, 78 insertions(+), 46 deletions(-) diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in index cd8bb1c..486a24f 100644 --- a/docs/man/xl.pod.1.in +++ b/docs/man/xl.pod.1.in @@ -1117,11 +1117,11 @@ as B<--ratelimit_us> in B Set or get rtds (Real Time Deferrable Server) scheduler parameters. This rt scheduler applies Preemptive Global Earliest Deadline First real-time scheduling algorithm to schedule VCPUs in the system. -Each VCPU has a dedicated period and budget. -VCPUs in the same domain have the same period and budget. +Each VCPU has a dedicated period, budget and extratime. While scheduled, a VCPU burns its budget. A VCPU has its budget replenished at the beginning of each period; Unused budget is discarded at the end of each period. +A VCPU with extratime set gets extra time from the unreserved system resource. B @@ -1145,6 +1145,11 @@ Period of time, in microseconds, over which to replenish the budget. Amount of time, in microseconds, that the VCPU will be allowed to run every period. +=item B<-e Extratime>, B<--extratime=Extratime> + +Binary flag to decide if the VCPU will be allowed to get extra time from +the unreserved system resource. + =item B<-c CPUPOOL>, B<--cpupool=CPUPOOL> Restrict output to domains in the specified cpupool. @@ -1160,57 +1165,57 @@ 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 + Name ID VCPU Period Budget Extratime + Domain-0 0 0 10000 4000 yes + vm1 2 0 300 150 yes + vm1 2 1 400 200 yes + vm1 2 2 10000 4000 yes + vm1 2 3 1000 500 yes + vm2 4 0 10000 4000 yes + vm2 4 1 10000 4000 yes Without any arguments, it will output the default scheduling 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 + Name ID Period Budget Extratime + Domain-0 0 10000 4000 yes + vm1 2 10000 4000 yes + vm2 4 10000 4000 yes -2) Use, for instancei, B<-d vm1, -v all> to see the budget and +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 + Name ID VCPU Period Budget Extratime + vm1 2 0 300 150 yes + vm1 2 1 400 200 yes + vm1 2 2 10000 4000 yes + vm1 2 3 1000 500 yes 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 + Name ID VCPU Period Budget Extratime + vm1 2 0 300 150 yes + vm1 2 3 1000 500 yes If no B<-v> is specified, the default scheduling parameters for the domain are shown: xl sched-rtds -d vm1 - Name ID Period Budget - vm1 1 10000 4000 + Name ID Period Budget Extratime + vm1 2 10000 4000 yes 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". +e.g., "xl sched-rtds -d vm1 -v 0 -p 100 -b 50 -e 1 -v 3 -p 300 -b 150 -e 0". 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". +e.g., "xl sched-rtds -d vm1 -v all -p 500 -b 250 -e 1". =back diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 68a8a72..5546cf6 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -273,12 +273,13 @@ struct cmd_spec cmd_table[] = { { "sched-rtds", &main_sched_rtds, 0, 1, "Get/set rtds scheduler parameters", - "[-d [-v[=VCPUID/all]] [-p[=PERIOD]] [-b[=BUDGET]]]", + "[-d [-v[=VCPUID/all]] [-p[=PERIOD]] [-b[=BUDGET]] [-e[=Extratime]]]", "-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" + "-e Extratime, --extratime=Extratime Extratime (1=yes, 0=no)\n" }, { "domid", &main_domid, 0, 0, diff --git a/tools/xl/xl_sched.c b/tools/xl/xl_sched.c index 7fabce3..7965ccb 100644 --- a/tools/xl/xl_sched.c +++ b/tools/xl/xl_sched.c @@ -252,7 +252,7 @@ static int sched_rtds_domain_output( libxl_domain_sched_params scinfo; if (domid < 0) { - printf("%-33s %4s %9s %9s\n", "Name", "ID", "Period", "Budget"); + printf("%-33s %4s %9s %9s %10s\n", "Name", "ID", "Period", "Budget", "Extratime"); return 0; } @@ -263,11 +263,12 @@ static int sched_rtds_domain_output( } domname = libxl_domid_to_name(ctx, domid); - printf("%-33s %4d %9d %9d\n", + printf("%-33s %4d %9d %9d %10s\n", domname, domid, scinfo.period, - scinfo.budget); + scinfo.budget, + scinfo.extratime ? "yes" : "no"); free(domname); libxl_domain_sched_params_dispose(&scinfo); return 0; @@ -280,8 +281,8 @@ static int sched_rtds_vcpu_output(int domid, libxl_vcpu_sched_params *scinfo) int i; if (domid < 0) { - printf("%-33s %4s %4s %9s %9s\n", "Name", "ID", - "VCPU", "Period", "Budget"); + printf("%-33s %4s %4s %9s %9s %10s\n", "Name", "ID", + "VCPU", "Period", "Budget", "Extratime"); return 0; } @@ -291,12 +292,13 @@ static int sched_rtds_vcpu_output(int domid, libxl_vcpu_sched_params *scinfo) domname = libxl_domid_to_name(ctx, domid); for ( i = 0; i < scinfo->num_vcpus; i++ ) { - printf("%-33s %4d %4d %9"PRIu32" %9"PRIu32"\n", + printf("%-33s %4d %4d %9"PRIu32" %9"PRIu32" %10s\n", domname, domid, scinfo->vcpus[i].vcpuid, scinfo->vcpus[i].period, - scinfo->vcpus[i].budget); + scinfo->vcpus[i].budget, + scinfo->vcpus[i].extratime ? "yes" : "no"); } free(domname); return 0; @@ -310,8 +312,8 @@ static int sched_rtds_vcpu_output_all(int domid, int i; if (domid < 0) { - printf("%-33s %4s %4s %9s %9s\n", "Name", "ID", - "VCPU", "Period", "Budget"); + printf("%-33s %4s %4s %9s %9s %10s\n", "Name", "ID", + "VCPU", "Period", "Budget", "Extratime"); return 0; } @@ -322,12 +324,13 @@ static int sched_rtds_vcpu_output_all(int domid, domname = libxl_domid_to_name(ctx, domid); for ( i = 0; i < scinfo->num_vcpus; i++ ) { - printf("%-33s %4d %4d %9"PRIu32" %9"PRIu32"\n", + printf("%-33s %4d %4d %9"PRIu32" %9"PRIu32" %10s\n", domname, domid, scinfo->vcpus[i].vcpuid, scinfo->vcpus[i].period, - scinfo->vcpus[i].budget); + scinfo->vcpus[i].budget, + scinfo->vcpus[i].extratime ? "yes" : "no"); } free(domname); return 0; @@ -711,14 +714,18 @@ int main_sched_rtds(int argc, char **argv) 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 */ + bool *extratimes = (bool *)xmalloc(sizeof(bool)); /* extratime is bool */ 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 e_size = 1; /* size of extratimes 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 */ + int e_index = 0; /* index in extratimes array */ bool opt_p = false; bool opt_b = false; + bool opt_e = false; bool opt_v = false; bool opt_all = false; /* output per-dom parameters */ int opt, i, rc, r; @@ -726,12 +733,13 @@ int main_sched_rtds(int argc, char **argv) {"domain", 1, 0, 'd'}, {"period", 1, 0, 'p'}, {"budget", 1, 0, 'b'}, + {"extratime", 1, 0, 'e'}, {"vcpuid",1, 0, 'v'}, {"cpupool", 1, 0, 'c'}, COMMON_LONG_OPTS }; - SWITCH_FOREACH_OPT(opt, "d:p:b:v:c", opts, "sched-rtds", 0) { + SWITCH_FOREACH_OPT(opt, "d:p:b:e:v:c", opts, "sched-rtds", 0) { case 'd': dom = optarg; break; @@ -755,6 +763,20 @@ int main_sched_rtds(int argc, char **argv) budgets[b_index++] = strtol(optarg, NULL, 10); opt_b = 1; break; + case 'e': + if (e_index >= e_size) { /* extratime array is full */ + e_size *= 2; + extratimes = xrealloc(extratimes, e_size); + } + if (strcmp(optarg, "0") && strcmp(optarg, "1")) + { + fprintf(stderr, "Invalid extratime.\n"); + r = EXIT_FAILURE; + goto out; + } + extratimes[e_index++] = strtol(optarg, NULL, 10); + opt_e = 1; + break; case 'v': if (!strcmp(optarg, "all")) { /* get or set all vcpus of a domain */ opt_all = 1; @@ -772,18 +794,18 @@ int main_sched_rtds(int argc, char **argv) break; } - if (cpupool && (dom || opt_p || opt_b || opt_v || opt_all)) { + if (cpupool && (dom || opt_p || opt_b || opt_e || opt_v || opt_all)) { fprintf(stderr, "Specifying a cpupool is not allowed with " "other options.\n"); r = EXIT_FAILURE; goto out; } - if (!dom && (opt_p || opt_b || opt_v)) { + if (!dom && (opt_p || opt_b || opt_e || opt_v)) { fprintf(stderr, "Missing parameters.\n"); r = EXIT_FAILURE; goto out; } - if (dom && !opt_v && !opt_all && (opt_p || opt_b)) { + if (dom && !opt_v && !opt_all && (opt_p || opt_b || opt_e)) { fprintf(stderr, "Must specify VCPU.\n"); r = EXIT_FAILURE; goto out; @@ -794,8 +816,9 @@ int main_sched_rtds(int argc, char **argv) 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"); + || ((v_index > e_index) && opt_e) || p_index != b_index + || p_index != e_index ) { + fprintf(stderr, "Incorrect number of period, budget and extratime\n"); r = EXIT_FAILURE; goto out; } @@ -829,7 +852,7 @@ int main_sched_rtds(int argc, char **argv) r = EXIT_FAILURE; goto out; } - } else if (!opt_p && !opt_b) { + } else if (!opt_p && !opt_b && !opt_e) { /* get per-vcpu rtds scheduling parameters */ libxl_vcpu_sched_params scinfo; libxl_vcpu_sched_params_init(&scinfo); @@ -861,6 +884,7 @@ int main_sched_rtds(int argc, char **argv) scinfo.vcpus[i].vcpuid = vcpus[i]; scinfo.vcpus[i].period = periods[i]; scinfo.vcpus[i].budget = budgets[i]; + scinfo.vcpus[i].extratime = extratimes[i] ? 1 : 0; } rc = sched_vcpu_set(domid, &scinfo); } else { /* set params for all vcpus */ @@ -869,6 +893,7 @@ int main_sched_rtds(int argc, char **argv) xmalloc(sizeof(libxl_sched_params)); scinfo.vcpus[0].period = periods[0]; scinfo.vcpus[0].budget = budgets[0]; + scinfo.vcpus[0].extratime = extratimes[0] ? 1 : 0; rc = sched_vcpu_set_all(domid, &scinfo); } @@ -885,6 +910,7 @@ out: free(vcpus); free(periods); free(budgets); + free(extratimes); return r; }