File 5aeaeae4-introduce-vcpu_sleep_nosync_locked.patch of Package xen.23721

commit 2ae5d71bc81af42258766731d5a4c1dca4b38c99
Author: George Dunlap <george.dunlap@citrix.com>
Date:   Fri Apr 13 13:05:35 2018 +0200

    xen: Introduce vcpu_sleep_nosync_locked()
    
    There are a lot of places which release a lock before calling
    vcpu_sleep_nosync(), which then just grabs the lock again.  This is
    not only a waste of time, but leads to more code duplication (since
    you have to copy-and-paste recipes rather than calling a unified
    function), which in turn leads to an increased chance of bugs.
    
    Introduce vcpu_sleep_nosync_locked(), which can be called if you
    already hold the schedule lock.
    
    Signed-off-by: George Dunlap <george.dunlap@citrix.com>

diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index ed3a3175e2..9594a4a3e4 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -424,14 +424,9 @@ void sched_destroy_domain(struct domain *d)
     cpupool_rm_domain(d);
 }
 
-void vcpu_sleep_nosync(struct vcpu *v)
+void vcpu_sleep_nosync_locked(struct vcpu *v)
 {
-    unsigned long flags;
-    spinlock_t *lock;
-
-    TRACE_2D(TRC_SCHED_SLEEP, v->domain->domain_id, v->vcpu_id);
-
-    lock = vcpu_schedule_lock_irqsave(v, &flags);
+    ASSERT(spin_is_locked(per_cpu(schedule_data,v->processor).schedule_lock));
 
     if ( likely(!vcpu_runnable(v)) )
     {
@@ -440,6 +435,18 @@ void vcpu_sleep_nosync(struct vcpu *v)
 
         SCHED_OP(VCPU2OP(v), sleep, v);
     }
+}
+
+void vcpu_sleep_nosync(struct vcpu *v)
+{
+    unsigned long flags;
+    spinlock_t *lock;
+
+    TRACE_2D(TRC_SCHED_SLEEP, v->domain->domain_id, v->vcpu_id);
+
+    lock = vcpu_schedule_lock_irqsave(v, &flags);
+
+    vcpu_sleep_nosync_locked(v);
 
     vcpu_schedule_unlock_irqrestore(lock, flags, v);
 }
openSUSE Build Service is sponsored by