From: jeet Subject: Re: Re: [Queries] Unpinning and Unhooking shadow Date: Fri, 16 Mar 2007 15:16:10 +0530 (IST) Message-ID: <33789.10981.qm@web8805.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 & all=0A=0ASorry for resending the same mail again. Please provide y= our comment/answer.=0A=0AHi Tim, =0AThanks for reply=0A=0A> 1. we do back t= raversing of per domain list of top level shadow pages and try to unpin the= m using function call sh_unpin()=0A> =0A> but in unpinning shadow we are un= setting pin bit in page->count_info and decrement the reference count of sh= adow page=0A> using call 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 th= is condition is unlikely? =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 created using shadow_alloc() =0A> so this sh_destroy_shadow= must be called for any one of the entry in toplevel list to free space of = at least required order =0A> and put back the pages in freelist of shadow p= ool ?=0A=0A| I don't understand your question.=0A|=0A| When we need to free= up some shadow memory, we walk the list of pinned=0A| shadows and unpin th= em. We walk them in reverse order because we hope=0A| that less useful sha= dows will be at the end. =0A|=0A| When we unpin a shadow, if it's not in u= se right now, its refcount falls=0A| to zero, which causes the whole tree o= f shadows below it to be=0A| recursively destroyed. =0A=0AMy question was f= or confirming my understanding that during unpinning it should destroy shad= ow recursively. =0AThanks for clarifying my understanding=0A=0A| If that do= esn't free up enough memeory, we try the next one.=0A=0A> 3. Also after thi= s if still space is not free then we try to unhooking the same toplevel lis= t by going though each entry in list and =0A> marking corresponding PML4 t= able's entries as 0 if that entry was marked PRESENT.=0A> =0A> But I am not= able to understand how 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 c= ause some of them to=0A| be destroyed.=0A=0ASorry but this is still not cle= ar to me how this will drop reference count of low level shadow pointed by = shadow Top PT entries =0Aby putting 0 in shadow top level PT entries, whic= h are PRESENT.=0A=0AAnd how & where these low level shadow would be destroy= ed?.=0Aplease explain this more.=0A=0A| =0A| When we have completed both sc= ans of the pinned-shadows list, the only=0A| shadows still allocated will b= e the top-level shadows for each vcpu in=0A| the guest, and they will have = no lower-level shadows attached to them.=0A=0ASo when handling page fault a= fter 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 recu= rrsively (shadow_get_and_create_l1e()) and put the entry in top level shado= w of currently executing process. is my understanding correct?=0A=0AAll als= o after both scan these Top level shadow will have pinned flag clear. As w= e are not pinning them again after unpinning in sh_unpin(). Right?=0A=0A=0A= Jeet=0A=0A=0A=0A=0A=0A=0A=09=09=0A_________________________________________= _________________=0AYahoo! India Answers: Share what you know. Learn someth= ing new=0Ahttp://in.answers.yahoo.com/