From: "Jan Beulich" Subject: Re: [PATCH v4 11/21] hvmloader: retrieve vNUMA information from hypervisor Date: Fri, 23 Jan 2015 13:27:27 +0000 Message-ID: <54C25A4F0200007800058D1A@mail.emea.novell.com> References: <1422011632-22018-1-git-send-email-wei.liu2@citrix.com> <1422011632-22018-12-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1422011632-22018-12-git-send-email-wei.liu2@citrix.com> Content-Disposition: inline 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: ian.campbell@citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, xen-devel@lists.xen.org, ufimtseva@gmail.com List-Id: xen-devel@lists.xenproject.org >>> On 23.01.15 at 12:13, wrote: > Changes in v4: > 1. Use *vnode_to_pnode to calculate size. > 2. Remove loop. > 3. TBD: rebase onto Jan's errno ABI change. Which went in already. > +void init_vnuma_info(void) > +{ > + int rc; > + struct xen_vnuma_topology_info vnuma_topo; > + > + vcpu_to_vnode = > + scratch_alloc(sizeof(*vcpu_to_vnode) * hvm_info->nr_vcpus, 0); Why is this not done together with the other two allocs below, avoiding it when the probing hypercall fails? > + vnuma_topo.domid = DOMID_SELF; > + vnuma_topo.pad = 0; > + vnuma_topo.nr_vcpus = 0; > + vnuma_topo.nr_vnodes = 0; > + vnuma_topo.nr_vmemranges = 0; > + > + set_xen_guest_handle(vnuma_topo.vdistance.h, NULL); > + set_xen_guest_handle(vnuma_topo.vcpu_to_vnode.h, NULL); > + set_xen_guest_handle(vnuma_topo.vmemrange.h, NULL); Perhaps easier to just memset() the whole thing to zero, and the set .domid? > + > + rc = hypercall_memory_op(XENMEM_get_vnumainfo, &vnuma_topo); > + > + if ( rc != -XEN_ENOBUFS ) > + return; > + > + ASSERT(vnuma_topo.nr_vcpus == hvm_info->nr_vcpus); > + > + vdistance = scratch_alloc(sizeof(uint32_t) * vnuma_topo.nr_vnodes * > + vnuma_topo.nr_vnodes, 0); > + vmemrange = scratch_alloc(sizeof(xen_vmemrange_t) * > + vnuma_topo.nr_vmemranges, 0); > + > + set_xen_guest_handle(vnuma_topo.vdistance.h, vdistance); > + set_xen_guest_handle(vnuma_topo.vcpu_to_vnode.h, vcpu_to_vnode); > + set_xen_guest_handle(vnuma_topo.vmemrange.h, vmemrange); > + > + rc = hypercall_memory_op(XENMEM_get_vnumainfo, &vnuma_topo); > + > + if ( rc < 0 ) > + { > + printf("Failed to retrieve vNUMA information, rc = %d\n", rc); > + return; > + } > + > + nr_vnodes = vnuma_topo.nr_vnodes; > + nr_vmemranges = vnuma_topo.nr_vmemranges; > + > + return; > +} Please drop this pointless "return". Jan