diff options
author | Dario Faggioli <dario.faggioli@citrix.com> | 2012-01-04 16:12:44 +0000 |
---|---|---|
committer | Dario Faggioli <dario.faggioli@citrix.com> | 2012-01-04 16:12:44 +0000 |
commit | a33389c34e9dd9e4877dd96c5b189fc9d6230ff7 (patch) | |
tree | 63d9bf351eb96ecfc42e975b702b8da3009dd4bd /xen/common/sched_credit.c | |
parent | 4da8a5edbd7800568eb4af5adc118e174e876694 (diff) | |
download | xen-a33389c34e9dd9e4877dd96c5b189fc9d6230ff7.tar.gz xen-a33389c34e9dd9e4877dd96c5b189fc9d6230ff7.tar.bz2 xen-a33389c34e9dd9e4877dd96c5b189fc9d6230ff7.zip |
Rework locking for sched_adjust.
The main idea is to move (as much as possible) locking logic
from generic code to the various pluggable schedulers.
While at it, the following is also accomplished:
- pausing all the non-current VCPUs of a domain while changing its
scheduling parameters is not effective in avoiding races and it is
prone to deadlock, so that is removed.
- sedf needs a global lock for preventing races while adjusting
domains' scheduling parameters (as it is for credit and credit2),
so that is added.
Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/common/sched_credit.c')
-rw-r--r-- | xen/common/sched_credit.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 4fa6140da5..c959a47d65 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -161,6 +161,7 @@ struct csched_dom { * System-wide private data */ struct csched_private { + /* lock for the whole pluggable scheduler, nests inside cpupool_lock */ spinlock_t lock; struct list_head active_sdom; uint32_t ncpus; @@ -800,6 +801,10 @@ csched_dom_cntl( struct csched_private *prv = CSCHED_PRIV(ops); unsigned long flags; + /* Protect both get and put branches with the pluggable scheduler + * lock. Runq lock not needed anywhere in here. */ + spin_lock_irqsave(&prv->lock, flags); + if ( op->cmd == XEN_DOMCTL_SCHEDOP_getinfo ) { op->u.credit.weight = sdom->weight; @@ -809,8 +814,6 @@ csched_dom_cntl( { ASSERT(op->cmd == XEN_DOMCTL_SCHEDOP_putinfo); - spin_lock_irqsave(&prv->lock, flags); - if ( op->u.credit.weight != 0 ) { if ( !list_empty(&sdom->active_sdom_elem) ) @@ -824,9 +827,10 @@ csched_dom_cntl( if ( op->u.credit.cap != (uint16_t)~0U ) sdom->cap = op->u.credit.cap; - spin_unlock_irqrestore(&prv->lock, flags); } + spin_unlock_irqrestore(&prv->lock, flags); + return 0; } |