ia64/xen-unstable

changeset 13224:25723963a6b6

Minor clean ups to shadow logdirty peek / clean.

Signed-off-by: Steven Hand <steven@xensource.com>
author Steven Hand <steven@xensource.com>
date Fri Dec 29 14:25:03 2006 +0000 (2006-12-29)
parents a8b2738a6f7f
children f0e9c518d0ff
files xen/arch/x86/mm/shadow/common.c
line diff
     1.1 --- a/xen/arch/x86/mm/shadow/common.c	Fri Dec 29 14:12:55 2006 +0000
     1.2 +++ b/xen/arch/x86/mm/shadow/common.c	Fri Dec 29 14:25:03 2006 +0000
     1.3 @@ -3123,7 +3123,7 @@ void shadow_convert_to_log_dirty(struct 
     1.4  static int shadow_log_dirty_op(
     1.5      struct domain *d, struct xen_domctl_shadow_op *sc)
     1.6  {
     1.7 -    int i, rv = 0, clean = 0;
     1.8 +    int i, rv = 0, clean = 0, peek = 1;
     1.9  
    1.10      domain_pause(d);
    1.11      shadow_lock(d);
    1.12 @@ -3137,12 +3137,12 @@ static int shadow_log_dirty_op(
    1.13                    d->arch.shadow.dirty_count);
    1.14  
    1.15      sc->stats.fault_count = d->arch.shadow.fault_count;
    1.16 -    sc->stats.dirty_count = d->arch.shadow.dirty_count;    
    1.17 -        
    1.18 -    if ( clean ) 
    1.19 +    sc->stats.dirty_count = d->arch.shadow.dirty_count;
    1.20 +
    1.21 +    if ( clean )
    1.22      {
    1.23 -        /* Need to revoke write access to the domain's pages again. 
    1.24 -         * In future, we'll have a less heavy-handed approach to this, 
    1.25 +        /* Need to revoke write access to the domain's pages again.
    1.26 +         * In future, we'll have a less heavy-handed approach to this,
    1.27           * but for now, we just unshadow everything except Xen. */
    1.28          shadow_blow_tables(d);
    1.29  
    1.30 @@ -3150,31 +3150,37 @@ static int shadow_log_dirty_op(
    1.31          d->arch.shadow.dirty_count = 0;
    1.32      }
    1.33  
    1.34 -    if ( guest_handle_is_null(sc->dirty_bitmap) ||
    1.35 -         (d->arch.shadow.dirty_bitmap == NULL) )
    1.36 +    if ( guest_handle_is_null(sc->dirty_bitmap) )
    1.37 +        /* caller may have wanted just to clean the state or access stats. */
    1.38 +        peek = 0;
    1.39 +
    1.40 +    if ( (peek || clean) && (d->arch.shadow.dirty_bitmap == NULL) )
    1.41      {
    1.42 -        rv = -EINVAL;
    1.43 +        rv = -EINVAL; /* perhaps should be ENOMEM? */
    1.44          goto out;
    1.45      }
    1.46   
    1.47      if ( sc->pages > d->arch.shadow.dirty_bitmap_size )
    1.48 -        sc->pages = d->arch.shadow.dirty_bitmap_size; 
    1.49 +        sc->pages = d->arch.shadow.dirty_bitmap_size;
    1.50  
    1.51  #define CHUNK (8*1024) /* Transfer and clear in 1kB chunks for L1 cache. */
    1.52      for ( i = 0; i < sc->pages; i += CHUNK )
    1.53      {
    1.54 -        int bytes = ((((sc->pages - i) > CHUNK) 
    1.55 -                      ? CHUNK 
    1.56 +        int bytes = ((((sc->pages - i) > CHUNK)
    1.57 +                      ? CHUNK
    1.58                        : (sc->pages - i)) + 7) / 8;
    1.59 -     
    1.60 -        if ( copy_to_guest_offset(
    1.61 -                 sc->dirty_bitmap, 
    1.62 -                 i/(8*sizeof(unsigned long)),
    1.63 -                 d->arch.shadow.dirty_bitmap + (i/(8*sizeof(unsigned long))),
    1.64 -                 (bytes + sizeof(unsigned long) - 1) / sizeof(unsigned long)) )
    1.65 +
    1.66 +        if ( likely(peek) )
    1.67          {
    1.68 -            rv = -EINVAL;
    1.69 -            goto out;
    1.70 +            if ( copy_to_guest_offset(
    1.71 +                     sc->dirty_bitmap,
    1.72 +                     i/(8*sizeof(unsigned long)),
    1.73 +                     d->arch.shadow.dirty_bitmap+(i/(8*sizeof(unsigned long))),
    1.74 +                     (bytes+sizeof(unsigned long)-1) / sizeof(unsigned long)) )
    1.75 +            {
    1.76 +                    rv = -EFAULT;
    1.77 +                    goto out;
    1.78 +            }
    1.79          }
    1.80  
    1.81          if ( clean )