Hi George: Appreciate for your kindly help. I think the page type should be changed inside mem_sharing_unshare_page() in shr_lock too ,to prevent someone might unshare the page again. So your patch and mine makes the whole solution. As for my patch, it seems that use put_page_and_type(page); to clean the page is enough, and don't need to BUG_ON(set_shared_p2m_entry_invalid(d, gfn)==0); ( which actually calls set_p2m_entry(d, gfn, _mfn(INVALID_MFN), 0, p2m_invalid) ), right? One another thing is rcu_lock_domain_by_id(d->domain_id); When someone hold this lock, d->is_dying = 0, does this mean d->is_dying will not be changed untill it call rcu_unlock_domain? That is to say, the lock actually protects whole d structure? > Date: Fri, 21 Jan 2011 16:41:47 +0000 > Subject: Re: [Xen-devel] mem_sharing: summarized problems when domain is dying > From: George.Dunlap@eu.citrix.com > To: juihaochiang@gmail.com > CC: Tim.Deegan@citrix.com; tinnycloud@hotmail.com; xen-devel@lists.xensource.com > > Tim / Xiaoyun, do you think something like this might work? > > -George > > On Fri, Jan 21, 2011 at 4:32 PM, George Dunlap wrote: > > [sorry, accidentally sent too early] > > > > On Fri, Jan 21, 2011 at 4:29 PM, George Dunlap wrote: > >> I'm not sure the exact rationale behind the "cannot fail" flag; but it > >> looks like in grant_table.c, both callers of gfn_to_mfn_unshare() > >> handle the case where the returned p2m entry is just > > > > ...invalid. I wonder if "unsharing" the page, but marking the entry > > invalid during death would help. > > > > I suppose the problem there is that if you're keeping the VM around > > but paused for analysis, you'll have holes in your address space. But > > just returning an invalid entry to the callers who try to unshare > > pages might work. > > > > -George > >