All of lore.kernel.org
 help / color / mirror / Atom feed
* xenpaing: one way to avoid paging out the page, when the corresponding mfn is in use.
@ 2011-11-01 12:23 Hongkaixing
  2011-11-01 17:07 ` Olaf Hering
  0 siblings, 1 reply; 3+ messages in thread
From: Hongkaixing @ 2011-11-01 12:23 UTC (permalink / raw)
  To: olaf@aepfle.de
  Cc: YangXiaowei, Xen-devel@lists.xensource.com, Eric Li(Zhentao),
	Yanqiangjun, hanweidong

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
 

^ permalink raw reply	[flat|nested] 3+ messages in thread
[parent not found: <20111101124941.583FA72C415@homiemail-mx8.g.dreamhost.com>]

end of thread, other threads:[~2011-11-02 14:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-01 12:23 xenpaing: one way to avoid paging out the page, when the corresponding mfn is in use Hongkaixing
2011-11-01 17:07 ` Olaf Hering
     [not found] <20111101124941.583FA72C415@homiemail-mx8.g.dreamhost.com>
2011-11-02 14:44 ` andres

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.