|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4/4] libxl/xl: allow to get and set cap on Credit2.
Note that a cap is considered valid only if
it is within the [1, nr_vcpus]% interval.
Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
---
Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
Cc: Anshul Makkar <anshul.makkar@xxxxxxxxxx>
---
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@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |