From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Anshul Makkar <anshul.makkar@citrix.com>,
Wei Liu <wei.liu2@citrix.com>
Subject: [PATCH 4/4] libxl/xl: allow to get and set cap on Credit2.
Date: Thu, 08 Jun 2017 14:09:09 +0200 [thread overview]
Message-ID: <149692374884.9605.7936271678792382781.stgit@Solace.fritz.box> (raw)
In-Reply-To: <149692186557.9605.11625777539060264052.stgit@Solace.fritz.box>
Note that a cap is considered valid only if
it is within the [1, nr_vcpus]% interval.
Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Anshul Makkar <anshul.makkar@citrix.com>
---
tools/libxl/libxl_sched.c | 21 +++++++++++++++++++++
tools/xl/xl_cmdtable.c | 1 +
tools/xl/xl_sched.c | 25 +++++++++++++++++--------
3 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/tools/libxl/libxl_sched.c b/tools/libxl/libxl_sched.c
index faa604e..7d144d0 100644
--- a/tools/libxl/libxl_sched.c
+++ b/tools/libxl/libxl_sched.c
@@ -405,6 +405,7 @@ static int sched_credit2_domain_get(libxl__gc *gc, uint32_t domid,
libxl_domain_sched_params_init(scinfo);
scinfo->sched = LIBXL_SCHEDULER_CREDIT2;
scinfo->weight = sdom.weight;
+ scinfo->cap = sdom.cap;
return 0;
}
@@ -413,8 +414,17 @@ static int sched_credit2_domain_set(libxl__gc *gc, uint32_t domid,
const libxl_domain_sched_params *scinfo)
{
struct xen_domctl_sched_credit2 sdom;
+ xc_domaininfo_t info;
int rc;
+ rc = xc_domain_getinfolist(CTX->xch, domid, 1, &info);
+ if (rc < 0) {
+ LOGED(ERROR, domid, "Getting domain info");
+ return ERROR_FAIL;
+ }
+ if (rc != 1 || info.domain != domid)
+ return ERROR_INVAL;
+
rc = xc_sched_credit2_domain_get(CTX->xch, domid, &sdom);
if (rc != 0) {
LOGED(ERROR, domid, "Getting domain sched credit2");
@@ -430,6 +440,17 @@ static int sched_credit2_domain_set(libxl__gc *gc, uint32_t domid,
sdom.weight = scinfo->weight;
}
+ if (scinfo->cap != LIBXL_DOMAIN_SCHED_PARAM_CAP_DEFAULT) {
+ if (scinfo->cap < 0
+ || scinfo->cap > (info.max_vcpu_id + 1) * 100) {
+ LOGD(ERROR, domid, "Cpu cap out of range, "
+ "valid range is from 0 to %d for specified number of vcpus",
+ ((info.max_vcpu_id + 1) * 100));
+ return ERROR_INVAL;
+ }
+ sdom.cap = scinfo->cap;
+ }
+
rc = xc_sched_credit2_domain_set(CTX->xch, domid, &sdom);
if ( rc < 0 ) {
LOGED(ERROR, domid, "Setting domain sched credit2");
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 30eb93c..2185ee6 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -265,6 +265,7 @@ struct cmd_spec cmd_table[] = {
"[-d <Domain> [-w[=WEIGHT]]] [-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"
"-r RLIMIT, --ratelimit_us=RLIMIT Set the scheduling rate limit, in microseconds\n"
"-p CPUPOOL, --cpupool=CPUPOOL Restrict output to CPUPOOL"
diff --git a/tools/xl/xl_sched.c b/tools/xl/xl_sched.c
index 85722fe..7fabce3 100644
--- a/tools/xl/xl_sched.c
+++ b/tools/xl/xl_sched.c
@@ -209,7 +209,7 @@ static int sched_credit2_domain_output(int domid)
libxl_domain_sched_params scinfo;
if (domid < 0) {
- printf("%-33s %4s %6s\n", "Name", "ID", "Weight");
+ printf("%-33s %4s %6s %4s\n", "Name", "ID", "Weight", "Cap");
return 0;
}
@@ -219,10 +219,11 @@ static int sched_credit2_domain_output(int domid)
return 1;
}
domname = libxl_domid_to_name(ctx, domid);
- printf("%-33s %4d %6d\n",
+ printf("%-33s %4d %6d %4d\n",
domname,
domid,
- scinfo.weight);
+ scinfo.weight,
+ scinfo.cap);
free(domname);
libxl_domain_sched_params_dispose(&scinfo);
return 0;
@@ -589,21 +590,23 @@ int main_sched_credit2(int argc, char **argv)
const char *dom = NULL;
const char *cpupool = NULL;
int ratelimit = 0;
- int weight = 256;
+ int weight = 256, cap = 0;
bool opt_s = false;
bool opt_r = false;
bool opt_w = false;
+ bool opt_c = false;
int opt, rc;
static struct option opts[] = {
{"domain", 1, 0, 'd'},
{"weight", 1, 0, 'w'},
+ {"cap", 1, 0, 'c'},
{"schedparam", 0, 0, 's'},
{"ratelimit_us", 1, 0, 'r'},
{"cpupool", 1, 0, 'p'},
COMMON_LONG_OPTS
};
- SWITCH_FOREACH_OPT(opt, "d:w:p:r:s", opts, "sched-credit2", 0) {
+ SWITCH_FOREACH_OPT(opt, "d:w:c:p:r:s", opts, "sched-credit2", 0) {
case 'd':
dom = optarg;
break;
@@ -611,6 +614,10 @@ int main_sched_credit2(int argc, char **argv)
weight = strtol(optarg, NULL, 10);
opt_w = true;
break;
+ case 'c':
+ cap = strtol(optarg, NULL, 10);
+ opt_c = true;
+ break;
case 's':
opt_s = true;
break;
@@ -623,12 +630,12 @@ int main_sched_credit2(int argc, char **argv)
break;
}
- if (cpupool && (dom || opt_w)) {
+ if (cpupool && (dom || opt_w || opt_c)) {
fprintf(stderr, "Specifying a cpupool is not allowed with other "
"options.\n");
return EXIT_FAILURE;
}
- if (!dom && opt_w) {
+ if (!dom && (opt_w || opt_c)) {
fprintf(stderr, "Must specify a domain.\n");
return EXIT_FAILURE;
}
@@ -663,7 +670,7 @@ int main_sched_credit2(int argc, char **argv)
} else {
uint32_t domid = find_domain(dom);
- if (!opt_w) { /* output credit2 scheduler info */
+ if (!opt_w && !opt_c) { /* output credit2 scheduler info */
sched_credit2_domain_output(-1);
if (sched_credit2_domain_output(domid))
return EXIT_FAILURE;
@@ -673,6 +680,8 @@ int main_sched_credit2(int argc, char **argv)
scinfo.sched = LIBXL_SCHEDULER_CREDIT2;
if (opt_w)
scinfo.weight = weight;
+ if (opt_c)
+ scinfo.cap = cap;
rc = sched_domain_set(domid, &scinfo);
libxl_domain_sched_params_dispose(&scinfo);
if (rc)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-06-08 12:09 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-08 12:08 [PATCH 0/4] xen/tools: Credit2: implement caps Dario Faggioli
2017-06-08 12:08 ` [PATCH 1/4] xen: credit2: implement utilization cap Dario Faggioli
2017-06-12 11:16 ` Anshul Makkar
2017-06-12 13:19 ` Dario Faggioli
2017-06-13 16:07 ` Anshul Makkar
2017-06-13 21:13 ` Dario Faggioli
2017-06-15 16:16 ` Anshul Makkar
2017-06-22 16:55 ` George Dunlap
2017-06-23 16:19 ` Dario Faggioli
2017-06-28 14:28 ` George Dunlap
2017-06-28 14:56 ` Dario Faggioli
2017-06-28 19:05 ` George Dunlap
2017-06-29 10:09 ` Dario Faggioli
2017-07-25 14:34 ` George Dunlap
2017-07-25 17:29 ` Dario Faggioli
2017-07-25 15:08 ` George Dunlap
2017-07-25 16:05 ` Dario Faggioli
2017-06-08 12:08 ` [PATCH 2/4] xen: credit2: allow to set and get " Dario Faggioli
2017-06-28 15:19 ` George Dunlap
2017-06-29 10:21 ` Dario Faggioli
2017-06-29 7:39 ` Alan Robinson
2017-06-29 8:26 ` George Dunlap
2017-06-08 12:09 ` [PATCH 3/4] xen: credit2: improve distribution of budget (for domains with caps) Dario Faggioli
2017-06-28 16:02 ` George Dunlap
2017-06-08 12:09 ` Dario Faggioli [this message]
2017-06-09 10:41 ` [PATCH 4/4] libxl/xl: allow to get and set cap on Credit2 Wei Liu
2017-06-28 18:43 ` George Dunlap
2017-06-29 10:22 ` Dario Faggioli
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=149692374884.9605.7936271678792382781.stgit@Solace.fritz.box \
--to=dario.faggioli@citrix.com \
--cc=anshul.makkar@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/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).