From: jeet Subject: Re: Re: [Queries] Unpinning and Unhooking shadow Date: Thu, 15 Mar 2007 10:47:45 +0530 (IST) Message-ID: <272773.61332.qm@web8814.mail.in.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable 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: Tim Deegan Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org HI Tim =0A=0AThanks for reply=0A=0A> 1. we do back traversing of per domain= list of top level shadow pages and try to unpin them using function call s= h_unpin()=0A> =0A> but in unpinning shadow we are unsetting pin bit in page= ->count_info and decrement the reference count of shadow page=0A> using cal= l to sh_put_ref() [define in xen/arch/x86/mm/shadow/private.h]=0A> =0A> but= in this function I am not able to understand why this condition is unlikel= y? =0A> =0A> if ( unlikely(nx =3D=3D 0) ) =0A> sh_destroy_shadow(v,= smfn);=0A=0A| Because sh_put_ref is called in lots of other places too...= =0A=0A> as we are trying to make space for new shadow which would be create= d using shadow_alloc() =0A> so this sh_destroy_shadow must be called for an= y one of the entry in toplevel list to free space of at least required orde= r =0A> and put back the pages in freelist of shadow pool ?=0A=0A| I don't u= nderstand your question.=0A|=0A| When we need to free up some shadow memory= , we walk the list of pinned=0A| shadows and unpin them. We walk them in r= everse order because we hope=0A| that less useful shadows will be at the en= d. =0A|=0A| When we unpin a shadow, if it's not in use right now, its refc= ount falls=0A| to zero, which causes the whole tree of shadows below it to = be=0A| recursively destroyed. =0A=0AMy question was for confirming my under= standing that during unpinning it should destroy shadow recursively. =0ATha= nks for clarifying my understanding=0A=0A| If that doesn't free up enough m= emeory, we try the next one.=0A=0A> 3. Also after this if still space is no= t free then we try to unhooking the same toplevel list by going though eac= h entry in list and =0A> marking corresponding PML4 table's entries as 0 if= that entry was marked PRESENT.=0A> =0A> But I am not able to understand ho= w this will return pages back to per domain freelist of shadow pages?=0A=0A= | Because it will drop the refcount on all the lower-level shadows that=0A|= were being pointed to by those entries, which will cause some of them to= =0A| be destroyed.=0A=0ASorry but this is still not clear to me how this wi= ll drop reference count of low level shadow pointed by shadow Top PT entrie= s =0Aby putting 0 in shadow top level PT entries, which are PRESENT.=0A=0A= And how & where these low level shadow would be destroyed?.=0Aplease explai= n this more.=0A=0A| =0A| When we have completed both scans of the pinned-sh= adows list, the only=0A| shadows still allocated will be the top-level shad= ows for each vcpu in=0A| the guest, and they will have no lower-level shado= ws attached to them.=0A=0ASo when handling page fault after this unhooking = (If as explained above this will remove all references of low level shadow = ) we need to create all the low level shadow again recurrsively (shadow_get= _and_create_l1e()) and put the entry in top level shadow of currently execu= ting process. is my understanding correct?=0A=0AAll also after both scan th= ese Top level shadow will have pinned flag clear. As we are not pinning th= em again after unpinning in sh_unpin(). Right?=0A=0A=0AJeet=0A____=0A=0A=0A= =0A=0A=09=09=0A__________________________________________________________= =0AYahoo! India Answers: Share what you know. Learn something new=0Ahttp://= in.answers.yahoo.com/