From: Mukesh Rathor Subject: Re: page refcount on pages mapped by the toolstack.. Date: Thu, 6 Dec 2012 18:21:31 -0800 Message-ID: <20121206182131.7b417212@mantra.us.oracle.com> References: <20121205174153.76fa5dd1@mantra.us.oracle.com> <50C0866202000078000AE787@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <50C0866202000078000AE787@nat28.tlf.novell.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: Jan Beulich Cc: IanCampbell , xen-devel List-Id: xen-devel@lists.xenproject.org On Thu, 06 Dec 2012 10:49:54 +0000 "Jan Beulich" wrote: > > Did you perhaps not monitor the changes to the refcnt closely > enough? It ought to be 2 when the guest is up (on reference for > the _PGC_allocated bit, and another for it to be mapped > somewhere in the guest). I.e. between Dom0 creating the guest > (and touching its memory) and the guest actually starting, there > could be further adjustments to the refcnt that simply sum up to > zero. Correct, it's 2 when the guest is up. Then relinquish_memory() seems to bring it to 0 when domain destroy is called. For PVH, I somehow end up with 3 when guest is up, so when guest is destroyed the mfn's are around with refcnt of 1. I get refcnt on the page in xen when doing xen_remap_domain_mfn_range() in dom0. I hold on to the refcnt until xen_unmap_domain_mfn_range(). Unmap results in call to XENMEM_remove_from_physmap where I do put_page if it's not a grant page and is from foreign domain.... Debugging that right now. Thanks for the help, Mukesh