From: Tim Deegan Subject: Re: pre-reservation of memory for domain creation Date: Thu, 14 Jan 2010 12:46:19 +0000 Message-ID: <20100114124619.GE30054@whitby.uk.xensource.com> References: <4B4CA40C0200007800029657@vpn.id2.novell.com> <4B4CAEB9020000780002969A@vpn.id2.novell.com> <6CADD16F56BC954D8E28F3836FA7ED7112A79326F2@shzsmsx501.ccr.corp.intel.com> <4B4D8A9402000078000299C3@vpn.id2.novell.com> <6CADD16F56BC954D8E28F3836FA7ED7112A7932EBF@shzsmsx501.ccr.corp.intel.com> <4B4EEB300200007800029E45@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="tKW2IUtsqtDRztdT" Return-path: Content-Disposition: inline In-Reply-To: <4B4EEB300200007800029E45@vpn.id2.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich Cc: Dongxiao Xu , "xen-devel@lists.xensource.com" , Keir Fraser List-Id: xen-devel@lists.xenproject.org --tKW2IUtsqtDRztdT Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline At 09:00 +0000 on 14 Jan (1263459616), Jan Beulich wrote: > >>> "Xu, Dongxiao" 14.01.10 08:19 >>> > > Currently guest initialization process in xend (XendDomainInfo.py) is: > > > > _constructDomain() --> domain_create() --> domain_max_vcpus() ... --> > > _initDomain() --> shadow_mem_control() ... > > While the patch certainly matches what I had in mind, with this sequence > it is clear that the tools still will need adjustment: The full ballooning only > happens from _initDomain(), and hence the pre-reservation (from > _constructDomain) of 4Mb would still be too small for large vCPU counts. > > I wonder though what all this memory is needed for before the domain > (not to speak of secondary CPUs) actually gets started. If that could be > got under control, tools side adjustment would not be necessary. Tim? Hmmm. Some shadow memory has to be allocated before the VCPUs are initialized so that they can be given monitor pagetables etc. Some shadow memory has to be allocated before the guest's main memory is assigned because the p2m is built out of shadow memory. It looks like there are (at least) two bugs here: - shadow_min_acceptable_pages() returns 0 for a domain with no vcpus, leading to a domain having shadow enabled but no shadow memory at all. - shadow_min_acceptable_pages() increases as more VCPUs are assigned but the shadow allocation is never increased to match. Fixing the first one should be enough, so long as xend assignd vcpus and memory before assigning shadow memory properly (which I believe it does). Patch attached. The separate issue of how much memory should be ballooned out before starting a domain really needs a full overhaul of all allocations in Xen so that we can assign blame for every page. :) Shadow memory is the best-behaved part of all this; most HVM overhead is just allocated anonymously. Cheers, Tim. -- Tim Deegan Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.] --tKW2IUtsqtDRztdT Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: attachment; filename="shmem" Make sure the minimum shadow allocation is never zero. Signed-off-by: Tim Deegan diff -r cba56c13ca3e xen/arch/x86/mm/shadow/common.c --- a/xen/arch/x86/mm/shadow/common.c Wed Jan 06 12:45:23 2010 +0000 +++ b/xen/arch/x86/mm/shadow/common.c Thu Jan 14 12:41:52 2010 +0000 @@ -1244,10 +1244,11 @@ * instruction, we must be able to map a large number (about thirty) VAs * at the same time, which means that to guarantee progress, we must * allow for more than ninety allocated pages per vcpu. We round that - * up to 128 pages, or half a megabyte per vcpu. */ + * up to 128 pages, or half a megabyte per vcpu, and add 1 more vcpu's + * worth to make sure we never return zero. */ static unsigned int shadow_min_acceptable_pages(struct domain *d) { - u32 vcpu_count = 0; + u32 vcpu_count = 1; struct vcpu *v; for_each_vcpu(d, v) --tKW2IUtsqtDRztdT Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --tKW2IUtsqtDRztdT--