ia64/xen-unstable

changeset 10901:556022fb8eb6

There is an allocation-failure path in sched_credit.c that BUGs. The
attached patch handles this potential failure case more gracefully.

Signed-off-by: Charles Coffing <ccoffing@novell.com>
author kfraser@localhost.localdomain
date Wed Aug 02 09:20:09 2006 +0100 (2006-08-02)
parents bbc27b921e2a
children 022f29d4d2b8
files xen/common/sched_credit.c
line diff
     1.1 --- a/xen/common/sched_credit.c	Wed Aug 02 09:16:26 2006 +0100
     1.2 +++ b/xen/common/sched_credit.c	Wed Aug 02 09:20:09 2006 +0100
     1.3 @@ -296,12 +296,17 @@ static inline void
     1.4          cpumask_raise_softirq(mask, SCHEDULE_SOFTIRQ);
     1.5  }
     1.6  
     1.7 -static void
     1.8 +static int
     1.9  csched_pcpu_init(int cpu)
    1.10  {
    1.11      struct csched_pcpu *spc;
    1.12      unsigned long flags;
    1.13  
    1.14 +    /* Allocate per-PCPU info */
    1.15 +    spc = xmalloc(struct csched_pcpu);
    1.16 +    if ( spc == NULL )
    1.17 +        return -1;
    1.18 +
    1.19      spin_lock_irqsave(&csched_priv.lock, flags);
    1.20  
    1.21      /* Initialize/update system-wide config */
    1.22 @@ -311,9 +316,6 @@ csched_pcpu_init(int cpu)
    1.23      if ( csched_priv.master >= csched_priv.ncpus )
    1.24          csched_priv.master = cpu;
    1.25  
    1.26 -    /* Allocate per-PCPU info */
    1.27 -    spc = xmalloc(struct csched_pcpu);
    1.28 -    BUG_ON( spc == NULL );
    1.29      INIT_LIST_HEAD(&spc->runq);
    1.30      spc->runq_sort_last = csched_priv.runq_sort;
    1.31      schedule_data[cpu].sched_priv = spc;
    1.32 @@ -323,6 +325,8 @@ csched_pcpu_init(int cpu)
    1.33      cpu_set(cpu, csched_priv.idlers);
    1.34  
    1.35      spin_unlock_irqrestore(&csched_priv.lock, flags);
    1.36 +
    1.37 +    return 0;
    1.38  }
    1.39  
    1.40  #ifndef NDEBUG
    1.41 @@ -490,7 +494,10 @@ csched_vcpu_init(struct vcpu *vc)
    1.42  
    1.43      /* Allocate per-PCPU info */
    1.44      if ( unlikely(!CSCHED_PCPU(vc->processor)) )
    1.45 -        csched_pcpu_init(vc->processor);
    1.46 +    {
    1.47 +        if ( csched_pcpu_init(vc->processor) != 0 )
    1.48 +            return -1;
    1.49 +    }
    1.50  
    1.51      CSCHED_VCPU_CHECK(vc);
    1.52