From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH] don't save Xen heap pages during domain save Date: Tue, 15 Jun 2010 12:45:31 +0100 Message-ID: <4C1783FB0200007800006777@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part9FB2C9CB.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part9FB2C9CB.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline As discussed in the thread starting at http://lists.xensource.com/archives/html/xen-devel/2010-05/msg01383.html, don't save Xen heap pages in order to avoid overallocation when the domain gets restored, as those pages would get (temporarily) backed with normal RAM pages by the restore code. This requires making DOMCTL_getpageframeinfo{2,3} usable for HVM guests, meaning that the input to these must be treated as GMFNs. Signed-off-by: Jan Beulich --- 2010-06-15.orig/tools/libxc/xc_domain_save.c 2010-06-01 = 13:39:57.000000000 +0200 +++ 2010-06-15/tools/libxc/xc_domain_save.c 2010-06-15 09:32:42.0000000= 00 +0200 @@ -1288,58 +1288,64 @@ int xc_domain_save(xc_interface *xch, in goto out; } =20 - if ( hvm ) + /* Get page types */ + if ( xc_get_pfn_type_batch(xch, dom, batch, pfn_type) ) { - /* Look for and skip completely empty batches. */ - for ( j =3D 0; j < batch; j++ ) - { - if ( !pfn_err[j] ) - break; - pfn_type[j] |=3D XEN_DOMCTL_PFINFO_XTAB; - } - if ( j =3D=3D batch ) - { - munmap(region_base, batch*PAGE_SIZE); - continue; /* bail on this batch: no valid pages */ - } - for ( ; j < batch; j++ ) - if ( pfn_err[j] ) - pfn_type[j] |=3D XEN_DOMCTL_PFINFO_XTAB; + PERROR("get_pfn_type_batch failed"); + goto out; } - else + + for ( run =3D j =3D 0; j < batch; j++ ) { - /* Get page types */ - if ( xc_get_pfn_type_batch(xch, dom, batch, pfn_type) ) - { - PERROR("get_pfn_type_batch failed"); - goto out; - } + unsigned long gmfn =3D pfn_batch[j]; =20 - for ( j =3D 0; j < batch; j++ ) + if ( !hvm ) + gmfn =3D pfn_to_mfn(gmfn); + + if ( pfn_err[j] ) { - unsigned long mfn =3D pfn_to_mfn(pfn_batch[j]); - =20 if ( pfn_type[j] =3D=3D XEN_DOMCTL_PFINFO_XTAB ) - { - DPRINTF("type fail: page %i mfn %08lx\n",=20 - j, mfn); continue; - } - =20 - if ( debug ) + DPRINTF("map fail: page %i mfn %08lx err %d\n", + j, gmfn, pfn_err[j]); + pfn_type[j] =3D XEN_DOMCTL_PFINFO_XTAB; + continue; + } + + if ( pfn_type[j] =3D=3D XEN_DOMCTL_PFINFO_XTAB ) + { + DPRINTF("type fail: page %i mfn %08lx\n", j, gmfn); + continue; + } + + /* canonicalise mfn->pfn */ + pfn_type[j] |=3D pfn_batch[j]; + ++run; + + if ( debug ) + { + if ( hvm ) + DPRINTF("%d pfn=3D%08lx sum=3D%08lx\n", + iter, + pfn_type[j], + csum_page(region_base + (PAGE_SIZE*j))); + else DPRINTF("%d pfn=3D %08lx mfn=3D %08lx [mfn]=3D = %08lx" " sum=3D %08lx\n", iter, - pfn_type[j] | pfn_batch[j], - mfn, - mfn_to_pfn(mfn), + pfn_type[j], + gmfn, + mfn_to_pfn(gmfn), csum_page(region_base + (PAGE_SIZE*j))); - =20 - /* canonicalise mfn->pfn */ - pfn_type[j] |=3D pfn_batch[j]; } } =20 + if ( !run ) + { + munmap(region_base, batch*PAGE_SIZE); + continue; /* bail on this batch: no valid pages */ + } + if ( wrexact(io_fd, &batch, sizeof(unsigned int)) ) { PERROR("Error when writing to state file (2)"); --- 2010-06-15.orig/xen/arch/x86/domctl.c 2010-03-02 09:11:28.0000000= 00 +0100 +++ 2010-06-15/xen/arch/x86/domctl.c 2010-06-15 09:32:42.000000000 = +0200 @@ -207,11 +207,12 @@ long arch_do_domctl( =20 for ( j =3D 0; j < k; j++ ) { - unsigned long type =3D 0, mfn =3D arr[j]; + unsigned long type =3D 0, mfn =3D gmfn_to_mfn(d, = arr[j]); =20 page =3D mfn_to_page(mfn); =20 - if ( unlikely(!mfn_valid(mfn)) ) + if ( unlikely(!mfn_valid(mfn)) || + unlikely(is_xen_heap_mfn(mfn)) ) type =3D XEN_DOMCTL_PFINFO_XTAB; else if ( xsm_getpageframeinfo(page) !=3D 0 ) ; @@ -306,14 +307,15 @@ long arch_do_domctl( for ( j =3D 0; j < k; j++ ) { =20 struct page_info *page; - unsigned long mfn =3D arr32[j]; + unsigned long mfn =3D gmfn_to_mfn(d, arr32[j]); =20 page =3D mfn_to_page(mfn); =20 if ( domctl->cmd =3D=3D XEN_DOMCTL_getpageframeinfo3) arr32[j] =3D 0; =20 - if ( unlikely(!mfn_valid(mfn)) ) + if ( unlikely(!mfn_valid(mfn)) || + unlikely(is_xen_heap_mfn(mfn)) ) arr32[j] |=3D XEN_DOMCTL_PFINFO_XTAB; else if ( xsm_getpageframeinfo(page) !=3D 0 ) continue; --=__Part9FB2C9CB.0__= Content-Type: text/plain; name="dont-save-xen-heap-pages.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="dont-save-xen-heap-pages.patch" As discussed in the thread starting at=0Ahttp://lists.xensource.com/archive= s/html/xen-devel/2010-05/msg01383.html,=0Adon't save Xen heap pages in = order to avoid overallocation when the=0Adomain gets restored, as those = pages would get (temporarily) backed=0Awith normal RAM pages by the = restore code.=0A=0AThis requires making DOMCTL_getpageframeinfo{2,3} = usable for HVM guests,=0Ameaning that the input to these must be treated = as GMFNs.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = 2010-06-15.orig/tools/libxc/xc_domain_save.c 2010-06-01 13:39:57.0000000= 00 +0200=0A+++ 2010-06-15/tools/libxc/xc_domain_save.c 2010-06-15 = 09:32:42.000000000 +0200=0A@@ -1288,58 +1288,64 @@ int xc_domain_save(xc_in= terface *xch, in=0A goto out;=0A }=0A =0A- = if ( hvm )=0A+ /* Get page types */=0A+ if ( = xc_get_pfn_type_batch(xch, dom, batch, pfn_type) )=0A {=0A- = /* Look for and skip completely empty batches. */=0A- = for ( j =3D 0; j < batch; j++ )=0A- {=0A- = if ( !pfn_err[j] )=0A- break;=0A- = pfn_type[j] |=3D XEN_DOMCTL_PFINFO_XTAB;=0A- }=0A- = if ( j =3D=3D batch )=0A- {=0A- = munmap(region_base, batch*PAGE_SIZE);=0A- = continue; /* bail on this batch: no valid pages */=0A- = }=0A- for ( ; j < batch; j++ )=0A- if ( = pfn_err[j] )=0A- pfn_type[j] |=3D XEN_DOMCTL_PFINFO_= XTAB;=0A+ PERROR("get_pfn_type_batch failed");=0A+ = goto out;=0A }=0A- else=0A+=0A+ = for ( run =3D j =3D 0; j < batch; j++ )=0A {=0A- = /* Get page types */=0A- if ( xc_get_pfn_type_batch(xch, = dom, batch, pfn_type) )=0A- {=0A- = PERROR("get_pfn_type_batch failed");=0A- goto out;=0A- = }=0A+ unsigned long gmfn =3D pfn_batch[j];=0A = =0A- for ( j =3D 0; j < batch; j++ )=0A+ if = ( !hvm )=0A+ gmfn =3D pfn_to_mfn(gmfn);=0A+=0A+ = if ( pfn_err[j] )=0A {=0A- = unsigned long mfn =3D pfn_to_mfn(pfn_batch[j]);=0A- =0A = if ( pfn_type[j] =3D=3D XEN_DOMCTL_PFINFO_XTAB )=0A- = {=0A- DPRINTF("type fail: page %i = mfn %08lx\n", =0A- j, mfn);=0A = continue;=0A- }=0A- =0A- = if ( debug )=0A+ DPRINTF("map fail: = page %i mfn %08lx err %d\n",=0A+ j, gmfn, = pfn_err[j]);=0A+ pfn_type[j] =3D XEN_DOMCTL_PFINFO_XTAB;= =0A+ continue;=0A+ }=0A+=0A+ = if ( pfn_type[j] =3D=3D XEN_DOMCTL_PFINFO_XTAB )=0A+ = {=0A+ DPRINTF("type fail: page %i mfn %08lx\n", j, = gmfn);=0A+ continue;=0A+ }=0A+=0A+ = /* canonicalise mfn->pfn */=0A+ pfn_type[j] |=3D = pfn_batch[j];=0A+ ++run;=0A+=0A+ if ( debug = )=0A+ {=0A+ if ( hvm )=0A+ = DPRINTF("%d pfn=3D%08lx sum=3D%08lx\n",=0A+ = iter,=0A+ pfn_type[j],=0A+ = csum_page(region_base + (PAGE_SIZE*j)));=0A+ = else=0A DPRINTF("%d pfn=3D %08lx = mfn=3D %08lx [mfn]=3D %08lx"=0A " sum=3D = %08lx\n",=0A iter,=0A- = pfn_type[j] | pfn_batch[j],=0A- = mfn,=0A- mfn_to_pfn(mfn),=0A+ = pfn_type[j],=0A+ gmfn,=0A+ = mfn_to_pfn(gmfn),=0A = csum_page(region_base + (PAGE_SIZE*j)));=0A- = =0A- /* canonicalise mfn->pfn */=0A- = pfn_type[j] |=3D pfn_batch[j];=0A }=0A }=0A = =0A+ if ( !run )=0A+ {=0A+ munmap(regi= on_base, batch*PAGE_SIZE);=0A+ continue; /* bail on this = batch: no valid pages */=0A+ }=0A+=0A if ( = wrexact(io_fd, &batch, sizeof(unsigned int)) )=0A {=0A = PERROR("Error when writing to state file (2)");=0A--- 2010-06-15.or= ig/xen/arch/x86/domctl.c 2010-03-02 09:11:28.000000000 +0100=0A+++ = 2010-06-15/xen/arch/x86/domctl.c 2010-06-15 09:32:42.000000000 = +0200=0A@@ -207,11 +207,12 @@ long arch_do_domctl(=0A =0A = for ( j =3D 0; j < k; j++ )=0A {=0A- = unsigned long type =3D 0, mfn =3D arr[j];=0A+ unsigned = long type =3D 0, mfn =3D gmfn_to_mfn(d, arr[j]);=0A =0A = page =3D mfn_to_page(mfn);=0A =0A- if ( unlikely(!mfn_v= alid(mfn)) )=0A+ if ( unlikely(!mfn_valid(mfn)) ||=0A+ = unlikely(is_xen_heap_mfn(mfn)) )=0A = type =3D XEN_DOMCTL_PFINFO_XTAB;=0A else if ( = xsm_getpageframeinfo(page) !=3D 0 )=0A ;=0A@@ = -306,14 +307,15 @@ long arch_do_domctl(=0A for ( j =3D 0; j < = k; j++ )=0A { =0A struct page_info = *page;=0A- unsigned long mfn =3D arr32[j];=0A+ = unsigned long mfn =3D gmfn_to_mfn(d, arr32[j]);=0A =0A = page =3D mfn_to_page(mfn);=0A =0A if ( domctl->cmd =3D=3D = XEN_DOMCTL_getpageframeinfo3)=0A arr32[j] =3D 0;=0A = =0A- if ( unlikely(!mfn_valid(mfn)) )=0A+ if = ( unlikely(!mfn_valid(mfn)) ||=0A+ unlikely(is_xen_heap= _mfn(mfn)) )=0A arr32[j] |=3D XEN_DOMCTL_PFINFO_XTAB;= =0A else if ( xsm_getpageframeinfo(page) !=3D 0 )=0A = continue;=0A --=__Part9FB2C9CB.0__= 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 --=__Part9FB2C9CB.0__=--