[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC v1 2/4] xl for rt scheduler
Add xl command for rt scheduler Signed-off-by: Sisu Xi <xisisu@xxxxxxxxx> Signed-off-by: Meng Xu <mengxu@xxxxxxxxxxxxx> --- docs/man/xl.pod.1 | 40 +++++++++++++ tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 141 +++++++++++++++++++++++++++++++++++++++++++++ tools/libxl/xl_cmdtable.c | 9 +++ 4 files changed, 191 insertions(+) diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1 index 30bd4bf..42aeedc 100644 --- a/docs/man/xl.pod.1 +++ b/docs/man/xl.pod.1 @@ -1019,6 +1019,46 @@ Restrict output to domains in the specified cpupool. =back +=item B<sched-rt> [I<OPTIONS>] + +Set or get rt (Real Time) 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. +While scheduled, a VCPU burns its budget. +A VCPU has its budget replenished at the beginning of each of its periods; +The VCPU discards its unused budget at the end of its periods. + +B<OPTIONS> + +=over 4 + +=item B<-d DOMAIN>, B<--domain=DOMAIN> + +Specify domain for which scheduler parameters are to be modified or retrieved. +Mandatory for modifying scheduler parameters. + +=item B<-v VCPU>, B<--vcpu=VCPU> + +Specify the index of VCPU whose parameters will be set. +A domain can have multiple VCPUs; Each VCPU has a unique index in this domain; +When set domain's parameters, it needs to set each VCPU's parameters of this +domain. + +=item B<-p PERIOD>, B<--period=PERIOD> + +A VCPU replenish its budget in every period. Time unit is millisecond. + +=item B<-b BUDGET>, B<--budget=BUDGET> + +A VCPU has BUDGET amount of time to run for each period. +Time unit is millisecond. + +=item B<-c CPUPOOL>, B<--cpupool=CPUPOOL> + +Restrict output to domains in the specified cpupool. + +=back + =back =head1 CPUPOOLS COMMANDS diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h index 10a2e66..51b634a 100644 --- a/tools/libxl/xl.h +++ b/tools/libxl/xl.h @@ -67,6 +67,7 @@ int main_memset(int argc, char **argv); int main_sched_credit(int argc, char **argv); int main_sched_credit2(int argc, char **argv); int main_sched_sedf(int argc, char **argv); +int main_sched_rt(int argc, char **argv); int main_domid(int argc, char **argv); int main_domname(int argc, char **argv); int main_rename(int argc, char **argv); diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 68df548..c043f88 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -4947,6 +4947,7 @@ int main_sharing(int argc, char **argv) return 0; } + static int sched_domain_get(libxl_scheduler sched, int domid, libxl_domain_sched_params *scinfo) { @@ -5098,6 +5099,52 @@ static int sched_sedf_domain_output( return 0; } + +static int sched_rt_domain_output( + int domid) +{ + char *domname; + libxl_domain_sched_params scinfo; + int rc, i; + + if (domid < 0) { + printf("%-33s %4s %4s %6s %6s\n", "Name", "ID", "VCPU", "Period", "Budget"); + return 0; + } + + libxl_domain_sched_params_init(&scinfo); + rc = sched_domain_get(LIBXL_SCHEDULER_RT, domid, &scinfo); + if (rc) + return rc; + + domname = libxl_domid_to_name(ctx, domid); + for( i = 0; i < scinfo.rt.num_vcpus; i++ ) + { + printf("%-33s %4d %4d %6d %6d\n", + domname, + domid, + i, + scinfo.rt.vcpus[i].period, + scinfo.rt.vcpus[i].budget); + } + free(domname); + + libxl_domain_sched_params_dispose(&scinfo); + + return 0; +} + +static int sched_rt_pool_output(uint32_t poolid) +{ + char *poolname; + + poolname = libxl_cpupoolid_to_name(ctx, poolid); + printf("Cpupool %s: sched=EDF\n", poolname); + + free(poolname); + return 0; +} + static int sched_default_pool_output(uint32_t poolid) { char *poolname; @@ -5465,6 +5512,100 @@ int main_sched_sedf(int argc, char **argv) return 0; } +/* + * <nothing> : List all domain paramters and sched params + * -d [domid] : List domain params for domain + * -d [domid] [params] : Set domain params for domain + */ +int main_sched_rt(int argc, char **argv) +{ + const char *dom = NULL; + const char *cpupool = NULL; + int period = 10, opt_p = 0; + int budget = 4, opt_b = 0; + int vcpu_index = 0, opt_v = 0; + int opt, rc; + static struct option opts[] = { + {"domain", 1, 0, 'd'}, + {"period", 1, 0, 'p'}, + {"budget", 1, 0, 'b'}, + {"vcpu", 1, 0, 'v'}, + {"cpupool", 1, 0, 'c'}, + COMMON_LONG_OPTS, + {0, 0, 0, 0} + }; + + SWITCH_FOREACH_OPT(opt, "d:p:b:v:c:h", opts, "sched-rt", 0) { + case 'd': + dom = optarg; + break; + case 'p': + period = strtol(optarg, NULL, 10); + opt_p = 1; + break; + case 'b': + budget = strtol(optarg, NULL, 10); + opt_b = 1; + break; + case 'v': + vcpu_index = strtol(optarg, NULL, 10); + opt_v = 1; + break; + case 'c': + cpupool = optarg; + break; + } + + if (cpupool && (dom || opt_p || opt_b || opt_v)) { + fprintf(stderr, "Specifying a cpupool is not allowed with other options.\n"); + return 1; + } + if (!dom && (opt_p || opt_b || opt_v)) { + fprintf(stderr, "Must specify a domain.\n"); + return 1; + } + if ( (opt_v || opt_p || opt_b) && (opt_p + opt_b + opt_v != 3) ) { + fprintf(stderr, "Must specify vcpu, period, budget\n"); + return 1; + } + + if (!dom) { /* list all domain's rt scheduler info */ + return -sched_domain_output(LIBXL_SCHEDULER_RT, + sched_rt_domain_output, + sched_rt_pool_output, + cpupool); + } else { + uint32_t domid = find_domain(dom); + if (!opt_p && !opt_b && !opt_v) { /* output rt scheduler info */ + sched_rt_domain_output(-1); + return -sched_rt_domain_output(domid); + } else { /* set rt scheduler paramaters */ + libxl_domain_sched_params scinfo; + libxl_domain_sched_params_init(&scinfo); + scinfo.rt.max_vcpus = LIBXL_XEN_LEGACY_MAX_VCPUS; + /* TODO: only alloc an array with the same num of dom's vcpus*/ + scinfo.rt.num_vcpus = LIBXL_XEN_LEGACY_MAX_VCPUS; + scinfo.rt.vcpus = + (libxl_vcpu*) malloc( sizeof(libxl_vcpu) * scinfo.rt.max_vcpus ); + if ( scinfo.rt.vcpus == NULL ) { + fprintf(stderr, "Alloc memory for scinfo.rt.vcpus fails\n"); + return 1; + } + scinfo.sched = LIBXL_SCHEDULER_RT; + scinfo.rt.vcpu_index = vcpu_index; + scinfo.rt.vcpus[vcpu_index].period = period; + scinfo.rt.vcpus[vcpu_index].budget = budget; + + rc = sched_domain_set(domid, &scinfo); + libxl_domain_sched_params_dispose(&scinfo); + if (rc) + return -rc; + } + } + + return 0; +} + int main_domid(int argc, char **argv) { uint32_t domid; diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index 4279b9f..70e2585 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -277,6 +277,15 @@ struct cmd_spec cmd_table[] = { " --period/--slice)\n" "-c CPUPOOL, --cpupool=CPUPOOL Restrict output to CPUPOOL" }, + { "sched-rt", + &main_sched_rt, 0, 1, + "Get/set rt scheduler parameters", + "[-d <Domain> [-v[=VCPU]] [-p[=PERIOD]] [-b[=BUDGET]]]", + "-d DOMAIN, --domain=DOMAIN Domain to modify\n" + "-v VCPU, --vcpu=VCPU VCPU\n" + "-p PERIOD, --period=PERIOD Period (ms)\n" + "-b BUDGET, --budget=BUDGET Budget (ms)\n" + }, { "domid", &main_domid, 0, 0, "Convert a domain name to domain id", -- 1.7.9.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |