From: Juergen Gross <juergen.gross@ts.fujitsu.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH 2 of 5] Support cpupools in xl sched-credit
Date: Mon, 28 Nov 2011 13:46:01 +0100 [thread overview]
Message-ID: <8bb677cf78c3868c96e9.1322484361@nehalem1> (raw)
In-Reply-To: <patchbomb.1322484359@nehalem1>
[-- Attachment #1: Type: text/plain, Size: 618 bytes --]
Adds cpupool awareness to output of xl sched-credit. Output can now be
restricted to a specific cpupool. The domains are printed for each cpupool
seperately.
The loop over cpupools and domains is seperated from the main command
implementation to be able to support other schedulers as well.
Signed-off-by: juergen.gross@ts.fujitsu.com
5 files changed, 101 insertions(+), 30 deletions(-)
docs/man/xl.pod.1 | 4 +
tools/libxl/libxl.c | 1
tools/libxl/libxl_types.idl | 1
tools/libxl/xl_cmdimpl.c | 120 ++++++++++++++++++++++++++++++++-----------
tools/libxl/xl_cmdtable.c | 5 +
[-- Attachment #2: xen-staging.hg-5.patch --]
[-- Type: text/x-patch, Size: 7992 bytes --]
# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# Date 1322483235 -3600
# Node ID 8bb677cf78c3868c96e97962477f229367f01dd6
# Parent 3a817a14e6a29657c8f798987ccb1568a586ea70
Support cpupools in xl sched-credit
Adds cpupool awareness to output of xl sched-credit. Output can now be
restricted to a specific cpupool. The domains are printed for each cpupool
seperately.
The loop over cpupools and domains is seperated from the main command
implementation to be able to support other schedulers as well.
Signed-off-by: juergen.gross@ts.fujitsu.com
diff -r 3a817a14e6a2 -r 8bb677cf78c3 docs/man/xl.pod.1
--- a/docs/man/xl.pod.1 Mon Nov 28 13:23:31 2011 +0100
+++ b/docs/man/xl.pod.1 Mon Nov 28 13:27:15 2011 +0100
@@ -610,6 +610,10 @@ 50 is half a CPU, 400 is 4 CPUs, etc. Th
50 is half a CPU, 400 is 4 CPUs, etc. The default, 0, means there is
no upper cap.
+=item B<-p CPUPOOL>, B<--cpupool=CPUPOOL>
+
+Restrict output to domains in the specified cpupool.
+
=back
=back
diff -r 3a817a14e6a2 -r 8bb677cf78c3 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Mon Nov 28 13:23:31 2011 +0100
+++ b/tools/libxl/libxl.c Mon Nov 28 13:27:15 2011 +0100
@@ -361,6 +361,7 @@ static void xcinfo2xlinfo(const xc_domai
xlinfo->cpu_time = xcinfo->cpu_time;
xlinfo->vcpu_max_id = xcinfo->max_vcpu_id;
xlinfo->vcpu_online = xcinfo->nr_online_vcpus;
+ xlinfo->cpupool = xcinfo->cpupool;
}
libxl_dominfo * libxl_list_domain(libxl_ctx *ctx, int *nb_domain)
diff -r 3a817a14e6a2 -r 8bb677cf78c3 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl Mon Nov 28 13:23:31 2011 +0100
+++ b/tools/libxl/libxl_types.idl Mon Nov 28 13:27:15 2011 +0100
@@ -109,6 +109,7 @@ SHUTDOWN_* constant."""),
("cpu_time", uint64),
("vcpu_max_id", uint32),
("vcpu_online", uint32),
+ ("cpupool", uint32),
], dispose_fn=None)
libxl_cpupoolinfo = Struct("cpupoolinfo", [
diff -r 3a817a14e6a2 -r 8bb677cf78c3 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Mon Nov 28 13:23:31 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c Mon Nov 28 13:27:15 2011 +0100
@@ -3699,25 +3699,90 @@ static int sched_credit_domain_set(
return rc;
}
-static void sched_credit_domain_output(
- int domid, libxl_sched_credit *scinfo)
+static int sched_credit_domain_output(
+ int domid)
{
char *domname;
+ libxl_sched_credit scinfo;
+ int rc;
+
+ if (domid < 0) {
+ printf("%-33s %4s %6s %4s\n", "Name", "ID", "Weight", "Cap");
+ return 0;
+ }
+ rc = sched_credit_domain_get(domid, &scinfo);
+ if (rc)
+ return rc;
domname = libxl_domid_to_name(ctx, domid);
printf("%-33s %4d %6d %4d\n",
domname,
domid,
- scinfo->weight,
- scinfo->cap);
+ scinfo.weight,
+ scinfo.cap);
free(domname);
+ return 0;
+}
+
+static int sched_domain_output(
+ uint32_t sched, int (*output)(int), const char *cpupool)
+{
+ libxl_dominfo *info;
+ libxl_cpupoolinfo *poolinfo = NULL;
+ uint32_t poolid;
+ char *poolname;
+ int nb_domain, n_pools = 0, i, p;
+ int rc = 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;
+ }
+ }
+
+ info = libxl_list_domain(ctx, &nb_domain);
+ if (!info) {
+ fprintf(stderr, "libxl_domain_infolist failed.\n");
+ return 1;
+ }
+ poolinfo = libxl_list_cpupool(ctx, &n_pools);
+ if (!poolinfo) {
+ fprintf(stderr, "error getting cpupool info\n");
+ return -ERROR_NOMEM;
+ }
+
+ for (p = 0; !rc && (p < n_pools); p++) {
+ if ((poolinfo[p].sched_id != sched) ||
+ (cpupool && (poolid != poolinfo[p].poolid)))
+ continue;
+
+ poolname = libxl_cpupoolid_to_name(ctx, poolinfo[p].poolid);
+ printf("Cpupool %s:\n", poolname);
+ free(poolname);
+
+ output(-1);
+ for (i = 0; i < nb_domain; i++) {
+ if (info[i].cpupool != poolinfo[p].poolid)
+ continue;
+ rc = output(info[i].domid);
+ if (rc)
+ break;
+ }
+ }
+ if (poolinfo) {
+ for (p = 0; p < n_pools; p++) {
+ libxl_cpupoolinfo_dispose(poolinfo + p);
+ }
+ }
+ return 0;
}
int main_sched_credit(int argc, char **argv)
{
- libxl_dominfo *info;
libxl_sched_credit scinfo;
- int nb_domain, i;
- const char *dom = NULL;
+ const char *dom = NULL;
+ const char *cpupool = NULL;
int weight = 256, cap = 0, opt_w = 0, opt_c = 0;
int opt, rc;
int option_index = 0;
@@ -3725,12 +3790,14 @@ int main_sched_credit(int argc, char **a
{"domain", 1, 0, 'd'},
{"weight", 1, 0, 'w'},
{"cap", 1, 0, 'c'},
- {"help", 0, 0, 'h'},
- {0, 0, 0, 0}
- };
-
- while (1) {
- opt = getopt_long(argc, argv, "d:w:c:h", long_options, &option_index);
+ {"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,
+ &option_index);
if (opt == -1)
break;
switch (opt) {
@@ -3747,31 +3814,28 @@ int main_sched_credit(int argc, char **a
cap = strtol(optarg, NULL, 10);
opt_c = 1;
break;
+ case 'p':
+ cpupool = optarg;
+ break;
case 'h':
help("sched-credit");
return 0;
}
}
+ if (cpupool && (dom || opt_w || opt_c)) {
+ fprintf(stderr, "Specifying a cpupool is not allowed with other "
+ "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 */
- info = libxl_list_domain(ctx, &nb_domain);
- if (!info) {
- fprintf(stderr, "libxl_domain_infolist failed.\n");
- return 1;
- }
-
- printf("%-33s %4s %6s %4s\n", "Name", "ID", "Weight", "Cap");
- for (i = 0; i < nb_domain; i++) {
- rc = sched_credit_domain_get(info[i].domid, &scinfo);
- if (rc)
- return -rc;
- sched_credit_domain_output(info[i].domid, &scinfo);
- }
+ return -sched_domain_output(XEN_SCHEDULER_CREDIT,
+ sched_credit_domain_output, cpupool);
} else {
find_domain(dom);
@@ -3780,8 +3844,8 @@ int main_sched_credit(int argc, char **a
return -rc;
if (!opt_w && !opt_c) { /* output credit scheduler info */
- printf("%-33s %4s %6s %4s\n", "Name", "ID", "Weight", "Cap");
- sched_credit_domain_output(domid, &scinfo);
+ sched_credit_domain_output(-1);
+ return -sched_credit_domain_output(domid);
} else { /* set credit scheduler paramaters */
if (opt_w)
scinfo.weight = weight;
diff -r 3a817a14e6a2 -r 8bb677cf78c3 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Mon Nov 28 13:23:31 2011 +0100
+++ b/tools/libxl/xl_cmdtable.c Mon Nov 28 13:27:15 2011 +0100
@@ -192,10 +192,11 @@ struct cmd_spec cmd_table[] = {
{ "sched-credit",
&main_sched_credit, 0,
"Get/set credit scheduler parameters",
- "[-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]",
+ "[-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)"
+ "-c CAP, --cap=CAP Cap (int)\n"
+ "-p CPUPOOL, --cpupool=CPUPOOL Restrict output to CPUPOOL"
},
{ "domid",
&main_domid, 0,
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2011-11-28 12:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-28 12:45 [PATCH 0 of 5] v2: xl scheduler support Juergen Gross
2011-11-28 12:46 ` [PATCH 1 of 5] xl sched-credit: support long options Juergen Gross
2011-11-28 12:46 ` Juergen Gross [this message]
2011-11-28 12:46 ` [PATCH 3 of 5] Support of xl sched-credit2 Juergen Gross
2011-11-28 12:46 ` [PATCH 4 of 5] Correct error message in libxl_sched_credit_domain_get() Juergen Gross
2011-11-28 12:46 ` [PATCH 5 of 5] Support of xl sched-sedf Juergen Gross
2011-12-01 18:41 ` [PATCH 0 of 5] v2: xl scheduler support Ian Jackson
-- strict thread matches above, loose matches on Subject: below --
2011-11-17 12:00 [PATCH 0 of 5] " Juergen Gross
2011-11-17 12:00 ` [PATCH 2 of 5] Support cpupools in xl sched-credit Juergen Gross
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=8bb677cf78c3868c96e9.1322484361@nehalem1 \
--to=juergen.gross@ts.fujitsu.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).