[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 7/8] tools/libxl: introduce libxl_count_physical_sockets
Introduce a util function libxl_count_physical_sockets() to get physical socket count. Replaced CMT code with the new function in xl. Signed-off-by: Chao Peng <chao.p.peng@xxxxxxxxxxxxxxx> --- tools/libxl/libxl_utils.c | 17 +++++++++++++++++ tools/libxl/libxl_utils.h | 2 ++ tools/libxl/xl_cmdimpl.c | 11 +++-------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 9053b27..6dbc611 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -853,6 +853,23 @@ int libxl_get_online_cpus(libxl_ctx *ctx) return online_cpus < 0 ? ERROR_FAIL : online_cpus; } +uint32_t libxl_count_physical_sockets(libxl_ctx *ctx) +{ + int rc; + libxl_physinfo info; + uint32_t nr_sockets = 0; + + libxl_physinfo_init(&info); + + rc = libxl_get_physinfo(ctx, &info); + if (!rc) + nr_sockets = info.nr_cpus / info.threads_per_core + / info.cores_per_socket; + + libxl_physinfo_dispose(&info); + return nr_sockets; +} + int libxl_get_max_nodes(libxl_ctx *ctx) { int max_nodes = xc_get_max_nodes(ctx->xch); diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h index acacdd9..f664de1 100644 --- a/tools/libxl/libxl_utils.h +++ b/tools/libxl/libxl_utils.h @@ -154,6 +154,8 @@ int libxl_cpumap_to_nodemap(libxl_ctx *ctx, void libxl_string_copy(libxl_ctx *ctx, char **dst, char **src); +uint32_t libxl_count_physical_sockets(libxl_ctx *ctx); + #endif /* diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 04faf98..f26a02d 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -7899,7 +7899,6 @@ static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid) { uint32_t i, socketid, nr_sockets, total_rmid; uint32_t l3_cache_size; - libxl_physinfo info; int rc, nr_domains; if (!libxl_psr_cmt_enabled(ctx)) { @@ -7913,15 +7912,11 @@ 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); - if (rc < 0) { - fprintf(stderr, "Failed getting physinfo, rc: %d\n", rc); - libxl_physinfo_dispose(&info); + nr_sockets = libxl_count_physical_sockets(ctx); + if (nr_sockets == 0) { + fprintf(stderr, "Failed getting physinfo\n"); return -1; } - 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) { -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |