diff options
author | Keir Fraser <keir@xen.org> | 2011-02-06 16:07:27 +0000 |
---|---|---|
committer | Keir Fraser <keir@xen.org> | 2011-02-06 16:07:27 +0000 |
commit | b9a9873c2e97a765c5136b223bf8921f3bd40c66 (patch) | |
tree | 72c3bfe424d7204e11ad88e040d0d4fed7c87362 /xen/common/schedule.c | |
parent | a69a0358f60de0ce4d00645d1599f7f7284a32c2 (diff) | |
download | xen-b9a9873c2e97a765c5136b223bf8921f3bd40c66.tar.gz xen-b9a9873c2e97a765c5136b223bf8921f3bd40c66.tar.bz2 xen-b9a9873c2e97a765c5136b223bf8921f3bd40c66.zip |
cpupool: Check for memory allocation failure on switching schedulers
When switching schedulers on a physical cpu due to a cpupool operation
check for a potential memory allocation failure and stop the operation
gracefully.
Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
Diffstat (limited to 'xen/common/schedule.c')
-rw-r--r-- | xen/common/schedule.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/xen/common/schedule.c b/xen/common/schedule.c index dd348c952a..21509b6df1 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1288,7 +1288,7 @@ void __init scheduler_init(void) BUG(); } -void schedule_cpu_switch(unsigned int cpu, struct cpupool *c) +int schedule_cpu_switch(unsigned int cpu, struct cpupool *c) { unsigned long flags; struct vcpu *idle; @@ -1297,11 +1297,18 @@ void schedule_cpu_switch(unsigned int cpu, struct cpupool *c) struct scheduler *new_ops = (c == NULL) ? &ops : c->sched; if ( old_ops == new_ops ) - return; + return 0; idle = idle_vcpu[cpu]; ppriv = SCHED_OP(new_ops, alloc_pdata, cpu); + if ( ppriv == NULL ) + return -ENOMEM; vpriv = SCHED_OP(new_ops, alloc_vdata, idle, idle->domain->sched_priv); + if ( vpriv == NULL ) + { + SCHED_OP(new_ops, free_pdata, ppriv, cpu); + return -ENOMEM; + } pcpu_schedule_lock_irqsave(cpu, flags); @@ -1318,6 +1325,8 @@ void schedule_cpu_switch(unsigned int cpu, struct cpupool *c) SCHED_OP(old_ops, free_vdata, vpriv_old); SCHED_OP(old_ops, free_pdata, ppriv_old, cpu); + + return 0; } struct scheduler *scheduler_get_default(void) |