Refactor sync_lazy_execstate_cpu() into the more sensible
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 26 Aug 2005 17:57:09 +0000 (17:57 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 26 Aug 2005 17:57:09 +0000 (17:57 +0000)
sync_vcpu_execstate().

Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/ia64/xenmisc.c
xen/arch/x86/domain.c
xen/common/schedule.c
xen/include/xen/sched.h

index c76a93eca8a8d538377316555a145064609c86ac..e651db4c65f71d8bb633723bbcc7bfd3f3c516bf 100644 (file)
@@ -58,7 +58,7 @@ platform_is_hp_ski(void)
 
 /* calls in xen/common code that are unused on ia64 */
 
-void sync_lazy_execstate_cpu(unsigned int cpu) {}
+void sync_vcpu_execstate(struct vcpu *v) {}
 
 #ifdef CONFIG_VTI
 int grant_table_create(struct domain *d) { return 0; }
index db1d630e6423920991c9bdc224ed98a830024385..974ec0c2dc04af5cc12138237cc0c7011ea33cc9 100644 (file)
@@ -885,8 +885,13 @@ int __sync_lazy_execstate(void)
     return switch_required;
 }
 
-void sync_lazy_execstate_cpu(unsigned int cpu)
+void sync_vcpu_execstate(struct vcpu *v)
 {
+    unsigned int cpu = v->processor;
+
+    if ( !cpu_isset(cpu, v->domain->cpumask) )
+        return;
+
     if ( cpu == smp_processor_id() )
     {
         (void)__sync_lazy_execstate();
index 3cec1097278fb12add7266239e30c5acd474269f..ff9373d60f1687d92b7b1c71a29435f39f8391b5 100644 (file)
@@ -218,9 +218,7 @@ void vcpu_sleep_sync(struct vcpu *v)
             && spin_is_locked(&schedule_data[v->processor].schedule_lock) )
         cpu_relax();
 
-    /* Counteract lazy context switching. */
-    if ( cpu_isset(v->processor, v->domain->cpumask) )
-        sync_lazy_execstate_cpu(v->processor);
+    sync_vcpu_execstate(v);
 }
 
 void vcpu_wake(struct vcpu *v)
index 2d93f7576d7491150cf5e97ab146034041274516..e7b06ff4cac5832d9ecddfe851cb6c7f2f7dfeeb 100644 (file)
@@ -250,10 +250,11 @@ void vcpu_sleep_nosync(struct vcpu *d);
 void vcpu_sleep_sync(struct vcpu *d);
 
 /*
- * Force loading of currently-executing domain state on the specified CPU.
- * This is used to counteract lazy state switching where required.
+ * Force synchronisation of given VCPU's state. If it is currently descheduled,
+ * this call will ensure that all its state is committed to memory and that
+ * no CPU is using critical state (e.g., page tables) belonging to the VCPU.
  */
-extern void sync_lazy_execstate_cpu(unsigned int cpu);
+extern void sync_vcpu_execstate(struct vcpu *v);
 
 /*
  * Called by the scheduler to switch to another VCPU. On entry, although
@@ -265,7 +266,7 @@ extern void sync_lazy_execstate_cpu(unsigned int cpu);
  * The callee must ensure that the local CPU is no longer running in @prev's
  * context, and that the context is saved to memory, before returning.
  * Alternatively, if implementing lazy context switching, it suffices to ensure
- * that invoking sync_lazy_execstate() will switch and commit @prev's state.
+ * that invoking sync_vcpu_execstate() will switch and commit @prev's state.
  */
 extern void context_switch(
     struct vcpu *prev,