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 1/6] tools/libxl: introduce libxl_get_online_socketmap
Date: Tue, 29 Sep 2015 15:49:50 +0800 [thread overview]
Message-ID: <1443512995-11853-2-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>
It sets the bit on the given bitmap if the corresponding socket is
available and clears the bit when the corresponding socket is not
available.
Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
---
v2:
* rename libxl_socket_bitmap_fill => libxl_get_online_socketmap.
* fix blanklines.
NOTE:LIBXL_HAVE_SOCKET_BITMAP_ALLOC is changed as we are still in 4.6 release cycle.
---
tools/libxl/libxl.h | 7 ++++---
tools/libxl/libxl_utils.c | 22 ++++++++++++++++++++++
tools/libxl/libxl_utils.h | 2 ++
3 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 5f9047c..fa5aedd 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -807,11 +807,12 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);
#define LIBXL_HAVE_PCITOPOLOGY 1
/*
- * LIBXL_HAVE_SOCKET_BITMAP_ALLOC
+ * LIBXL_HAVE_SOCKET_BITMAP
*
- * If this is defined, then libxl_socket_bitmap_alloc exists.
+ * If this is defined, then libxl_socket_bitmap_alloc and
+ * libxl_get_online_socketmap exist.
*/
-#define LIBXL_HAVE_SOCKET_BITMAP_ALLOC 1
+#define LIBXL_HAVE_SOCKET_BITMAP 1
/*
* LIBXL_HAVE_SRM_V2
diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
index bfc9699..408ec85 100644
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -886,6 +886,28 @@ int libxl_socket_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *socketmap,
}
+int libxl_get_online_socketmap(libxl_ctx *ctx, libxl_bitmap *socketmap)
+{
+ libxl_cputopology *tinfo = NULL;
+ int nr_cpus = 0, i, rc = 0;
+
+ tinfo = libxl_get_cpu_topology(ctx, &nr_cpus);
+ if (tinfo == NULL) {
+ rc = ERROR_FAIL;
+ goto out;
+ }
+
+ libxl_bitmap_set_none(socketmap);
+ for (i = 0; i < nr_cpus; i++)
+ if (tinfo[i].socket != XEN_INVALID_SOCKET_ID
+ && !libxl_bitmap_test(socketmap, tinfo[i].socket))
+ libxl_bitmap_set(socketmap, tinfo[i].socket);
+
+ out:
+ libxl_cputopology_list_free(tinfo, nr_cpus);
+ return rc;
+}
+
int libxl_nodemap_to_cpumap(libxl_ctx *ctx,
const libxl_bitmap *nodemap,
libxl_bitmap *cpumap)
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
index 1e5ca8a..339ebdf 100644
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -143,6 +143,8 @@ int libxl_node_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *nodemap,
int max_nodes);
int libxl_socket_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *socketmap,
int max_sockets);
+/* Fill socketmap with the CPU topology information on the system. */
+int libxl_get_online_socketmap(libxl_ctx *ctx, libxl_bitmap *socketmap);
/* Populate cpumap with the cpus spanned by the nodes in nodemap */
int libxl_nodemap_to_cpumap(libxl_ctx *ctx,
--
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 ` Chao Peng [this message]
2015-09-29 9:10 ` [PATCH v2 for Xen 4.6 1/6] tools/libxl: introduce libxl_get_online_socketmap Dario Faggioli
2015-09-29 9:22 ` Wei Liu
2015-09-29 7:49 ` [PATCH v2 for Xen 4.6 2/6] tools/libxl: fix socket display error for CMT Chao Peng
2015-09-29 9:06 ` 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-2-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).