direct-io.hg

changeset 12241:cf8e65797826

[XEN] Simplify domain shutdown -- no need to synchronously halt execution.

This avoids a possible deadlock on the per-domain 'big lock'.

No control tools depend on synchronous halting of execution (e.g.,
save/restore already expect that secondary CPUs were halted
synchronously under the control of the guest itself). This makes the
code rather less complex.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@localhost.localdomain
date Sat Nov 04 19:50:59 2006 +0000 (2006-11-04)
parents 5ec45b464563
children e3abede54214
files xen/common/domain.c xen/common/domctl.c xen/include/xen/softirq.h
line diff
     1.1 --- a/xen/common/domain.c	Sat Nov 04 19:26:29 2006 +0000
     1.2 +++ b/xen/common/domain.c	Sat Nov 04 19:50:59 2006 +0000
     1.3 @@ -247,42 +247,6 @@ void __domain_crash_synchronous(void)
     1.4  }
     1.5  
     1.6  
     1.7 -static DEFINE_PER_CPU(struct domain *, domain_shuttingdown);
     1.8 -
     1.9 -static void domain_shutdown_finalise(void)
    1.10 -{
    1.11 -    struct domain *d;
    1.12 -    struct vcpu *v;
    1.13 -
    1.14 -    d = this_cpu(domain_shuttingdown);
    1.15 -    this_cpu(domain_shuttingdown) = NULL;
    1.16 -
    1.17 -    BUG_ON(d == NULL);
    1.18 -    BUG_ON(d == current->domain);
    1.19 -
    1.20 -    LOCK_BIGLOCK(d);
    1.21 -
    1.22 -    /* Make sure that every vcpu is descheduled before we finalise. */
    1.23 -    for_each_vcpu ( d, v )
    1.24 -        vcpu_sleep_sync(v);
    1.25 -    BUG_ON(!cpus_empty(d->domain_dirty_cpumask));
    1.26 -
    1.27 -    /* Don't set DOMF_shutdown until execution contexts are sync'ed. */
    1.28 -    if ( !test_and_set_bit(_DOMF_shutdown, &d->domain_flags) )
    1.29 -        send_guest_global_virq(dom0, VIRQ_DOM_EXC);
    1.30 -
    1.31 -    UNLOCK_BIGLOCK(d);
    1.32 -
    1.33 -    put_domain(d);
    1.34 -}
    1.35 -
    1.36 -static __init int domain_shutdown_finaliser_init(void)
    1.37 -{
    1.38 -    open_softirq(DOMAIN_SHUTDOWN_FINALISE_SOFTIRQ, domain_shutdown_finalise);
    1.39 -    return 0;
    1.40 -}
    1.41 -__initcall(domain_shutdown_finaliser_init);
    1.42 -
    1.43  void domain_shutdown(struct domain *d, u8 reason)
    1.44  {
    1.45      struct vcpu *v;
    1.46 @@ -290,20 +254,13 @@ void domain_shutdown(struct domain *d, u
    1.47      if ( d->domain_id == 0 )
    1.48          dom0_shutdown(reason);
    1.49  
    1.50 -    /* Mark the domain as shutting down. */
    1.51      d->shutdown_code = reason;
    1.52 +    set_bit(_DOMF_shutdown, &d->domain_flags);
    1.53  
    1.54 -    /* Put every vcpu to sleep, but don't wait (avoids inter-vcpu deadlock). */
    1.55 -    spin_lock(&d->pause_lock);
    1.56 -    d->pause_count++;
    1.57 -    set_bit(_DOMF_paused, &d->domain_flags);
    1.58 -    spin_unlock(&d->pause_lock);
    1.59      for_each_vcpu ( d, v )
    1.60          vcpu_sleep_nosync(v);
    1.61  
    1.62 -    get_knownalive_domain(d);
    1.63 -    this_cpu(domain_shuttingdown) = d;
    1.64 -    raise_softirq(DOMAIN_SHUTDOWN_FINALISE_SOFTIRQ);
    1.65 +    send_guest_global_virq(dom0, VIRQ_DOM_EXC);
    1.66  }
    1.67  
    1.68  
    1.69 @@ -312,12 +269,8 @@ void domain_pause_for_debugger(void)
    1.70      struct domain *d = current->domain;
    1.71      struct vcpu *v;
    1.72  
    1.73 -    /*
    1.74 -     * NOTE: This does not synchronously pause the domain. The debugger
    1.75 -     * must issue a PAUSEDOMAIN command to ensure that all execution
    1.76 -     * has ceased and guest state is committed to memory.
    1.77 -     */
    1.78      set_bit(_DOMF_ctrl_pause, &d->domain_flags);
    1.79 +
    1.80      for_each_vcpu ( d, v )
    1.81          vcpu_sleep_nosync(v);
    1.82  
     2.1 --- a/xen/common/domctl.c	Sat Nov 04 19:26:29 2006 +0000
     2.2 +++ b/xen/common/domctl.c	Sat Nov 04 19:50:59 2006 +0000
     2.3 @@ -107,9 +107,9 @@ void getdomaininfo(struct domain *d, str
     2.4              info->nr_online_vcpus++;
     2.5          }
     2.6      }
     2.7 -    
     2.8 +
     2.9      info->cpu_time = cpu_time;
    2.10 -    
    2.11 +
    2.12      info->flags = flags |
    2.13          ((d->domain_flags & DOMF_dying)      ? XEN_DOMINF_dying    : 0) |
    2.14          ((d->domain_flags & DOMF_shutdown)   ? XEN_DOMINF_shutdown : 0) |
     3.1 --- a/xen/include/xen/softirq.h	Sat Nov 04 19:26:29 2006 +0000
     3.2 +++ b/xen/include/xen/softirq.h	Sat Nov 04 19:50:59 2006 +0000
     3.3 @@ -8,9 +8,8 @@
     3.4  #define KEYPRESS_SOFTIRQ                  3
     3.5  #define NMI_SOFTIRQ                       4
     3.6  #define PAGE_SCRUB_SOFTIRQ                5
     3.7 -#define DOMAIN_SHUTDOWN_FINALISE_SOFTIRQ  6
     3.8 -#define TRACE_SOFTIRQ                     7
     3.9 -#define NR_SOFTIRQS                       8
    3.10 +#define TRACE_SOFTIRQ                     6
    3.11 +#define NR_SOFTIRQS                       7
    3.12  
    3.13  #ifndef __ASSEMBLY__
    3.14