From: Tim Deegan Subject: Re: Questions about sh_prefetch and log_dirty Date: Thu, 25 Jun 2009 14:23:30 +0100 Message-ID: <20090625132330.GS16056@york.uk.xensource.com> References: <4A410663.7010507@pku.edu.cn> <20090624102238.GQ16056@york.uk.xensource.com> <4A42253A.7070105@pku.edu.cn> <20090624131144.GR16056@york.uk.xensource.com> <4A43740D.2080303@pku.edu.cn> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Return-path: Content-Disposition: inline In-Reply-To: <4A43740D.2080303@pku.edu.cn> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: David Knight Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Hi, At 13:56 +0100 on 25 Jun (1245938205), David Knight wrote: > I made a mistake when I explain my problem. My code can successfully > migrate the domU TO MODIFIED Xen. But when a domU is migrated > from Modified Xen to a Unmodified Xen. The clock is frozen. OK, that makes much more sense. It's the log-dirty code in the Xen you're migratin from that will cause the problems. > Here is my code, most of it is just a copy of sh_prefetch(); You've done some pretty odd things to it. Why did you remove all the comments, for example? Why did you replace all the array indirections with pointer arithmetic? Anyway, the main thing that stands out is that you don't handle the OOS optimization at all. Are you running a very old version of Xen? Cheers, Tim. > static void sh_prebuild(struct vcpu *v, walk_t gw, > shadow_l1e_t *ptr_sl1e, mfn_t sl1mfn, unsigned int countl, unsigned int countr) > { > int i, distr,distl; > gfn_t gfn; > mfn_t gmfn; > guest_l1e_t *gl1p = NULL, gl1e; > shadow_l1e_t sl1e; > u32 gflags; > p2m_type_t p2mt; > struct page_info *pg; > > distl = ((unsigned long)ptr_sl1e & ~PAGE_MASK) / sizeof sl1e; > distr = (PAGE_SIZE - ((unsigned long)ptr_sl1e & ~PAGE_MASK)) / sizeof sl1e; > > if ( distl > countl ) > distl = countl; > if ( distr > countr + 1 ) > distr = countr + 1; > > if ( !mfn_valid(gw.l1mfn) ) > return; > > gl1p = sh_map_domain_page(gw.l1mfn); > gl1p += guest_l1_table_offset(gw.va); > > ptr_sl1e -= distl; > distl = 0-distl; > > for ( i = distl; i < distr ; i++ ) > { > if ( i == 0 ) > { > ptr_sl1e += 1; > continue; > } > > if ( ptr_sl1e->l1 != 0 ) > break; > > if ( mfn_valid(gw.l1mfn) ) > { > gl1e = *(gl1p + i); > > gflags = guest_l1e_get_flags(gl1e); > if ( (gflags & _PAGE_PRESENT) > && (!(gflags & _PAGE_ACCESSED) > || ((gflags & _PAGE_RW) && !(gflags & _PAGE_DIRTY))) ) > break; > } > else > { > ASSERT(guest_l2e_get_flags(gw.l2e) & _PAGE_PSE); > gl1e = guest_l1e_from_gfn( > _gfn(gfn_x(guest_l1e_get_gfn(gw.l1e)) + i), > guest_l1e_get_flags(gw.l1e)); > } > > gfn = guest_l1e_get_gfn(gl1e); > gmfn = gfn_to_mfn(v->domain, gfn, &p2mt); > > pg = mfn_to_page(gmfn); > > if ( mfn_valid(gmfn) > && ((pg->u.inuse.type_info & PGT_type_mask)==PGT_writable_page) ) > { > l1e_propagate_from_guest(v, gl1e, gmfn, &sl1e, ft_demand_write, p2mt); > (void) shadow_set_l1e(v, ptr_sl1e, sl1e, sl1mfn); > } > > ptr_sl1e += 1; > } > if ( gl1p != NULL ) > sh_unmap_domain_page(gl1p); > } -- Tim Deegan Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]