From: Chao Peng <chao.p.peng@linux.intel.com>
To: xen-devel@lists.xen.org
Cc: wei.liu2@citrix.com, Ian.Jackson@eu.citrix.com,
Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com
Subject: [PATCH for Xen 4.6 3/5] tools/libxl: return socket id from libxl_psr_cat_get_l3_info
Date: Mon, 28 Sep 2015 19:54:51 +0800 [thread overview]
Message-ID: <1443441293-4287-4-git-send-email-chao.p.peng@linux.intel.com> (raw)
In-Reply-To: <1443441293-4287-1-git-send-email-chao.p.peng@linux.intel.com>
The entries returned from libxl_psr_cat_get_l3_info are assumed
to be socket-continuous. But this is not true in the hotplug case.
This patch gets the socket bitmap for all the sockets on the system
first and stores the socket id in the structure libxl_psr_cat_info in
libxl_psr_cat_get_l3_info. The xl or similar consumers then can display
socket information correctly. For the sake of future extention, the
field added to libxl_psr_cat_info is named as target_id.
Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
---
tools/libxl/libxl_psr.c | 21 ++++++++++++++++-----
tools/libxl/libxl_types.idl | 1 +
tools/libxl/xl_cmdimpl.c | 37 +++++++++++++++++++------------------
3 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index 3378239..10e1113 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -339,7 +339,8 @@ int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
{
GC_INIT(ctx);
int rc;
- int i, nr_sockets;
+ int i = 0, socket, nr_sockets;
+ libxl_bitmap socketmap;
libxl_psr_cat_info *ptr;
rc = libxl__count_physical_sockets(gc, &nr_sockets);
@@ -348,21 +349,31 @@ int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
goto out;
}
+ libxl_socket_bitmap_alloc(ctx, &socketmap, nr_sockets);
+ rc = libxl_socket_bitmap_fill(ctx, &socketmap);
+ if (rc < 0) {
+ LOGE(ERROR, "failed to get available sockets");
+ goto out;
+ }
+
ptr = libxl__malloc(NOGC, nr_sockets * sizeof(libxl_psr_cat_info));
- for (i = 0; i < nr_sockets; i++) {
- if (xc_psr_cat_get_l3_info(ctx->xch, i, &ptr[i].cos_max,
- &ptr[i].cbm_len)) {
+ libxl_for_each_set_bit(socket, socketmap) {
+ ptr[i].target_id = socket;
+ if (xc_psr_cat_get_l3_info(ctx->xch, socket, &ptr[i].cos_max,
+ &ptr[i].cbm_len)) {
libxl__psr_cat_log_err_msg(gc, errno);
rc = ERROR_FAIL;
free(ptr);
goto out;
}
+ i++;
}
*info = ptr;
- *nr = nr_sockets;
+ *nr = i;
out:
+ libxl_bitmap_dispose(&socketmap);
GC_FREE;
return rc;
}
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 9f6ec00..c7bd425 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -792,6 +792,7 @@ libxl_psr_cbm_type = Enumeration("psr_cbm_type", [
])
libxl_psr_cat_info = Struct("psr_cat_info", [
+ ("target_id", uint32),
("cos_max", uint32),
("cbm_len", uint32),
])
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index c72d3df..cec0d2c 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -8383,35 +8383,37 @@ int main_psr_cmt_show(int argc, char **argv)
static int psr_cat_hwinfo(void)
{
int rc;
- int socketid, nr_sockets;
+ int i, nr;
uint32_t l3_cache_size;
libxl_psr_cat_info *info;
printf("Cache Allocation Technology (CAT):\n");
- rc = libxl_psr_cat_get_l3_info(ctx, &info, &nr_sockets);
+ rc = libxl_psr_cat_get_l3_info(ctx, &info, &nr);
if (rc) {
fprintf(stderr, "Failed to get cat info\n");
return rc;
}
- for (socketid = 0; socketid < nr_sockets; socketid++) {
- rc = libxl_psr_cmt_get_l3_cache_size(ctx, socketid, &l3_cache_size);
+ for (i = 0; i < nr; i++) {
+ rc = libxl_psr_cmt_get_l3_cache_size(ctx, info->target_id,
+ &l3_cache_size);
if (rc) {
fprintf(stderr, "Failed to get l3 cache size for socket:%d\n",
- socketid);
+ info->target_id);
goto out;
}
- printf("%-16s: %u\n", "Socket ID", socketid);
+ printf("%-16s: %u\n", "Socket ID", info->target_id);
printf("%-16s: %uKB\n", "L3 Cache", l3_cache_size);
printf("%-16s: %u\n", "Maximum COS", info->cos_max);
printf("%-16s: %u\n", "CBM length", info->cbm_len);
printf("%-16s: %#llx\n", "Default CBM",
(1ull << info->cbm_len) - 1);
+ info++;
}
out:
- libxl_psr_cat_info_list_free(info, nr_sockets);
+ libxl_psr_cat_info_list_free(info, nr);
return rc;
}
@@ -8453,47 +8455,46 @@ static int psr_cat_print_domain_cbm(uint32_t domid, uint32_t socketid)
return 0;
}
-static int psr_cat_print_socket(uint32_t domid, uint32_t socketid,
- libxl_psr_cat_info *info)
+static int psr_cat_print_socket(uint32_t domid, libxl_psr_cat_info *info)
{
int rc;
uint32_t l3_cache_size;
- rc = libxl_psr_cmt_get_l3_cache_size(ctx, socketid, &l3_cache_size);
+ rc = libxl_psr_cmt_get_l3_cache_size(ctx, info->target_id, &l3_cache_size);
if (rc) {
fprintf(stderr, "Failed to get l3 cache size for socket:%d\n",
- socketid);
+ info->target_id);
return -1;
}
- printf("%-16s: %u\n", "Socket ID", socketid);
+ printf("%-16s: %u\n", "Socket ID", info->target_id);
printf("%-16s: %uKB\n", "L3 Cache", l3_cache_size);
printf("%-16s: %#llx\n", "Default CBM", (1ull << info->cbm_len) - 1);
printf("%5s%25s%16s\n", "ID", "NAME", "CBM");
- return psr_cat_print_domain_cbm(domid, socketid);
+ return psr_cat_print_domain_cbm(domid, info->target_id);
}
static int psr_cat_show(uint32_t domid)
{
- int socketid, nr_sockets;
+ int i, nr;
int rc;
libxl_psr_cat_info *info;
- rc = libxl_psr_cat_get_l3_info(ctx, &info, &nr_sockets);
+ rc = libxl_psr_cat_get_l3_info(ctx, &info, &nr);
if (rc) {
fprintf(stderr, "Failed to get cat info\n");
return rc;
}
- for (socketid = 0; socketid < nr_sockets; socketid++) {
- rc = psr_cat_print_socket(domid, socketid, info + socketid);
+ for (i = 0; i < nr; i++) {
+ rc = psr_cat_print_socket(domid, info + i);
if (rc)
goto out;
}
out:
- libxl_psr_cat_info_list_free(info, nr_sockets);
+ libxl_psr_cat_info_list_free(info, nr);
return rc;
}
--
1.9.1
next prev parent reply other threads:[~2015-09-28 11:54 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-28 11:54 [PATCH for Xen 4.6 0/5] Several PSR fixes in libxl Chao Peng
2015-09-28 11:54 ` [PATCH for Xen 4.6 1/5] tools/libxl: introduce libxl_socket_bitmap_fill Chao Peng
2015-09-28 14:12 ` Wei Liu
2015-09-28 14:53 ` Dario Faggioli
2015-09-28 14:57 ` Wei Liu
2015-09-29 2:47 ` Chao Peng
2015-09-29 2:49 ` Chao Peng
2015-09-28 11:54 ` [PATCH for Xen 4.6 2/5] tools/libxl: fix socket display error for CMT Chao Peng
2015-09-28 14:13 ` Wei Liu
2015-09-28 15:06 ` Dario Faggioli
2015-09-28 15:36 ` Wei Liu
2015-09-29 2:53 ` Chao Peng
2015-09-28 11:54 ` Chao Peng [this message]
2015-09-28 14:13 ` [PATCH for Xen 4.6 3/5] tools/libxl: return socket id from libxl_psr_cat_get_l3_info Wei Liu
2015-09-28 15:35 ` Dario Faggioli
2015-09-28 15:46 ` Wei Liu
2015-09-29 3:05 ` Chao Peng
2015-09-29 7:19 ` Dario Faggioli
2015-09-28 11:54 ` [PATCH for Xen 4.6 4/5] tools/libxl: fix range check in main_psr_cat_cbm_set Chao Peng
2015-09-28 14:14 ` Wei Liu
2015-09-28 15:16 ` Dario Faggioli
2015-09-28 11:54 ` [PATCH for Xen 4.6 5/5] docs: make xl-psr.markdown more precise Chao Peng
2015-09-28 14:14 ` Wei Liu
2015-09-28 15:15 ` Dario Faggioli
2015-09-28 14:16 ` [PATCH for Xen 4.6 0/5] Several PSR fixes in libxl Wei Liu
2015-09-28 15:42 ` Dario Faggioli
2015-09-29 3:08 ` 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=1443441293-4287-4-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=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).