From: George Dunlap <george.dunlap@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: george.dunlap@eu.citrix.com
Subject: [PATCH 10 of 10] xl: Implement sched-credit schedule parameter command-line interface
Date: Tue, 21 Feb 2012 13:34:16 +0000 [thread overview]
Message-ID: <4f3e3d7016735b6c7a28.1329831256@kodo2> (raw)
In-Reply-To: <patchbomb.1329831246@kodo2>
Add features to the sched-credit interface to allow querying and
displaying scheduler parameters. New interface works as follows:
<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
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
diff -r 6dc39f1a7167 -r 4f3e3d701673 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Tue Feb 21 12:17:15 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c Tue Feb 21 12:17:18 2012 +0000
@@ -3936,6 +3936,30 @@ static int sched_credit_domain_set(
return rc;
}
+static int sched_credit_param_set(
+ int poolid, libxl_sched_credit_param *scinfo)
+{
+ int rc;
+
+ rc = libxl_sched_credit_param_set(ctx, poolid, scinfo);
+ if (rc)
+ fprintf(stderr, "libxl_sched_credit_param_set failed.\n");
+
+ return rc;
+}
+
+static int sched_credit_param_get(
+ int poolid, libxl_sched_credit_param *scinfo)
+{
+ int rc;
+
+ rc = libxl_sched_credit_param_get(ctx, poolid, scinfo);
+ if (rc)
+ fprintf(stderr, "libxl_sched_credit_domain_get failed.\n");
+
+ return rc;
+}
+
static int sched_credit_domain_output(
int domid)
{
@@ -3960,6 +3984,25 @@ static int sched_credit_domain_output(
return 0;
}
+static int sched_credit_pool_output(
+ uint32_t poolid)
+{
+ libxl_sched_credit_param scparam;
+ char *poolname;
+ int rc;
+
+ rc = sched_credit_param_get(poolid, &scparam);
+ if (rc)
+ return rc;
+ poolname = libxl_cpupoolid_to_name(ctx, poolid);
+ 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)
{
@@ -4123,25 +4166,41 @@ static int sched_domain_output(
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;
@@ -4159,6 +4218,17 @@ int main_sched_credit(int argc, char **a
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;
@@ -4168,20 +4238,54 @@ int main_sched_credit(int argc, char **a
}
}
- 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 (!dom) { /* list all domain's credit scheduler info */
+ if (!opt_s && (opt_t || opt_r)) {
+ fprintf(stderr, "Must specify schedparam to set schedule "
+ "parameter values.\n");
+ return 1;
+ }
+
+ if (opt_s) {
+ libxl_sched_credit_param 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_param_get(poolid, &scparam);
+ if (rc)
+ return -rc;
+
+ if (opt_t)
+ scparam.tslice_ms = tslice;
+
+ if (opt_r)
+ scparam.ratelimit_us = ratelimit;
+
+ rc = sched_credit_param_set(poolid, &scparam);
+ if (rc)
+ return -rc;
+ }
+ } else if (!dom) { /* list all domain's credit scheduler info */
return -sched_domain_output(XEN_SCHEDULER_CREDIT,
sched_credit_domain_output,
- sched_default_pool_output,
+ sched_credit_pool_output,
cpupool);
} else {
find_domain(dom);
diff -r 6dc39f1a7167 -r 4f3e3d701673 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Tue Feb 21 12:17:15 2012 +0000
+++ b/tools/libxl/xl_cmdtable.c Tue Feb 21 12:17:18 2012 +0000
@@ -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,
next prev parent reply other threads:[~2012-02-21 13:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-21 13:34 [PATCH 00 of 10] Allow user to configure credit scheduler parameters George Dunlap
2012-02-21 13:34 ` [PATCH 01 of 10] cleanup: Remove dependency files in efi directory during a make clean George Dunlap
2012-02-21 13:34 ` [PATCH 02 of 10] xen: Add a #define for the default ratelimit George Dunlap
2012-02-21 13:34 ` [PATCH 03 of 10] xen: Print ratelimit in scheduler debugkey George Dunlap
2012-02-21 13:34 ` [PATCH 04 of 10] xen: Implement SCHEDOP sysctl for credit scheduler George Dunlap
2012-02-21 13:34 ` [PATCH 05 of 10] libxc: " George Dunlap
2012-02-21 17:49 ` Ian Jackson
2012-02-21 13:34 ` [PATCH 06 of 10] libxl: cleanup: Remove pointless ERRNOVAL George Dunlap
2012-02-21 17:46 ` Ian Jackson
2012-02-21 13:34 ` [PATCH 07 of 10] libxl: Rename libxl_sched_* to include _domain George Dunlap
2012-02-21 17:52 ` Ian Jackson
2012-02-21 17:54 ` George Dunlap
2012-02-21 13:34 ` [PATCH 08 of 10] libxl: Implement libxl_sched_credit_param_[gs]et George Dunlap
2012-02-21 17:51 ` Ian Jackson
2012-02-21 17:56 ` George Dunlap
2012-02-21 17:57 ` Ian Jackson
2012-02-21 13:34 ` [PATCH 09 of 10] xl: Refactor sched_domain_output to have a callback for pool information George Dunlap
2012-02-21 17:49 ` Ian Jackson
2012-02-21 13:34 ` George Dunlap [this message]
2012-02-21 17:56 ` [PATCH 10 of 10] xl: Implement sched-credit schedule parameter command-line interface Ian Jackson
2012-02-21 18:11 ` George Dunlap
2012-02-21 18:17 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f3e3d7016735b6c7a28.1329831256@kodo2 \
--to=george.dunlap@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).