[xen staging] xen: Introduce vcpu_sleep_nosync_locked()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen staging] xen: Introduce vcpu_sleep_nosync_locked()

patchbot
commit da0a5e00de8aa93f2a7482d138dbee9dec2aa5c2
Author:     George Dunlap <[hidden email]>
AuthorDate: Wed May 2 11:09:18 2018 +0100
Commit:     George Dunlap <[hidden email]>
CommitDate: Thu May 3 11:56:36 2018 +0100

    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 <[hidden email]>
    Reviewed-by: Dario Faggioli <[hidden email]>
    Release-acked-by: Juergen Gross <[hidden email]>
---
 xen/common/schedule.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 69d255389e..7489833361 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -455,14 +455,9 @@ void sched_destroy_domain(struct 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)) )
     {
@@ -471,6 +466,18 @@ void vcpu_sleep_nosync(struct vcpu *v)
 
         SCHED_OP(vcpu_scheduler(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);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog