common: introduce vcpu_{,un}pause_by_systemcontroller() helpers
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 25 Jul 2014 09:54:20 +0000 (11:54 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 25 Jul 2014 09:54:20 +0000 (11:54 +0200)
Which will be used by following patches.  Reorder the function declarations
for vcpu/domain pause/unpause to group by vcpu/domain and visually separate
them slightly.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/domain.c
xen/include/xen/sched.h

index cd64aea7ac905219d702ae5fa9137e8f62288689..d7a84cf3cbfa35a0fdc04efafd1714752c3fa56f 100644 (file)
@@ -878,6 +878,46 @@ void vcpu_unpause(struct vcpu *v)
         vcpu_wake(v);
 }
 
+int vcpu_pause_by_systemcontroller(struct vcpu *v)
+{
+    int old, new, prev = v->controller_pause_count;
+
+    do
+    {
+        old = prev;
+        new = old + 1;
+
+        if ( new > 255 )
+            return -EUSERS;
+
+        prev = cmpxchg(&v->controller_pause_count, old, new);
+    } while ( prev != old );
+
+    vcpu_pause(v);
+
+    return 0;
+}
+
+int vcpu_unpause_by_systemcontroller(struct vcpu *v)
+{
+    int old, new, prev = v->controller_pause_count;
+
+    do
+    {
+        old = prev;
+        new = old - 1;
+
+        if ( new < 0 )
+            return -EINVAL;
+
+        prev = cmpxchg(&v->controller_pause_count, old, new);
+    } while ( prev != old );
+
+    vcpu_unpause(v);
+
+    return 0;
+}
+
 void domain_pause(struct domain *d)
 {
     struct vcpu *v;
index 62a4785ba4c5dbfb16547937cf4d3972285bd7fd..67eb8f078014e58a0a091de0ddafafcca4fb8b69 100644 (file)
@@ -216,6 +216,8 @@ struct vcpu
 
     /* VCPU paused for mem_event replies. */
     atomic_t         mem_event_pause_count;
+    /* VCPU paused by system controller. */
+    int              controller_pause_count;
 
     /* IRQ-safe virq_lock protects against delivering VIRQ to stale evtchn. */
     evtchn_port_t    virq_to_evtchn[NR_VIRQS];
@@ -768,9 +770,12 @@ void vcpu_block(void);
 void vcpu_unblock(struct vcpu *v);
 void vcpu_pause(struct vcpu *v);
 void vcpu_pause_nosync(struct vcpu *v);
+void vcpu_unpause(struct vcpu *v);
+int vcpu_pause_by_systemcontroller(struct vcpu *v);
+int vcpu_unpause_by_systemcontroller(struct vcpu *v);
+
 void domain_pause(struct domain *d);
 void domain_pause_nosync(struct domain *d);
-void vcpu_unpause(struct vcpu *v);
 void domain_unpause(struct domain *d);
 int domain_unpause_by_systemcontroller(struct domain *d);
 int __domain_pause_by_systemcontroller(struct domain *d,