aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Dunlap <george.dunlap@eu.citrix.com>2012-03-14 14:06:04 +0000
committerGeorge Dunlap <george.dunlap@eu.citrix.com>2012-03-14 14:06:04 +0000
commite05b3ee53b7d27e82f1227adf398d46a8511f9d9 (patch)
treea0a74b4ceac8e2bb45c317f36c4110fdfa409756
parent266e2c6682517f56310e5fb2c7890a286d0499a6 (diff)
downloadxen-e05b3ee53b7d27e82f1227adf398d46a8511f9d9.tar.gz
xen-e05b3ee53b7d27e82f1227adf398d46a8511f9d9.tar.bz2
xen-e05b3ee53b7d27e82f1227adf398d46a8511f9d9.zip
xl: Implement sched-credit schedule parameter command-line interface
Add features to the sched-credit interface to allow querying and displaying scheduler parameters. Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
-rw-r--r--docs/man/xl.pod.147
-rw-r--r--tools/libxl/xl_cmdimpl.c125
-rw-r--r--tools/libxl/xl_cmdtable.c13
3 files changed, 168 insertions, 17 deletions
diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1
index 7802a027c8..2ab8418a00 100644
--- a/docs/man/xl.pod.1
+++ b/docs/man/xl.pod.1
@@ -714,6 +714,53 @@ no upper cap.
Restrict output to domains in the specified cpupool.
+=item B<-s>, B<--schedparam>
+
+Specify to list or set pool-wide scheduler parameters.
+
+=item B<-t TSLICE>, B<--tslice_ms=TSLICE>
+
+Timeslice tells the scheduler how long to allow VMs to run before
+pre-empting. The default is 30ms. Valid ranges are 1ms to 1000ms.
+The length of the timeslice (in ms) must be higher than the length of
+the ratelimit (see below).
+
+=item B<-r RLIMIT>, B<--ratelimit_us=RLIMIT>
+
+Ratelimit attempts to limit the number of schedules per second. It
+sets a minimum amount of time (in microseconds) a VM must run before
+we will allow a higher-prioirty VM to pre-empt it. The default value
+is 1000 microseconds (1ms). Valid range is 100 to 500000 (500ms).
+The ratelimit length must be lower than the timeslice length.
+
+=back
+
+B<COMBINATION>
+
+The following is the effect of combining the above options:
+
+=over 4
+
+=item B<E<lt>nothingE<gt>> : List all domain params and sched params from all pools
+
+=item B<-d [domid]> : List domain params for domain [domid]
+
+=item B<-d [domid] [params]> : Set domain params for domain [domid]
+
+=item B<-p [pool]> : list all domains and sched params for [pool]
+
+=item B<-s> : List sched params for poolid 0
+
+=item B<-s [params]> : Set sched params for poolid 0
+
+=item B<-p [pool] -s> : List sched params for [pool]
+
+=item B<-p [pool] -s [params]> : Set sched params for [pool]
+
+=item B<-p [pool] -d>... : Illegal
+
+=item
+
=back
=item B<sched-credit2> [I<OPTIONS>]
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 30972879db..1d59b89b4d 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3906,8 +3906,7 @@ int main_sharing(int argc, char **argv)
return 0;
}
-static int sched_credit_domain_get(
- int domid, libxl_sched_credit_domain *scinfo)
+static int sched_credit_domain_get(int domid, libxl_sched_credit_domain *scinfo)
{
int rc;
@@ -3918,8 +3917,7 @@ static int sched_credit_domain_get(
return rc;
}
-static int sched_credit_domain_set(
- int domid, libxl_sched_credit_domain *scinfo)
+static int sched_credit_domain_set(int domid, libxl_sched_credit_domain *scinfo)
{
int rc;
@@ -3931,8 +3929,29 @@ static int sched_credit_domain_set(
return rc;
}
-static int sched_credit_domain_output(
- int domid)
+static int sched_credit_params_set(int poolid, libxl_sched_credit_params *scinfo)
+{
+ int rc;
+
+ rc = libxl_sched_credit_params_set(ctx, poolid, scinfo);
+ if (rc)
+ fprintf(stderr, "libxl_sched_credit_params_set failed.\n");
+
+ return rc;
+}
+
+static int sched_credit_params_get(int poolid, libxl_sched_credit_params *scinfo)
+{
+ int rc;
+
+ rc = libxl_sched_credit_params_get(ctx, poolid, scinfo);
+ if (rc)
+ fprintf(stderr, "libxl_sched_credit_params_get failed.\n");
+
+ return rc;
+}
+
+static int sched_credit_domain_output(int domid)
{
char *domname;
libxl_sched_credit_domain scinfo;
@@ -3956,6 +3975,27 @@ static int sched_credit_domain_output(
return 0;
}
+static int sched_credit_pool_output(uint32_t poolid)
+{
+ libxl_sched_credit_params scparam;
+ char *poolname;
+ int rc;
+
+ poolname = libxl_cpupoolid_to_name(ctx, poolid);
+ rc = sched_credit_params_get(poolid, &scparam);
+ if (rc) {
+ printf("Cpupool %s: [sched params unavailable]\n",
+ poolname);
+ } else {
+ printf("Cpupool %s: tslice=%dms ratelimit=%dus\n",
+ poolname,
+ scparam.tslice_ms,
+ scparam.ratelimit_us);
+ }
+ free(poolname);
+ return 0;
+}
+
static int sched_credit2_domain_get(
int domid, libxl_sched_credit2_domain *scinfo)
{
@@ -4119,25 +4159,41 @@ static int sched_domain_output(libxl_scheduler sched, int (*output)(int),
return 0;
}
+/*
+ * <nothing> : List all domain params and sched params from all pools
+ * -d [domid] : List domain params for domain
+ * -d [domid] [params] : Set domain params for domain
+ * -p [pool] : list all domains and sched params for pool
+ * -s : List sched params for poolid 0
+ * -s [params] : Set sched params for poolid 0
+ * -p [pool] -s : List sched params for pool
+ * -p [pool] -s [params] : Set sched params for pool
+ * -p [pool] -d... : Illegal
+ */
int main_sched_credit(int argc, char **argv)
{
libxl_sched_credit_domain scinfo;
const char *dom = NULL;
const char *cpupool = NULL;
int weight = 256, cap = 0, opt_w = 0, opt_c = 0;
+ int opt_s = 0;
+ int tslice = 0, opt_t = 0, ratelimit = 0, opt_r = 0;
int opt, rc;
int option_index = 0;
static struct option long_options[] = {
{"domain", 1, 0, 'd'},
{"weight", 1, 0, 'w'},
{"cap", 1, 0, 'c'},
+ {"schedparam", 0, 0, 's'},
+ {"tslice_ms", 1, 0, 't'},
+ {"ratelimit_us", 1, 0, 'r'},
{"cpupool", 1, 0, 'p'},
{"help", 0, 0, 'h'},
{0, 0, 0, 0}
};
while (1) {
- opt = getopt_long(argc, argv, "d:w:c:p:h", long_options,
+ opt = getopt_long(argc, argv, "d:w:c:p:t:r:hs", long_options,
&option_index);
if (opt == -1)
break;
@@ -4155,6 +4211,17 @@ int main_sched_credit(int argc, char **argv)
cap = strtol(optarg, NULL, 10);
opt_c = 1;
break;
+ case 't':
+ tslice = strtol(optarg, NULL, 10);
+ opt_t = 1;
+ break;
+ case 'r':
+ ratelimit = strtol(optarg, NULL, 10);
+ opt_r = 1;
+ break;
+ case 's':
+ opt_s = 1;
+ break;
case 'p':
cpupool = optarg;
break;
@@ -4164,20 +4231,54 @@ int main_sched_credit(int argc, char **argv)
}
}
- if (cpupool && (dom || opt_w || opt_c)) {
- fprintf(stderr, "Specifying a cpupool is not allowed with other "
- "options.\n");
+ if ((cpupool || opt_s) && (dom || opt_w || opt_c)) {
+ fprintf(stderr, "Specifying a cpupool or schedparam is not "
+ "allowed with domain options.\n");
return 1;
}
if (!dom && (opt_w || opt_c)) {
fprintf(stderr, "Must specify a domain.\n");
return 1;
}
+ if (!opt_s && (opt_t || opt_r)) {
+ fprintf(stderr, "Must specify schedparam to set schedule "
+ "parameter values.\n");
+ return 1;
+ }
- if (!dom) { /* list all domain's credit scheduler info */
+ if (opt_s) {
+ libxl_sched_credit_params scparam;
+ uint32_t poolid = 0;
+
+ if (cpupool) {
+ if (cpupool_qualifier_to_cpupoolid(cpupool, &poolid, NULL) ||
+ !libxl_cpupoolid_to_name(ctx, poolid)) {
+ fprintf(stderr, "unknown cpupool \'%s\'\n", cpupool);
+ return -ERROR_FAIL;
+ }
+ }
+
+ if (!opt_t && !opt_r) { /* Output scheduling parameters */
+ return -sched_credit_pool_output(poolid);
+ } else { /* Set scheduling parameters*/
+ rc = sched_credit_params_get(poolid, &scparam);
+ if (rc)
+ return -rc;
+
+ if (opt_t)
+ scparam.tslice_ms = tslice;
+
+ if (opt_r)
+ scparam.ratelimit_us = ratelimit;
+
+ rc = sched_credit_params_set(poolid, &scparam);
+ if (rc)
+ return -rc;
+ }
+ } else if (!dom) { /* list all domain's credit scheduler info */
return -sched_domain_output(LIBXL_SCHEDULER_CREDIT,
sched_credit_domain_output,
- sched_default_pool_output,
+ sched_credit_pool_output,
cpupool);
} else {
find_domain(dom);
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index 888180954a..352ea87951 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -204,11 +204,14 @@ struct cmd_spec cmd_table[] = {
{ "sched-credit",
&main_sched_credit, 0,
"Get/set credit scheduler parameters",
- "[-d <Domain> [-w[=WEIGHT]|-c[=CAP]]] [-p CPUPOOL]",
- "-d DOMAIN, --domain=DOMAIN Domain to modify\n"
- "-w WEIGHT, --weight=WEIGHT Weight (int)\n"
- "-c CAP, --cap=CAP Cap (int)\n"
- "-p CPUPOOL, --cpupool=CPUPOOL Restrict output to CPUPOOL"
+ "[-d <Domain> [-w[=WEIGHT]|-c[=CAP]]] [-s [-t TSLICE] [-r RATELIMIT]] [-p CPUPOOL]",
+ "-d DOMAIN, --domain=DOMAIN Domain to modify\n"
+ "-w WEIGHT, --weight=WEIGHT Weight (int)\n"
+ "-c CAP, --cap=CAP Cap (int)\n"
+ "-s --schedparam Query / modify scheduler parameters\n"
+ "-t TSLICE, --tslice_ms=TSLICE Set the timeslice, in milliseconds\n"
+ "-r RLIMIT, --ratelimit_us=RLIMIT Set the scheduling rate limit, in microseconds\n"
+ "-p CPUPOOL, --cpupool=CPUPOOL Restrict output to CPUPOOL"
},
{ "sched-credit2",
&main_sched_credit2, 0,