diff options
author | Juergen Gross <juergen.gross@ts.fujitsu.com> | 2011-11-18 13:34:43 +0000 |
---|---|---|
committer | Juergen Gross <juergen.gross@ts.fujitsu.com> | 2011-11-18 13:34:43 +0000 |
commit | f42d7a66bf44fdff582a4e2ff2c33e99a579c0d4 (patch) | |
tree | 4c649865d20d1d9caf54ec4556cc6ea04a212a42 /xen | |
parent | 95ad9f65c972a3439ae6d11243373be16f71cb94 (diff) | |
download | xen-f42d7a66bf44fdff582a4e2ff2c33e99a579c0d4.tar.gz xen-f42d7a66bf44fdff582a4e2ff2c33e99a579c0d4.tar.bz2 xen-f42d7a66bf44fdff582a4e2ff2c33e99a579c0d4.zip |
sched_sedf: Avoid panic when adjusting sedf parameters
When using sedf scheduler in a cpupool the system might panic when
setting sedf scheduling parameters for a domain. Introduces
for_each_domain_in_cpupool macro as it is usable 4 times now. Add
appropriate locking in cpupool_unassign_cpu().
Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
Committed-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen')
-rw-r--r-- | xen/common/cpupool.c | 6 | ||||
-rw-r--r-- | xen/common/sched_sedf.c | 8 | ||||
-rw-r--r-- | xen/common/schedule.c | 5 | ||||
-rw-r--r-- | xen/include/xen/sched.h | 20 |
4 files changed, 28 insertions, 11 deletions
diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index fcc44b1e57..45162ad708 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -309,10 +309,9 @@ int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu) if ( (c->n_dom > 0) && (cpumask_weight(c->cpu_valid) == 1) && (cpu != cpupool_moving_cpu) ) { - for_each_domain(d) + rcu_read_lock(&domlist_read_lock); + for_each_domain_in_cpupool(d, c) { - if ( d->cpupool != c ) - continue; if ( !d->is_dying ) { ret = -EBUSY; @@ -327,6 +326,7 @@ int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu) } cpupool0->n_dom++; } + rcu_read_unlock(&domlist_read_lock); if ( ret ) goto out; } diff --git a/xen/common/sched_sedf.c b/xen/common/sched_sedf.c index 76b0e9d68c..8bff90c44a 100644 --- a/xen/common/sched_sedf.c +++ b/xen/common/sched_sedf.c @@ -1304,6 +1304,8 @@ static void sedf_dump_cpu_state(const struct scheduler *ops, int i) rcu_read_lock(&domlist_read_lock); for_each_domain ( d ) { + if ( (d->cpupool ? d->cpupool->sched : &sched_sedf_def) != ops ) + continue; for_each_vcpu(d, ed) { if ( !__task_on_queue(ed) && (ed->processor == i) ) @@ -1335,10 +1337,8 @@ static int sedf_adjust_weights(struct cpupool *c, struct xen_domctl_scheduler_op /* Sum across all weights. */ rcu_read_lock(&domlist_read_lock); - for_each_domain( d ) + for_each_domain_in_cpupool( d, c ) { - if ( c != d->cpupool ) - continue; for_each_vcpu( d, p ) { if ( (cpu = p->processor) >= nr_cpus ) @@ -1367,7 +1367,7 @@ static int sedf_adjust_weights(struct cpupool *c, struct xen_domctl_scheduler_op /* Adjust all slices (and periods) to the new weight. */ rcu_read_lock(&domlist_read_lock); - for_each_domain( d ) + for_each_domain_in_cpupool( d, c ) { for_each_vcpu ( d, p ) { diff --git a/xen/common/schedule.c b/xen/common/schedule.c index c07d6f0f98..0455619ac2 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -538,11 +538,8 @@ int cpu_disable_scheduler(unsigned int cpu) if ( c == NULL ) return ret; - for_each_domain ( d ) + for_each_domain_in_cpupool ( d, c ) { - if ( d->cpupool != c ) - continue; - affinity_broken = 0; for_each_vcpu ( d, v ) diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 80d5c4b758..e12293cafc 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -564,11 +564,31 @@ void hypercall_cancel_continuation(void); extern struct domain *domain_list; /* Caller must hold the domlist_read_lock or domlist_update_lock. */ +static inline struct domain *first_domain_in_cpupool( struct cpupool *c) +{ + struct domain *d; + for (d = rcu_dereference(domain_list); d && d->cpupool != c; + d = rcu_dereference(d->next_in_list)); + return d; +} +static inline struct domain *next_domain_in_cpupool( + struct domain *d, struct cpupool *c) +{ + for (d = rcu_dereference(d->next_in_list); d && d->cpupool != c; + d = rcu_dereference(d->next_in_list)); + return d; +} + #define for_each_domain(_d) \ for ( (_d) = rcu_dereference(domain_list); \ (_d) != NULL; \ (_d) = rcu_dereference((_d)->next_in_list )) \ +#define for_each_domain_in_cpupool(_d,_c) \ + for ( (_d) = first_domain_in_cpupool(_c); \ + (_d) != NULL; \ + (_d) = next_domain_in_cpupool((_d), (_c))) + #define for_each_vcpu(_d,_v) \ for ( (_v) = (_d)->vcpu ? (_d)->vcpu[0] : NULL; \ (_v) != NULL; \ |