ia64/xen-unstable

changeset 10453:9d46e53c75f7

[XEN] PTE updates do not need to use CMPXCHG instruction.
This is because the updates are already protected by a
per-domain lock. Using straightforward memory writes has
two advantages:
1. Faster
2. More correct (previously we could race accessed/dirty
bit updates by other CPUs).
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@dhcp93.uk.xensource.com
date Fri Jun 16 15:22:03 2006 +0100 (2006-06-16)
parents 2ac74e1df3d7
children 61a81fab2a02
files xen/arch/x86/mm.c
line diff
     1.1 --- a/xen/arch/x86/mm.c	Fri Jun 16 14:45:01 2006 +0100
     1.2 +++ b/xen/arch/x86/mm.c	Fri Jun 16 15:22:03 2006 +0100
     1.3 @@ -1167,6 +1167,9 @@ static inline int update_l1e(l1_pgentry_
     1.4                               l1_pgentry_t  ol1e, 
     1.5                               l1_pgentry_t  nl1e)
     1.6  {
     1.7 +#ifndef PTE_UPDATE_WITH_CMPXCHG
     1.8 +    return !__copy_to_user(pl1e, &nl1e, sizeof(nl1e));
     1.9 +#else
    1.10      intpte_t o = l1e_get_intpte(ol1e);
    1.11      intpte_t n = l1e_get_intpte(nl1e);
    1.12  
    1.13 @@ -1181,6 +1184,7 @@ static inline int update_l1e(l1_pgentry_
    1.14          return 0;
    1.15      }
    1.16      return 1;
    1.17 +#endif
    1.18  }
    1.19  
    1.20  
    1.21 @@ -1228,6 +1232,9 @@ static int mod_l1_entry(l1_pgentry_t *pl
    1.22      return 1;
    1.23  }
    1.24  
    1.25 +#ifndef PTE_UPDATE_WITH_CMPXCHG
    1.26 +#define UPDATE_ENTRY(_t,_p,_o,_n) ({ (*(_p) = (_n)); 1; })
    1.27 +#else
    1.28  #define UPDATE_ENTRY(_t,_p,_o,_n) ({                                    \
    1.29      intpte_t __o = cmpxchg((intpte_t *)(_p),                            \
    1.30                             _t ## e_get_intpte(_o),                      \
    1.31 @@ -1239,6 +1246,7 @@ static int mod_l1_entry(l1_pgentry_t *pl
    1.32                  (_t ## e_get_intpte(_n)),                               \
    1.33                  (__o));                                                 \
    1.34      (__o == _t ## e_get_intpte(_o)); })
    1.35 +#endif
    1.36  
    1.37  /* Update the L2 entry at pl2e to new value nl2e. pl2e is within frame pfn. */
    1.38  static int mod_l2_entry(l2_pgentry_t *pl2e, 
    1.39 @@ -2408,12 +2416,16 @@ static int create_grant_pte_mapping(
    1.40          goto failed;
    1.41      }
    1.42  
    1.43 -    if ( __copy_from_user(&ol1e, (l1_pgentry_t *)va, sizeof(ol1e)) ||
    1.44 -         !update_l1e(va, ol1e, _nl1e) )
    1.45 +    ol1e = *(l1_pgentry_t *)va;
    1.46 +    if ( !update_l1e(va, ol1e, _nl1e) )
    1.47      {
    1.48 +#ifndef PTE_UPDATE_WITH_CMPXCHG
    1.49 +        BUG();
    1.50 +#else
    1.51          put_page_type(page);
    1.52          rc = GNTST_general_error;
    1.53          goto failed;
    1.54 +#endif
    1.55      } 
    1.56  
    1.57      put_page_from_l1e(ol1e, d);
    1.58 @@ -2531,7 +2543,13 @@ static int create_grant_va_mapping(
    1.59  
    1.60      if ( unlikely(__copy_from_user(&ol1e, pl1e, sizeof(ol1e)) != 0) ||
    1.61           !update_l1e(pl1e, ol1e, _nl1e) )
    1.62 +    {
    1.63 +#ifndef PTE_UPDATE_WITH_CMPXCHG
    1.64 +        BUG();
    1.65 +#else
    1.66          return GNTST_general_error;
    1.67 +#endif
    1.68 +    }
    1.69  
    1.70      put_page_from_l1e(ol1e, d);
    1.71