ia64/xen-unstable

changeset 1278:7dcd4464f39e

bitkeeper revision 1.836.1.1 (4070ff6fJhQoaxeSlTRL6ojba0QXfw)

shadow logdirty mode added
author iap10@tetris.cl.cam.ac.uk
date Mon Apr 05 06:40:47 2004 +0000 (2004-04-05)
parents 498890e33619
children 35f6d097e399
files xen/common/memory.c xen/include/asm-i386/page.h xen/include/xen/shadow.h
line diff
     1.1 --- a/xen/common/memory.c	Fri Apr 02 16:27:52 2004 +0000
     1.2 +++ b/xen/common/memory.c	Mon Apr 05 06:40:47 2004 +0000
     1.3 @@ -1149,7 +1149,12 @@ int do_update_va_mapping(unsigned long p
     1.4  	}
     1.5  
     1.6  	check_pagetable( p, p->mm.pagetable, "va" ); // debug
     1.7 -    
     1.8 +
     1.9 +	/* if we're in logdirty mode, we need to note that we've updated the
    1.10 +	   PTE in the PT-holding page. This is a bit of a pain as we don't
    1.11 +	   know the physcial (machine) frame number of the page */
    1.12 +	if ( p->mm.shadow_mode == SHM_logdirty )
    1.13 +	  mark_dirty( &current->mm, va_to_l1mfn(page_nr<<PAGE_SHIFT) );    
    1.14      }
    1.15  
    1.16  
     2.1 --- a/xen/include/asm-i386/page.h	Fri Apr 02 16:27:52 2004 +0000
     2.2 +++ b/xen/include/asm-i386/page.h	Mon Apr 05 06:40:47 2004 +0000
     2.3 @@ -93,6 +93,8 @@ typedef struct { unsigned long pt_lo; } 
     2.4  #define linear_pg_table ((l1_pgentry_t *)LINEAR_PT_VIRT_START)
     2.5  #define linear_l2_table ((l2_pgentry_t *)(LINEAR_PT_VIRT_START+(LINEAR_PT_VIRT_START>>(L2_PAGETABLE_SHIFT-L1_PAGETABLE_SHIFT))))
     2.6  
     2.7 +#define va_to_l1mfn(_va) (l2_pgentry_val(linear_l2_table[_va>>L2_PAGETABLE_SHIFT]) >> PAGE_SHIFT)
     2.8 +
     2.9  extern l2_pgentry_t idle_pg_table[ENTRIES_PER_L2_PAGETABLE];
    2.10  extern void paging_init(void);
    2.11  
     3.1 --- a/xen/include/xen/shadow.h	Fri Apr 02 16:27:52 2004 +0000
     3.2 +++ b/xen/include/xen/shadow.h	Mon Apr 05 06:40:47 2004 +0000
     3.3 @@ -82,8 +82,12 @@ static inline void mark_dirty( struct mm
     3.4  	ASSERT(m->shadow_dirty_bitmap);
     3.5  	if( likely(pfn<m->shadow_dirty_bitmap_size) )
     3.6  	{
     3.7 -		// use setbit to be smp guest safe
     3.8 -		set_bit( pfn, m->shadow_dirty_bitmap );
     3.9 +		/* use setbit to be smp guest safe. Since the same page is likely to 
    3.10 +		   get marked dirty many times, examine the bit first before doing the
    3.11 +		   expensive lock-prefixed opertion */
    3.12 +
    3.13 +		if (! test_bit( pfn, m->shadow_dirty_bitmap ) )
    3.14 +			set_bit( pfn, m->shadow_dirty_bitmap );
    3.15  	}
    3.16  	else
    3.17  	{
    3.18 @@ -328,6 +332,18 @@ static inline unsigned long get_shadow_s
    3.19  {
    3.20  	unsigned long res;
    3.21  
    3.22 +	/* If we get here, we know that this domain is running in shadow mode. 
    3.23 +	   We also know that some sort of update has happened to the underlying
    3.24 +	   page table page: either a PTE has been updated, or the page has
    3.25 +	   changed type. If we're in log dirty mode, we should set the approrpiate
    3.26 +	   bit in the dirty bitmap.
    3.27 +	   NB: the VA update path doesn't use this so needs to be handled 
    3.28 +	   independnetly. 
    3.29 +	 */
    3.30 +
    3.31 +	if( m->shadow_mode == SHM_logdirty )
    3.32 +		mark_dirty( m, gpfn );
    3.33 +
    3.34  	spin_lock(&m->shadow_lock);
    3.35  	res = __shadow_status( m, gpfn );
    3.36  	if (!res) spin_unlock(&m->shadow_lock);