diff options
author | Keir Fraser <keir@xen.org> | 2010-10-24 13:09:50 +0100 |
---|---|---|
committer | Keir Fraser <keir@xen.org> | 2010-10-24 13:09:50 +0100 |
commit | 7e6b926a17db1d63f1b8fd2745776f5369dacb4e (patch) | |
tree | 753bf45413056dc82c8d309d919a048149ff802b /xen/common/sched_credit.c | |
parent | 8e5c88afb0fb552ba803fecc1952d01293442d7d (diff) | |
download | xen-7e6b926a17db1d63f1b8fd2745776f5369dacb4e.tar.gz xen-7e6b926a17db1d63f1b8fd2745776f5369dacb4e.tar.bz2 xen-7e6b926a17db1d63f1b8fd2745776f5369dacb4e.zip |
cpupools: Make interface more consistent
The current cpupools code interface is a bit inconsistent. This
patch addresses this by making the interaction for each
vcpu in a pool look like this:
alloc_vdata() -- allocates and sets up vcpu data
insert_vcpu() -- the vcpu is ready to run in this pool
remove_vcpu() -- take the vcpu out of the pool
free_vdata() -- delete allocated vcpu data
(Previously, remove_vcpu and free_vdata were combined into a "destroy
vcpu", and insert_vcpu was only called for idle vcpus.)
This also addresses a bug in credit2 which was caused by a
misunderstanding of the cpupools interface.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
Diffstat (limited to 'xen/common/sched_credit.c')
-rw-r--r-- | xen/common/sched_credit.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 64369c3462..aad47706a9 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -677,35 +677,35 @@ csched_vcpu_insert(const struct scheduler *ops, struct vcpu *vc) static void csched_free_vdata(const struct scheduler *ops, void *priv) { - struct csched_private *prv = CSCHED_PRIV(ops); struct csched_vcpu *svc = priv; - unsigned long flags; - - if ( __vcpu_on_runq(svc) ) - __runq_remove(svc); - - spin_lock_irqsave(&(prv->lock), flags); - if ( !list_empty(&svc->active_vcpu_elem) ) - __csched_vcpu_acct_stop_locked(prv, svc); - - spin_unlock_irqrestore(&(prv->lock), flags); + BUG_ON( !list_empty(&svc->runq_elem) ); xfree(svc); } static void -csched_vcpu_destroy(const struct scheduler *ops, struct vcpu *vc) +csched_vcpu_remove(const struct scheduler *ops, struct vcpu *vc) { + struct csched_private *prv = CSCHED_PRIV(ops); struct csched_vcpu * const svc = CSCHED_VCPU(vc); struct csched_dom * const sdom = svc->sdom; + unsigned long flags; CSCHED_STAT_CRANK(vcpu_destroy); + if ( __vcpu_on_runq(svc) ) + __runq_remove(svc); + + spin_lock_irqsave(&(prv->lock), flags); + + if ( !list_empty(&svc->active_vcpu_elem) ) + __csched_vcpu_acct_stop_locked(prv, svc); + + spin_unlock_irqrestore(&(prv->lock), flags); + BUG_ON( sdom == NULL ); BUG_ON( !list_empty(&svc->runq_elem) ); - - csched_free_vdata(ops, svc); } static void @@ -1561,7 +1561,7 @@ const struct scheduler sched_credit_def = { .destroy_domain = csched_dom_destroy, .insert_vcpu = csched_vcpu_insert, - .destroy_vcpu = csched_vcpu_destroy, + .remove_vcpu = csched_vcpu_remove, .sleep = csched_vcpu_sleep, .wake = csched_vcpu_wake, |