From: Chao Peng <chao.p.peng@linux.intel.com>
To: xen-devel@lists.xen.org
Cc: wei.liu2@citrix.com, dario.faggioli@citrix.com,
Ian.Jackson@eu.citrix.com, Ian.Campbell@citrix.com,
stefano.stabellini@eu.citrix.com
Subject: [PATCH v2 for Xen 4.6 2/6] tools/libxl: fix socket display error for CMT
Date: Tue, 29 Sep 2015 15:49:51 +0800 [thread overview]
Message-ID: <1443512995-11853-3-git-send-email-chao.p.peng@linux.intel.com> (raw)
In-Reply-To: <1443512995-11853-1-git-send-email-chao.p.peng@linux.intel.com>
When displaying the CMT information for all the sockets, we assume socket
number is continuous. This is not true in the hotplug case. For instance,
when the 3rd socket is plugged out on a 4-socket system, the available
sockets numbers are 1,2,4 but current we will display the CMT
information for socket 1,2,3.
The fix is getting the socket bitmap for all the sockets on the system
first and then displaying CMT information for_each_set_bit in that bitmap.
Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
v2:
* add libxl_bitmap_init().
---
tools/libxl/xl_cmdimpl.c | 43 +++++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 2706759..f01d245 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -8192,7 +8192,7 @@ static int psr_cmt_get_mem_bandwidth(uint32_t domid,
static void psr_cmt_print_domain_info(libxl_dominfo *dominfo,
libxl_psr_cmt_type type,
- uint32_t nr_sockets)
+ libxl_bitmap *socketmap)
{
char *domain_name;
uint32_t socketid;
@@ -8205,7 +8205,7 @@ static void psr_cmt_print_domain_info(libxl_dominfo *dominfo,
printf("%-40s %5d", domain_name, dominfo->domid);
free(domain_name);
- for (socketid = 0; socketid < nr_sockets; socketid++) {
+ libxl_for_each_set_bit(socketid, *socketmap) {
switch (type) {
case LIBXL_PSR_CMT_TYPE_CACHE_OCCUPANCY:
if (!libxl_psr_cmt_get_sample(ctx, dominfo->domid, type, socketid,
@@ -8228,9 +8228,9 @@ static void psr_cmt_print_domain_info(libxl_dominfo *dominfo,
static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
{
- uint32_t i, socketid, nr_sockets, total_rmid;
+ uint32_t i, socketid, total_rmid;
uint32_t l3_cache_size;
- libxl_physinfo info;
+ libxl_bitmap socketmap;
int rc, nr_domains;
if (!libxl_psr_cmt_enabled(ctx)) {
@@ -8244,41 +8244,39 @@ static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
return -1;
}
- libxl_physinfo_init(&info);
- rc = libxl_get_physinfo(ctx, &info);
+ libxl_bitmap_init(&socketmap);
+ libxl_socket_bitmap_alloc(ctx, &socketmap, 0);
+ rc = libxl_get_online_socketmap(ctx, &socketmap);
if (rc < 0) {
- fprintf(stderr, "Failed getting physinfo, rc: %d\n", rc);
- libxl_physinfo_dispose(&info);
- return -1;
+ fprintf(stderr, "Failed getting available sockets, rc: %d\n", rc);
+ goto out;
}
- nr_sockets = info.nr_cpus / info.threads_per_core / info.cores_per_socket;
- libxl_physinfo_dispose(&info);
rc = libxl_psr_cmt_get_total_rmid(ctx, &total_rmid);
if (rc < 0) {
fprintf(stderr, "Failed to get max RMID value\n");
- return -1;
+ goto out;
}
printf("Total RMID: %d\n", total_rmid);
/* Header */
printf("%-40s %5s", "Name", "ID");
- for (socketid = 0; socketid < nr_sockets; socketid++)
+ libxl_for_each_set_bit(socketid, socketmap)
printf("%14s %d", "Socket", socketid);
printf("\n");
if (type == LIBXL_PSR_CMT_TYPE_CACHE_OCCUPANCY) {
/* Total L3 cache size */
printf("%-46s", "Total L3 Cache Size");
- for (socketid = 0; socketid < nr_sockets; socketid++) {
+ libxl_for_each_set_bit(socketid, socketmap) {
rc = libxl_psr_cmt_get_l3_cache_size(ctx, socketid,
&l3_cache_size);
if (rc < 0) {
fprintf(stderr,
"Failed to get system l3 cache size for socket:%d\n",
socketid);
- return -1;
+ goto out;
}
printf("%13u KB", l3_cache_size);
}
@@ -8292,9 +8290,10 @@ static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
libxl_dominfo_init(&dominfo);
if (libxl_domain_info(ctx, &dominfo, domid)) {
fprintf(stderr, "Failed to get domain info for %d\n", domid);
- return -1;
+ rc = -1;
+ goto out;
}
- psr_cmt_print_domain_info(&dominfo, type, nr_sockets);
+ psr_cmt_print_domain_info(&dominfo, type, &socketmap);
libxl_dominfo_dispose(&dominfo);
}
else
@@ -8302,13 +8301,17 @@ static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
libxl_dominfo *list;
if (!(list = libxl_list_domain(ctx, &nr_domains))) {
fprintf(stderr, "Failed to get domain info for domain list.\n");
- return -1;
+ rc = -1;
+ goto out;
}
for (i = 0; i < nr_domains; i++)
- psr_cmt_print_domain_info(list + i, type, nr_sockets);
+ psr_cmt_print_domain_info(list + i, type, &socketmap);
libxl_dominfo_list_free(list, nr_domains);
}
- return 0;
+
+out:
+ libxl_bitmap_dispose(&socketmap);
+ return rc;
}
int main_psr_cmt_attach(int argc, char **argv)
--
1.9.1
next prev parent reply other threads:[~2015-09-29 7:49 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-29 7:49 [PATCH v2 for Xen 4.6 0/6] Several PSR fixes in libxl Chao Peng
2015-09-29 7:49 ` [PATCH v2 for Xen 4.6 1/6] tools/libxl: introduce libxl_get_online_socketmap Chao Peng
2015-09-29 9:10 ` Dario Faggioli
2015-09-29 9:22 ` Wei Liu
2015-09-29 7:49 ` Chao Peng [this message]
2015-09-29 9:06 ` [PATCH v2 for Xen 4.6 2/6] tools/libxl: fix socket display error for CMT Dario Faggioli
2015-09-29 7:49 ` [PATCH v2 for Xen 4.6 3/6] tools/libxl: return socket id from libxl_psr_cat_get_l3_info Chao Peng
2015-09-29 9:09 ` Dario Faggioli
2015-09-29 9:22 ` Wei Liu
2015-09-29 7:49 ` [PATCH v2 for Xen 4.6 4/6] tools/libxl: fix range check in main_psr_cat_cbm_set Chao Peng
2015-09-29 7:49 ` [PATCH v2 for Xen 4.6 5/6] docs: make xl-psr.markdown more precise Chao Peng
2015-09-29 9:27 ` Andrew Cooper
2015-09-29 9:55 ` Ian Campbell
2015-09-30 1:34 ` Chao Peng
2015-09-30 8:57 ` Ian Campbell
2015-09-30 9:40 ` Chao Peng
2015-09-29 7:49 ` [PATCH v2 for Xen 4.6 6/6] docs/man: resort sections Chao Peng
2015-09-29 8:53 ` Dario Faggioli
2015-09-29 9:02 ` Wei Liu
2015-09-29 9:33 ` [PATCH v2 for Xen 4.6 0/6] Several PSR fixes in libxl Wei Liu
2015-09-29 10:30 ` Ian Campbell
2015-09-30 1:36 ` Chao Peng
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=1443512995-11853-3-git-send-email-chao.p.peng@linux.intel.com \
--to=chao.p.peng@linux.intel.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=dario.faggioli@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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).