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

[Xen-changelog] Avoid unnecessary pte flags changes, which are costly on Xen. Also clean



ChangeSet 1.1351, 2005/03/23 08:59:22+00:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Avoid unnecessary pte flags changes, which are costly on Xen. Also clean
        up XCHG handling in instruction emulator a little bit.
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h |   13 ++++++++-
 xen/arch/x86/x86_emulate.c                                 |   17 ++++++-------
 2 files changed, 19 insertions(+), 11 deletions(-)


diff -Nru a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h 
b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h
--- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h        
2005-03-23 05:03:00 -05:00
+++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h        
2005-03-23 05:03:00 -05:00
@@ -263,8 +263,17 @@
        return test_and_clear_bit(_PAGE_BIT_ACCESSED, &ptep->pte_low);
 }
 
-static inline void ptep_set_wrprotect(pte_t *ptep)             { 
clear_bit(_PAGE_BIT_RW, &ptep->pte_low); }
-static inline void ptep_mkdirty(pte_t *ptep)                   { 
set_bit(_PAGE_BIT_DIRTY, &ptep->pte_low); }
+static inline void ptep_set_wrprotect(pte_t *ptep)
+{
+       if (pte_write(*ptep))
+               clear_bit(_PAGE_BIT_RW, &ptep->pte_low);
+}
+
+static inline void ptep_mkdirty(pte_t *ptep)
+{
+       if (!pte_dirty(*ptep))
+               set_bit(_PAGE_BIT_DIRTY, &ptep->pte_low);
+}
 
 /*
  * Macro to mark a page protection value as "uncacheable".  On processors 
which do not support
diff -Nru a/xen/arch/x86/x86_emulate.c b/xen/arch/x86/x86_emulate.c
--- a/xen/arch/x86/x86_emulate.c        2005-03-23 05:03:00 -05:00
+++ b/xen/arch/x86/x86_emulate.c        2005-03-23 05:03:00 -05:00
@@ -668,18 +668,17 @@
         emulate_2op_SrcV("test", src, dst, _regs.eflags);
         break;
     case 0x86 ... 0x87: /* xchg */
-        src.val ^= dst.val;
-        dst.val ^= src.val;
-        src.val ^= dst.val;
-        lock_prefix = 1;
-        /* Write back the source (temporary register location). */
+        /* Write back the register source. */
         switch ( dst.bytes )
         {
-        case 1: *(u8  *)src.ptr = (u8)src.val; break;
-        case 2: *(u16 *)src.ptr = (u16)src.val; break;
-        case 4: *src.ptr = (u32)src.val; break; /* 64b mode: zero-extend */
-        case 8: *src.ptr = src.val; break;
+        case 1: *(u8  *)src.ptr = (u8)dst.val; break;
+        case 2: *(u16 *)src.ptr = (u16)dst.val; break;
+        case 4: *src.ptr = (u32)dst.val; break; /* 64b mode: zero-extend */
+        case 8: *src.ptr = dst.val; break;
         }
+        /* Write back the memory destination with implicit LOCK prefix. */
+        dst.val = src.val;
+        lock_prefix = 1;
         break;
     case 0xa0 ... 0xa1: /* mov */
         dst.ptr = (unsigned long *)&_regs.eax;


-------------------------------------------------------
This SF.net email is sponsored by: 2005 Windows Mobile Application Contest
Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones
for the chance to win $25,000 and application distribution. Enter today at
http://ads.osdn.com/?ad_id=6882&alloc_id=15148&op=click
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-changelog


 


Rackspace

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