sched: fix deadlock when changing scheduling parameters
authorChong Li <chong.li@wustl.edu>
Tue, 5 Apr 2016 11:25:44 +0000 (13:25 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 5 Apr 2016 11:25:44 +0000 (13:25 +0200)
Commit f7b87b0745b4 ("enable per-VCPU parameter for RTDS") introduced
a bug: it made it possible, in Credit and Credit2, when doing domain
or vcpu parameters' manipulation, to leave the hypervisor with a
spinlock held and interrupts disabled.

Fix it.

Signed-off-by: Chong Li <chong.li@wustl.edu>
Acked-by: Dario Faggioli <dario.faggioli@citrix.com>
xen/common/sched_credit.c
xen/common/sched_credit2.c

index e5d15d85255ac1d4070c29887ae0853ed79d8cc3..4c4927fac439e15b6c161e58583ef1d528594334 100644 (file)
@@ -1075,6 +1075,7 @@ csched_dom_cntl(
     struct csched_dom * const sdom = CSCHED_DOM(d);
     struct csched_private *prv = CSCHED_PRIV(ops);
     unsigned long flags;
+    int rc = 0;
 
     /* Protect both get and put branches with the pluggable scheduler
      * lock. Runq lock not needed anywhere in here. */
@@ -1101,12 +1102,13 @@ csched_dom_cntl(
             sdom->cap = op->u.credit.cap;
         break;
     default:
-        return -EINVAL;
+        rc = -EINVAL;
+        break;
     }
 
     spin_unlock_irqrestore(&prv->lock, flags);
 
-    return 0;
+    return rc;
 }
 
 static inline void
index d48ed5a3d3c2da8ab90a022c6a600e81013f5eb6..b8c8e40fc94e6d2ae3d6c99f59ef4046f9fe68b1 100644 (file)
@@ -1416,6 +1416,7 @@ csched2_dom_cntl(
     struct csched2_dom * const sdom = CSCHED2_DOM(d);
     struct csched2_private *prv = CSCHED2_PRIV(ops);
     unsigned long flags;
+    int rc = 0;
 
     /* Must hold csched2_priv lock to read and update sdom,
      * runq lock to update csvcs. */
@@ -1457,12 +1458,13 @@ csched2_dom_cntl(
         }
         break;
     default:
-        return -EINVAL;
+        rc = -EINVAL;
+        break;
     }
 
     spin_unlock_irqrestore(&prv->lock, flags);
 
-    return 0;
+    return rc;
 }
 
 static void *