[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [XEN] PTE updates do not need to use CMPXCHG instruction.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxxxx
# Node ID 9d46e53c75f7598ab25b76b7a491801d1b320f5f
# Parent  2ac74e1df3d7d7751a128d2ad2fe9cc3a9d23c54
[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@xxxxxxxxxxxxx>
---
 xen/arch/x86/mm.c |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff -r 2ac74e1df3d7 -r 9d46e53c75f7 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Fri Jun 16 14:45:01 2006 +0100
+++ b/xen/arch/x86/mm.c Fri Jun 16 15:22:03 2006 +0100
@@ -1167,6 +1167,9 @@ static inline int update_l1e(l1_pgentry_
                              l1_pgentry_t  ol1e, 
                              l1_pgentry_t  nl1e)
 {
+#ifndef PTE_UPDATE_WITH_CMPXCHG
+    return !__copy_to_user(pl1e, &nl1e, sizeof(nl1e));
+#else
     intpte_t o = l1e_get_intpte(ol1e);
     intpte_t n = l1e_get_intpte(nl1e);
 
@@ -1181,6 +1184,7 @@ static inline int update_l1e(l1_pgentry_
         return 0;
     }
     return 1;
+#endif
 }
 
 
@@ -1228,6 +1232,9 @@ static int mod_l1_entry(l1_pgentry_t *pl
     return 1;
 }
 
+#ifndef PTE_UPDATE_WITH_CMPXCHG
+#define UPDATE_ENTRY(_t,_p,_o,_n) ({ (*(_p) = (_n)); 1; })
+#else
 #define UPDATE_ENTRY(_t,_p,_o,_n) ({                                    \
     intpte_t __o = cmpxchg((intpte_t *)(_p),                            \
                            _t ## e_get_intpte(_o),                      \
@@ -1239,6 +1246,7 @@ static int mod_l1_entry(l1_pgentry_t *pl
                 (_t ## e_get_intpte(_n)),                               \
                 (__o));                                                 \
     (__o == _t ## e_get_intpte(_o)); })
+#endif
 
 /* Update the L2 entry at pl2e to new value nl2e. pl2e is within frame pfn. */
 static int mod_l2_entry(l2_pgentry_t *pl2e, 
@@ -2408,12 +2416,16 @@ static int create_grant_pte_mapping(
         goto failed;
     }
 
-    if ( __copy_from_user(&ol1e, (l1_pgentry_t *)va, sizeof(ol1e)) ||
-         !update_l1e(va, ol1e, _nl1e) )
-    {
+    ol1e = *(l1_pgentry_t *)va;
+    if ( !update_l1e(va, ol1e, _nl1e) )
+    {
+#ifndef PTE_UPDATE_WITH_CMPXCHG
+        BUG();
+#else
         put_page_type(page);
         rc = GNTST_general_error;
         goto failed;
+#endif
     } 
 
     put_page_from_l1e(ol1e, d);
@@ -2531,7 +2543,13 @@ static int create_grant_va_mapping(
 
     if ( unlikely(__copy_from_user(&ol1e, pl1e, sizeof(ol1e)) != 0) ||
          !update_l1e(pl1e, ol1e, _nl1e) )
+    {
+#ifndef PTE_UPDATE_WITH_CMPXCHG
+        BUG();
+#else
         return GNTST_general_error;
+#endif
+    }
 
     put_page_from_l1e(ol1e, d);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.