From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH v3 7/8] tools/libxl: introduce libxl_count_physical_sockets Date: Mon, 30 Mar 2015 15:51:01 +0100 Message-ID: <20150330145101.GK25911@zion.uk.xensource.com> References: <1427373505-9303-1-git-send-email-chao.p.peng@linux.intel.com> <1427373505-9303-8-git-send-email-chao.p.peng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1427373505-9303-8-git-send-email-chao.p.peng@linux.intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Chao Peng Cc: keir@xen.org, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org, will.auld@intel.com, JBeulich@suse.com, wei.liu2@citrix.com, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org On Thu, Mar 26, 2015 at 08:38:24PM +0800, Chao Peng wrote: > 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 > --- > 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; > +} > + This function looks x86 centric. If I'm right then it should be surrounded by #ifdef. I think Ian suggested you make this an internal function not a public API. But if I misunderstand Ian's intention, please make this function return libxl error code. The socket number can be returned from an out parameter. I.e. int libxl_count_physical_sockets(libxl_ctx *ctx, uint32_t *nr_sockets); Wei.