From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Ostrovsky Subject: Re: [PATCH v3 3/4] libxc: rework vnuma bits in setup_guest Date: Mon, 01 Jun 2015 16:18:28 -0400 Message-ID: <556CBE14.3010509@oracle.com> References: <1433153954-27994-1-git-send-email-wei.liu2@citrix.com> <1433153954-27994-4-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YzWAW-00072Y-5J for xen-devel@lists.xenproject.org; Mon, 01 Jun 2015 20:18:44 +0000 In-Reply-To: <1433153954-27994-4-git-send-email-wei.liu2@citrix.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 , Xen-devel Cc: Dario Faggioli , Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org On 06/01/2015 06:19 AM, Wei Liu wrote: > Make the setup process similar to PV counterpart. That is, to allocate a > P2M array that covers the whole memory range and start from there. This > is clearer than using an array with no holes in it. > > Also the dummy layout should take MMIO hole into consideration. We might > end up having two vmemranges in the dummy layout. > > Signed-off-by: Wei Liu > Cc: Ian Campbell > Cc: Ian Jackson Reviewed-by: Boris Ostrovsky with a couple of nits below that you might consider. > @@ -325,16 +352,23 @@ static int setup_guest(xc_interface *xch, > DPRINTF(" TOTAL: %016"PRIx64"->%016"PRIx64"\n", v_start, v_end); > DPRINTF(" ENTRY: %016"PRIx64"\n", elf_uval(&elf, elf.ehdr, e_entry)); > > - if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL ) > + if ( (page_array = malloc(p2m_size * sizeof(xen_pfn_t))) == NULL ) > { > PERROR("Could not allocate memory."); > goto error_out; > } > > - for ( i = 0; i < nr_pages; i++ ) > - page_array[i] = i; > - for ( i = args->mmio_start >> PAGE_SHIFT; i < nr_pages; i++ ) > - page_array[i] += args->mmio_size >> PAGE_SHIFT; > + for ( i = 0; i < p2m_size; i++ ) > + page_array[i] = ((xen_pfn_t)-1); For large guests memset-ting page_array to 0xf should be much faster (but obviously not type-safe). > + for ( vmemid = 0; vmemid < args->nr_vmemranges; vmemid++ ) > + { > + uint64_t pfn; > + > + for ( pfn = args->vmemranges[vmemid].start >> PAGE_SHIFT; > + pfn < args->vmemranges[vmemid].end >> PAGE_SHIFT; > + pfn++ ) > + page_array[pfn] = pfn; > + } > > /* > * Try to claim pages for early warning of insufficient memory available. > @@ -645,6 +679,12 @@ static int setup_guest(xc_interface *xch, > error_out: > rc = -1; > out: > + if ( use_dummy ) Or 'if (args->vmemranges == dummy_vmemrange)' and drop use_dummy variable. -boris > + { > + args->nr_vnodes = 0; > + args->vmemranges = NULL; > + args->vnode_to_pnode = NULL; > + } > if ( elf_check_broken(&elf) ) > ERROR("HVM ELF broken: %s", elf_check_broken(&elf)); >