ia64/xen-unstable

changeset 1512:af9edd9590d8

bitkeeper revision 1.989 (40d67c9em66pd7yVqnpYax0LoJ-lzw)

Bug fixes.
author kaf24@scramble.cl.cam.ac.uk
date Mon Jun 21 06:13:50 2004 +0000 (2004-06-21)
parents 3bcb3ae4e038
children 639166dab6cf
files xen/common/dom0_ops.c xen/common/schedule.c
line diff
     1.1 --- a/xen/common/dom0_ops.c	Sun Jun 20 13:51:29 2004 +0000
     1.2 +++ b/xen/common/dom0_ops.c	Mon Jun 21 06:13:50 2004 +0000
     1.3 @@ -103,9 +103,13 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     1.4          ret = -ESRCH;
     1.5          if ( d != NULL )
     1.6          {
     1.7 -            domain_stop(d);
     1.8 +            ret = -EINVAL;
     1.9 +            if ( d != current )
    1.10 +            {
    1.11 +                domain_stop(d);
    1.12 +                ret = 0;
    1.13 +            }
    1.14              put_domain(d);
    1.15 -            ret = 0;
    1.16          }
    1.17      }
    1.18      break;
    1.19 @@ -173,9 +177,9 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    1.20              if ( d != current )
    1.21              {
    1.22                  domain_kill(d);
    1.23 -                put_domain(d);
    1.24                  ret = 0;
    1.25              }
    1.26 +            put_domain(d);
    1.27          }
    1.28      }
    1.29      break;
    1.30 @@ -183,34 +187,35 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    1.31      case DOM0_PINCPUDOMAIN:
    1.32      {
    1.33          domid_t dom = op->u.pincpudomain.domain;
    1.34 +        struct domain *d = find_domain_by_id(dom);
    1.35 +        int cpu = op->u.pincpudomain.cpu;
    1.36 +
    1.37 +        if ( d == NULL )
    1.38 +        {
    1.39 +            ret = -ESRCH;            
    1.40 +            break;
    1.41 +        }
    1.42          
    1.43 -        if ( dom == current->domain || dom == IDLE_DOMAIN_ID )
    1.44 +        if ( d == current )
    1.45 +        {
    1.46              ret = -EINVAL;
    1.47 +            put_domain(d);
    1.48 +            break;
    1.49 +        }
    1.50 +
    1.51 +        if ( cpu == -1 )
    1.52 +        {
    1.53 +            clear_bit(DF_CPUPINNED, &d->flags);
    1.54 +        }
    1.55          else
    1.56          {
    1.57 -            struct domain *d = find_domain_by_id(dom);
    1.58 -            int cpu = op->u.pincpudomain.cpu;
    1.59 -            
    1.60 -            ret = -ESRCH;
    1.61 -            
    1.62 -            if ( d != NULL )
    1.63 -            {
    1.64 -                if ( cpu == -1 )
    1.65 -                {
    1.66 -                    clear_bit(DF_CPUPINNED, &d->flags);
    1.67 -                }
    1.68 -                else
    1.69 -                {
    1.70 -                    domain_pause(d);
    1.71 -                    set_bit(DF_CPUPINNED, &d->flags);
    1.72 -                    cpu = cpu % smp_num_cpus;
    1.73 -                    d->processor = cpu;
    1.74 -                    domain_unpause(d);
    1.75 -                }
    1.76 -                put_domain(d);
    1.77 -                ret = 0;
    1.78 -            }      
    1.79 +            domain_pause(d);
    1.80 +            set_bit(DF_CPUPINNED, &d->flags);
    1.81 +            d->processor = cpu % smp_num_cpus;
    1.82 +            domain_unpause(d);
    1.83          }
    1.84 +
    1.85 +        put_domain(d);
    1.86      }
    1.87      break;
    1.88  
    1.89 @@ -293,7 +298,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    1.90          op->u.getdomaininfo.flags =
    1.91              (test_bit(DF_RUNNING, &d->flags) ? DOMFLAGS_RUNNING : 0);
    1.92  
    1.93 -        domain_pause(d);
    1.94 +        if ( d != current )
    1.95 +            domain_pause(d);
    1.96  
    1.97          op->u.getdomaininfo.domain = d->domain;
    1.98          strcpy(op->u.getdomaininfo.name, d->name);
    1.99 @@ -381,7 +387,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   1.100              ret = -EINVAL;
   1.101  
   1.102      gdi_out:
   1.103 -        domain_unpause(d);
   1.104 +        if ( d != current )
   1.105 +            domain_unpause(d);
   1.106          put_domain(d);
   1.107      }
   1.108      break;
     2.1 --- a/xen/common/schedule.c	Sun Jun 20 13:51:29 2004 +0000
     2.2 +++ b/xen/common/schedule.c	Mon Jun 21 06:13:50 2004 +0000
     2.3 @@ -178,16 +178,17 @@ void domain_sleep(struct domain *d)
     2.4      int           cpu = d->processor;
     2.5  
     2.6      spin_lock_irqsave(&schedule_lock[cpu], flags);
     2.7 -
     2.8 -    if ( test_bit(DF_RUNNING, &d->flags) )
     2.9 -        cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ);
    2.10 -    else if ( __task_on_runqueue(d) )
    2.11 -        __del_from_runqueue(d);
    2.12 -
    2.13 +    if ( likely(!domain_runnable(d)) )
    2.14 +    {
    2.15 +        if ( test_bit(DF_RUNNING, &d->flags) )
    2.16 +            cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ);
    2.17 +        else if ( __task_on_runqueue(d) )
    2.18 +            __del_from_runqueue(d);
    2.19 +    }
    2.20      spin_unlock_irqrestore(&schedule_lock[cpu], flags);
    2.21  
    2.22      /* Synchronous. */
    2.23 -    while ( test_bit(DF_RUNNING, &d->flags) )
    2.24 +    while ( test_bit(DF_RUNNING, &d->flags) && !domain_runnable(d) )
    2.25      {
    2.26          smp_mb();
    2.27          cpu_relax();