From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ross Lagerwall Subject: Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation Date: Mon, 6 Jul 2015 14:33:35 +0100 Message-ID: <559A83AF.3090601@citrix.com> References: <1436188640-303-1-git-send-email-wei.liu2@citrix.com> <1436188640-303-3-git-send-email-wei.liu2@citrix.com> <559A820D.9050601@citrix.com> <20150706133007.GB1134@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZC6X6-00032k-7B for xen-devel@lists.xenproject.org; Mon, 06 Jul 2015 13:34:04 +0000 In-Reply-To: <20150706133007.GB1134@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 , Andrew Cooper Cc: Xen-devel , Dario Faggioli List-Id: xen-devel@lists.xenproject.org On 07/06/2015 02:30 PM, Wei Liu wrote: > On Mon, Jul 06, 2015 at 02:26:37PM +0100, Andrew Cooper wrote: >> On 06/07/15 14:17, Wei Liu wrote: >>> In 415b58c1 (tools/libxc: Batch memory allocations for PV guests) the >>> number of super pages is calculated with the number of total pages. That >>> is wrong. It breaks PV guest vNUMA. The correct number of super pages >>> should be derived from the number of pages within that virtual NUMA >>> node. >>> >>> Also change the name and type of super page variable to match the naming >>> convention and type of normal page variable. Make the necessary >>> adjustment to make code compile. >>> >>> Reported-by: Dario Faggioli >>> Signed-off-by: Wei Liu >>> --- >>> Cc: Ross Lagerwall >>> --- >>> tools/libxc/xc_dom_x86.c | 10 +++++----- >>> 1 file changed, 5 insertions(+), 5 deletions(-) >>> >>> diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c >>> index acd7b3f..faabe96 100644 >>> --- a/tools/libxc/xc_dom_x86.c >>> +++ b/tools/libxc/xc_dom_x86.c >>> @@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom) >>> for ( i = 0; i < nr_vmemranges; i++ ) >>> { >>> unsigned int memflags; >>> - uint64_t pages; >>> + uint64_t pages, super_pages; >>> unsigned int pnode = vnode_to_pnode[vmemranges[i].nid]; >>> - int nr_spages = dom->total_pages >> SUPERPAGE_PFN_SHIFT; >>> xen_pfn_t extents[SUPERPAGE_BATCH_SIZE]; >>> xen_pfn_t pfn_base_idx; >>> >>> @@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom) >>> >>> pages = (vmemranges[i].end - vmemranges[i].start) >>> >> PAGE_SHIFT; >>> + super_pages = pages >> SUPERPAGE_PFN_SHIFT; >>> pfn_base = vmemranges[i].start >> PAGE_SHIFT; >>> >>> for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ ) >>> dom->p2m_host[pfn] = pfn; >>> >>> pfn_base_idx = pfn_base; >>> - while (nr_spages) { >>> - int count = min(nr_spages, SUPERPAGE_BATCH_SIZE); >>> - nr_spages -= count; >>> + while (super_pages) { >>> + int count = min_t(uint64_t, super_pages, SUPERPAGE_BATCH_SIZE); >> >> This line alone indicates that int is not an appropriate type for >> count. unsigned int as as an absolute minimum, as it will be bounded to >> SUPERPAGE_BATCH_SIZE. >> > > Yes, I also need to make count uint64_t. > Is this needed? count should never be larger than 512 (aka SUPERPAGE_BATCH_SIZE). -- Ross Lagerwall