From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olaf Hering Subject: Re: xenpaing: one way to avoid paging out the page, when the corresponding mfn is in use. Date: Tue, 1 Nov 2011 18:07:48 +0100 Message-ID: <20111101170748.GA9034@aepfle.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Hongkaixing Cc: YangXiaowei , "Xen-devel@lists.xensource.com" , "Eric Li(Zhentao)" , Yanqiangjun , hanweidong List-Id: xen-devel@lists.xenproject.org On Tue, Nov 01, Hongkaixing wrote: > Recently many advanced memory mechanisms are introduced into Xen. > One problem we found is the conflict between p2m query and setting. > For example, backend drivers always map domU’s page to its own > space, during the mapping procedure, situations as follow may > happen, when mfn is obtained by gfn_to_mfn(), this mfn is likely to > be paged out. > > first case: > grant mapping xenpaing > mfn = gfn_to_mfn(); > <----------- p2m_paging_nominate() > | | > Check type ok paged out; > | > try to map > What we want is: > When the page (mfn) is accessed by gfn_to_mfn(), this page should > never be paged out until the mapping action is end. The query+map and query+change opterations on p2m entries should be done under some lock. I have recently updated the p2m_mem_paging* functions to do their modifications with the p2m_lock held. Furthermore the change below checks wether something mapped a page between nominate and evict: http://xenbits.xen.org/hg/xen-unstable.hg/rev/eda18b27de6e While this certainly does not fix all possible races, it slightly reduces the window. A more complete approach to add locking around p2m modifcations was recently started by Andres Lagar-Cavilla: http://lists.xensource.com/archives/html/xen-devel/2011-10/msg01946.html Olaf