WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] xenpaing: one way to avoid paging out the page, when the cor

To: "olaf@xxxxxxxxx" <olaf@xxxxxxxxx>
Subject: [Xen-devel] xenpaing: one way to avoid paging out the page, when the corresponding mfn is in use.
From: Hongkaixing <hongkaixing@xxxxxxxxxx>
Date: Tue, 01 Nov 2011 12:23:37 +0000
Accept-language: zh-CN, en-US
Cc: YangXiaowei <xiaowei.yang@xxxxxxxxxx>, "Xen-devel@xxxxxxxxxxxxxxxxxxx" <Xen-devel@xxxxxxxxxxxxxxxxxxx>, "Eric Li\(Zhentao\)" <lizhentao@xxxxxxxxxx>, Yanqiangjun <yanqiangjun@xxxxxxxxxx>, hanweidong <hanweidong@xxxxxxxxxx>
Delivery-date: Tue, 01 Nov 2011 05:28:43 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcyYkBoFkms15JzMQkuSzw/WFaUE2g==
Thread-topic: xenpaing: one way to avoid paging out the page, when the corresponding mfn is in use.
Hello,

   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. 

second case:
   grant mapping                            xenpaing 
                                         p2m_paging_nominate()
                                     
                                                 gfn_to_mfn();    
  mfn = gfn_to_mfn();  ------------->     |  
                                             check type ok
         |                                               |
     Check type ok                     paged out;
         |
     try to map
What we want is:
When the gfn_to_mfn() action happens during paging nomination, the nomination 
should abort immediately.

Our solution prototype is like this :
1. Introduce a new member named last_access in page_info struct to save the 
last access time and access tag.
2. when the mfn is obtained through gfn_to_mfn(), we save time stamp and access 
tag in the page_info.
3. Paging nominate procedure use access information as a criterion.

How it works? 
1.Using time stamp to avoid case 1. When the mfn is obtained by mapping 
process, 
   the time stamp can prevent the page from being selected by paging .
2.Using access tag to avoid case 2. During the paging nomination, if the access 
tag of page is detected, 
   paging should skip selecting this page. 

The pseudo-code of step 3 can be written as follow:
int p2m_mem_paging_nominate(struct domain *d, unsigned long gfn)
{
   
    mfn = gfn_to_mfn_noreference(d, gfn, &p2mt);   -----> avoid saving 
timestamp and access tag 
    
    if ( !mfn_valid(mfn) )
        goto out;
    
    clear_access_tag();   ----------> clear the access tag of this page
    if (test_page_hot())
       goto out;           ------> if the page is accessed recently, go to out
    ........
  
    set_p2m_entry(d, gfn, mfn, 0, p2m_ram_paging_out);
    if ( test_access_tag ( mfn ) )
        goto out;  --------> if access tag is set, the gfn_to_mfn must have 
happened above, abort anyway.
    ret = 0;
 out:
    p2m_unlock(d->arch.p2m);
    return ret;
}
   Maybe this is an imperfect prototype, do you have any good ideas?

  Hong Kaixing
 
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>