ia64/xen-unstable

changeset 2642:3cb2cf1d6374

bitkeeper revision 1.1159.1.234 (416e95e7ig3rKKW3LsOEQgmh0FMeBg)

Small cleanups.
author kaf24@freefall.cl.cam.ac.uk
date Thu Oct 14 15:06:15 2004 +0000 (2004-10-14)
parents fbdffdf4bda9
children 33abe95e07ae
files xen/arch/x86/shadow.c
line diff
     1.1 --- a/xen/arch/x86/shadow.c	Thu Oct 14 13:36:09 2004 +0000
     1.2 +++ b/xen/arch/x86/shadow.c	Thu Oct 14 15:06:15 2004 +0000
     1.3 @@ -51,7 +51,7 @@ static inline void free_shadow_page(
     1.4      free_domheap_page(page);
     1.5  }
     1.6  
     1.7 -static void __free_shadow_table(struct mm_struct *m)
     1.8 +static void free_shadow_state(struct mm_struct *m)
     1.9  {
    1.10      int                   i, free = 0;
    1.11      struct shadow_status *x, *n;
    1.12 @@ -108,7 +108,7 @@ static void __free_shadow_table(struct m
    1.13      SH_LOG("Free shadow table. Freed=%d.", free);
    1.14  }
    1.15  
    1.16 -static inline int __clear_shadow_page(
    1.17 +static inline int clear_shadow_page(
    1.18      struct mm_struct *m, struct shadow_status *x)
    1.19  {
    1.20      unsigned long   *p;
    1.21 @@ -135,7 +135,7 @@ static inline int __clear_shadow_page(
    1.22      return restart;
    1.23  }
    1.24  
    1.25 -static void __clear_shadow_state(struct mm_struct *m)
    1.26 +static void clear_shadow_state(struct mm_struct *m)
    1.27  {
    1.28      int                   i;
    1.29      struct shadow_status *x;
    1.30 @@ -150,11 +150,11 @@ static void __clear_shadow_state(struct 
    1.31          if ( x->pfn == 0 )
    1.32              continue;
    1.33  
    1.34 -        if ( __clear_shadow_page(m, x) )
    1.35 +        if ( clear_shadow_page(m, x) )
    1.36              goto retry;
    1.37  
    1.38          for ( x = x->next; x != NULL; x = x->next )
    1.39 -            if ( __clear_shadow_page(m, x) )
    1.40 +            if ( clear_shadow_page(m, x) )
    1.41                  goto retry;
    1.42  
    1.43          shadow_audit(m, 0);
    1.44 @@ -209,7 +209,7 @@ void __shadow_mode_disable(struct domain
    1.45      struct mm_struct *m = &d->mm;
    1.46      struct shadow_status *x, *n;
    1.47  
    1.48 -    __free_shadow_table(m);
    1.49 +    free_shadow_state(m);
    1.50      m->shadow_mode = 0;
    1.51  
    1.52      SH_VLOG("freed tables count=%d l1=%d l2=%d",
    1.53 @@ -246,7 +246,7 @@ static int shadow_mode_table_op(
    1.54      struct mm_struct *m = &d->mm;
    1.55      int               i, rc = 0;
    1.56  
    1.57 -    ASSERT(spin_is_locked(&d->mm.shadow_lock));
    1.58 +    ASSERT(spin_is_locked(&m->shadow_lock));
    1.59  
    1.60      SH_VLOG("shadow mode table op %08lx %08lx count %d",
    1.61              pagetable_val(m->pagetable), pagetable_val(m->shadow_table),
    1.62 @@ -256,35 +256,41 @@ static int shadow_mode_table_op(
    1.63  
    1.64      switch ( op )
    1.65      {
    1.66 +        /* XXX KAF: Do we really need this function? Is it any use? */
    1.67      case DOM0_SHADOW_CONTROL_OP_FLUSH:
    1.68 -        __free_shadow_table( m );  
    1.69 +        free_shadow_state(m);
    1.70  
    1.71 -        d->mm.shadow_fault_count       = 0;
    1.72 -        d->mm.shadow_dirty_count       = 0;
    1.73 -        d->mm.shadow_dirty_net_count   = 0;
    1.74 -        d->mm.shadow_dirty_block_count = 0;
    1.75 +        m->shadow_fault_count       = 0;
    1.76 +        m->shadow_dirty_count       = 0;
    1.77 +        m->shadow_dirty_net_count   = 0;
    1.78 +        m->shadow_dirty_block_count = 0;
    1.79  
    1.80          break;
    1.81     
    1.82      case DOM0_SHADOW_CONTROL_OP_CLEAN:
    1.83 -        __clear_shadow_state(m);
    1.84 +        /*
    1.85 +         * XXX KAF: Why not just free_shadow_state()? Is zeroing L2's faster?
    1.86 +         * If so, why wouldn't zeroing L1's be better than freeing them, as we
    1.87 +         * do now?
    1.88 +         */
    1.89 +        clear_shadow_state(m);
    1.90  
    1.91 -        sc->stats.fault_count       = d->mm.shadow_fault_count;
    1.92 -        sc->stats.dirty_count       = d->mm.shadow_dirty_count;
    1.93 -        sc->stats.dirty_net_count   = d->mm.shadow_dirty_net_count;
    1.94 -        sc->stats.dirty_block_count = d->mm.shadow_dirty_block_count;
    1.95 +        sc->stats.fault_count       = m->shadow_fault_count;
    1.96 +        sc->stats.dirty_count       = m->shadow_dirty_count;
    1.97 +        sc->stats.dirty_net_count   = m->shadow_dirty_net_count;
    1.98 +        sc->stats.dirty_block_count = m->shadow_dirty_block_count;
    1.99  
   1.100 -        d->mm.shadow_fault_count       = 0;
   1.101 -        d->mm.shadow_dirty_count       = 0;
   1.102 -        d->mm.shadow_dirty_net_count   = 0;
   1.103 -        d->mm.shadow_dirty_block_count = 0;
   1.104 +        m->shadow_fault_count       = 0;
   1.105 +        m->shadow_dirty_count       = 0;
   1.106 +        m->shadow_dirty_net_count   = 0;
   1.107 +        m->shadow_dirty_block_count = 0;
   1.108   
   1.109          if ( (d->max_pages > sc->pages) || 
   1.110               (sc->dirty_bitmap == NULL) || 
   1.111 -             (d->mm.shadow_dirty_bitmap == NULL) )
   1.112 +             (m->shadow_dirty_bitmap == NULL) )
   1.113          {
   1.114              rc = -EINVAL;
   1.115 -            goto out;
   1.116 +            break;
   1.117          }
   1.118   
   1.119          sc->pages = d->max_pages;
   1.120 @@ -297,41 +303,41 @@ static int shadow_mode_table_op(
   1.121       
   1.122              copy_to_user(
   1.123                  sc->dirty_bitmap + (i/(8*sizeof(unsigned long))),
   1.124 -                d->mm.shadow_dirty_bitmap +(i/(8*sizeof(unsigned long))),
   1.125 +                m->shadow_dirty_bitmap +(i/(8*sizeof(unsigned long))),
   1.126                  bytes);
   1.127       
   1.128              memset(
   1.129 -                d->mm.shadow_dirty_bitmap + (i/(8*sizeof(unsigned long))),
   1.130 +                m->shadow_dirty_bitmap + (i/(8*sizeof(unsigned long))),
   1.131                  0, bytes);
   1.132          }
   1.133  
   1.134          break;
   1.135  
   1.136      case DOM0_SHADOW_CONTROL_OP_PEEK:
   1.137 -        sc->stats.fault_count       = d->mm.shadow_fault_count;
   1.138 -        sc->stats.dirty_count       = d->mm.shadow_dirty_count;
   1.139 -        sc->stats.dirty_net_count   = d->mm.shadow_dirty_net_count;
   1.140 -        sc->stats.dirty_block_count = d->mm.shadow_dirty_block_count;
   1.141 +        sc->stats.fault_count       = m->shadow_fault_count;
   1.142 +        sc->stats.dirty_count       = m->shadow_dirty_count;
   1.143 +        sc->stats.dirty_net_count   = m->shadow_dirty_net_count;
   1.144 +        sc->stats.dirty_block_count = m->shadow_dirty_block_count;
   1.145   
   1.146          if ( (d->max_pages > sc->pages) || 
   1.147               (sc->dirty_bitmap == NULL) || 
   1.148 -             (d->mm.shadow_dirty_bitmap == NULL) )
   1.149 +             (m->shadow_dirty_bitmap == NULL) )
   1.150          {
   1.151              rc = -EINVAL;
   1.152 -            goto out;
   1.153 +            break;
   1.154          }
   1.155   
   1.156          sc->pages = d->max_pages;
   1.157          copy_to_user(
   1.158 -            sc->dirty_bitmap, d->mm.shadow_dirty_bitmap, (d->max_pages+7)/8);
   1.159 +            sc->dirty_bitmap, m->shadow_dirty_bitmap, (d->max_pages+7)/8);
   1.160  
   1.161          break;
   1.162  
   1.163      default:
   1.164 -        BUG();
   1.165 +        rc = -EINVAL;
   1.166 +        break;
   1.167      }
   1.168  
   1.169 - out:
   1.170      SH_VLOG("shadow mode table op : page count %d", m->shadow_page_count);
   1.171      shadow_audit(m, 1);
   1.172      __shadow_mk_pagetable(m);
   1.173 @@ -340,8 +346,8 @@ static int shadow_mode_table_op(
   1.174  
   1.175  int shadow_mode_control(struct domain *d, dom0_shadow_control_t *sc)
   1.176  {
   1.177 -    unsigned int cmd = sc->op;
   1.178 -    int          rc  = 0;
   1.179 +    unsigned int op = sc->op;
   1.180 +    int          rc = 0;
   1.181  
   1.182      if ( unlikely(d == current) )
   1.183      {
   1.184 @@ -354,7 +360,7 @@ int shadow_mode_control(struct domain *d
   1.185  
   1.186      shadow_lock(&d->mm);
   1.187  
   1.188 -    switch ( cmd )
   1.189 +    switch ( op )
   1.190      {
   1.191      case DOM0_SHADOW_CONTROL_OP_OFF:
   1.192          shadow_mode_disable(d);
   1.193 @@ -371,12 +377,7 @@ int shadow_mode_control(struct domain *d
   1.194          break;
   1.195  
   1.196      default:
   1.197 -        if ( shadow_mode(d) && 
   1.198 -             (cmd >= DOM0_SHADOW_CONTROL_OP_FLUSH) && 
   1.199 -             (cmd <= DOM0_SHADOW_CONTROL_OP_PEEK) )
   1.200 -            rc = shadow_mode_table_op(d, sc);
   1.201 -        else
   1.202 -            rc = -EINVAL;
   1.203 +        rc = shadow_mode(d) ? shadow_mode_table_op(d, sc) : -EINVAL;
   1.204          break;
   1.205      }
   1.206