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

[Xen-changelog] [xen-3.4-testing] x86: extend runstate area updates



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1250696254 -3600
# Node ID ca4db4ff9101f51d89a3de9e756b8a2f90a2baf2
# Parent  5aacaeffd6f59838a947824f5b2e56c2849fa0d0
x86: extend runstate area updates

In order to give guests a hint at whether their vCPU-s are currently
scheduled (so they can e.g. adapt their behavior in spin loops),
update
the run state area (if registered) also when de-scheduling a vCPU.

Also fix an oversight in the compat mode implementation of
VCPUOP_register_runstate_memory_area.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
xen-unstable changeset:   20077:456b4ec00244
xen-unstable date:        Wed Aug 19 13:01:41 2009 +0100
---
 xen/arch/x86/domain.c        |   40 +++++++++++++++++++++++++---------------
 xen/arch/x86/x86_64/domain.c |    2 +-
 2 files changed, 26 insertions(+), 16 deletions(-)

diff -r 5aacaeffd6f5 -r ca4db4ff9101 xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Wed Aug 19 16:36:34 2009 +0100
+++ b/xen/arch/x86/domain.c     Wed Aug 19 16:37:34 2009 +0100
@@ -1219,6 +1219,26 @@ static void paravirt_ctxt_switch_to(stru
     }
 }
 
+/* Update per-VCPU guest runstate shared memory area (if registered). */
+static void update_runstate_area(struct vcpu *v)
+{
+    if ( guest_handle_is_null(runstate_guest(v)) )
+        return;
+
+#ifdef CONFIG_COMPAT
+    if ( is_pv_32on64_domain(v->domain) )
+    {
+        struct compat_vcpu_runstate_info info;
+
+        XLAT_vcpu_runstate_info(&info, &v->runstate);
+        __copy_to_guest(v->runstate_guest.compat, &info, 1);
+        return;
+    }
+#endif
+
+    __copy_to_guest(runstate_guest(v), &v->runstate, 1);
+}
+
 static inline int need_full_gdt(struct vcpu *v)
 {
     return (!is_hvm_vcpu(v) && !is_idle_vcpu(v));
@@ -1311,6 +1331,9 @@ void context_switch(struct vcpu *prev, s
         flush_tlb_mask(dirty_mask);
     }
 
+    if (prev != next)
+        update_runstate_area(prev);
+
     if ( is_hvm_vcpu(prev) && !list_empty(&prev->arch.hvm_vcpu.tm_list) )
         pt_save_timer(prev);
 
@@ -1350,21 +1373,8 @@ void context_switch(struct vcpu *prev, s
 
     context_saved(prev);
 
-    /* Update per-VCPU guest runstate shared memory area (if registered). */
-    if ( !guest_handle_is_null(runstate_guest(next)) )
-    {
-        if ( !is_pv_32on64_domain(next->domain) )
-            __copy_to_guest(runstate_guest(next), &next->runstate, 1);
-#ifdef CONFIG_COMPAT
-        else
-        {
-            struct compat_vcpu_runstate_info info;
-
-            XLAT_vcpu_runstate_info(&info, &next->runstate);
-            __copy_to_guest(next->runstate_guest.compat, &info, 1);
-        }
-#endif
-    }
+    if (prev != next)
+        update_runstate_area(next);
 
     schedule_tail(next);
     BUG();
diff -r 5aacaeffd6f5 -r ca4db4ff9101 xen/arch/x86/x86_64/domain.c
--- a/xen/arch/x86/x86_64/domain.c      Wed Aug 19 16:36:34 2009 +0100
+++ b/xen/arch/x86/x86_64/domain.c      Wed Aug 19 16:37:34 2009 +0100
@@ -56,7 +56,7 @@ arch_compat_vcpu_op(
             struct vcpu_runstate_info runstate;
 
             vcpu_runstate_get(v, &runstate);
-            XLAT_vcpu_runstate_info(&info, &v->runstate);
+            XLAT_vcpu_runstate_info(&info, &runstate);
         }
         __copy_to_guest(v->runstate_guest.compat, &info, 1);
 

_______________________________________________
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®.