From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chao Peng Subject: Re: [PATCH v3 7/8] tools/libxl: introduce libxl_count_physical_sockets Date: Tue, 31 Mar 2015 16:51:22 +0800 Message-ID: <20150331085122.GB5816@pengc-linux.bj.intel.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> <20150330145101.GK25911@zion.uk.xensource.com> Reply-To: Chao Peng Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20150330145101.GK25911@zion.uk.xensource.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: Wei Liu 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, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org On Mon, Mar 30, 2015 at 03:51:01PM +0100, Wei Liu wrote: > 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); > Making it public is the need of supporting LIBXL_PSR_TARGET_ALL in libxl_psr_cat_set_cbm(), which is suggested by Ian as well. In such case, both xl/libxl need to get socket_count. Introduce it in libxl so that both can make use of it. Except this, I would like to adopt your suggestions(#ifdef to x86 only and return error code). Chao