direct-io.hg

changeset 6462:b88e1417bd14

Only hotplug cpus and save/restore vcpu context on SMP builds.
The for_each_cpu_mask macro has a slightly odd behaviour in the
non-CONFIG_SMP case, making the code unexpectedly incorrect.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Mon Aug 29 17:14:08 2005 +0000 (2005-08-29)
parents 936be0ae823f
children 70be155e9e9c
files linux-2.6-xen-sparse/arch/xen/kernel/reboot.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Mon Aug 29 14:53:38 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Mon Aug 29 17:14:08 2005 +0000
     1.3 @@ -65,6 +65,7 @@ static int shutting_down = SHUTDOWN_INVA
     1.4  #define cpu_up(x) (-EOPNOTSUPP)
     1.5  #endif
     1.6  
     1.7 +#ifdef CONFIG_SMP
     1.8  static void save_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
     1.9  {
    1.10      int r;
    1.11 @@ -119,12 +120,12 @@ static int restore_vcpu_context(int vcpu
    1.12  
    1.13      return 0;
    1.14  }
    1.15 +#endif
    1.16  
    1.17  static int __do_suspend(void *ignore)
    1.18  {
    1.19      int i, j;
    1.20      suspend_record_t *suspend_record;
    1.21 -    static vcpu_guest_context_t suspended_cpu_records[NR_CPUS];
    1.22  
    1.23      /* Hmmm... a cleaner interface to suspend/resume blkdevs would be nice. */
    1.24  	/* XXX SMH: yes it would :-( */	
    1.25 @@ -147,7 +148,11 @@ static int __do_suspend(void *ignore)
    1.26      extern unsigned long max_pfn;
    1.27      extern unsigned int *pfn_to_mfn_frame_list;
    1.28  
    1.29 +#ifdef CONFIG_SMP
    1.30 +    static vcpu_guest_context_t suspended_cpu_records[NR_CPUS];
    1.31      cpumask_t prev_online_cpus, prev_present_cpus;
    1.32 +#endif
    1.33 +
    1.34      int err = 0;
    1.35  
    1.36      BUG_ON(smp_processor_id() != 0);
    1.37 @@ -164,6 +169,8 @@ static int __do_suspend(void *ignore)
    1.38      if ( suspend_record == NULL )
    1.39          goto out;
    1.40  
    1.41 +    preempt_disable();
    1.42 +#ifdef CONFIG_SMP
    1.43      /* Take all of the other cpus offline.  We need to be careful not
    1.44         to get preempted between the final test for num_online_cpus()
    1.45         == 1 and disabling interrupts, since otherwise userspace could
    1.46 @@ -175,7 +182,6 @@ static int __do_suspend(void *ignore)
    1.47         since by the time num_online_cpus() == 1, there aren't any
    1.48         other cpus) */
    1.49      cpus_clear(prev_online_cpus);
    1.50 -    preempt_disable();
    1.51      while (num_online_cpus() > 1) {
    1.52  	preempt_enable();
    1.53  	for_each_online_cpu(i) {
    1.54 @@ -190,6 +196,7 @@ static int __do_suspend(void *ignore)
    1.55  	}
    1.56  	preempt_disable();
    1.57      }
    1.58 +#endif
    1.59  
    1.60      suspend_record->nr_pfns = max_pfn; /* final number of pfns */
    1.61  
    1.62 @@ -197,6 +204,7 @@ static int __do_suspend(void *ignore)
    1.63  
    1.64      preempt_enable();
    1.65  
    1.66 +#ifdef CONFIG_SMP
    1.67      cpus_clear(prev_present_cpus);
    1.68      for_each_present_cpu(i) {
    1.69  	if (i == 0)
    1.70 @@ -204,6 +212,7 @@ static int __do_suspend(void *ignore)
    1.71  	save_vcpu_context(i, &suspended_cpu_records[i]);
    1.72  	cpu_set(i, prev_present_cpus);
    1.73      }
    1.74 +#endif
    1.75  
    1.76  #ifdef __i386__
    1.77      mm_pin_all();
    1.78 @@ -269,12 +278,14 @@ static int __do_suspend(void *ignore)
    1.79  
    1.80      usbif_resume();
    1.81  
    1.82 -    for_each_cpu_mask(i, prev_present_cpus) {
    1.83 +#ifdef CONFIG_SMP
    1.84 +    for_each_cpu_mask(i, prev_present_cpus)
    1.85  	restore_vcpu_context(i, &suspended_cpu_records[i]);
    1.86 -    }
    1.87 +#endif
    1.88  
    1.89      __sti();
    1.90  
    1.91 +#ifdef CONFIG_SMP
    1.92   out_reenable_cpus:
    1.93      for_each_cpu_mask(i, prev_online_cpus) {
    1.94  	j = cpu_up(i);
    1.95 @@ -284,6 +295,7 @@ static int __do_suspend(void *ignore)
    1.96  	    err = j;
    1.97  	}
    1.98      }
    1.99 +#endif
   1.100  
   1.101   out:
   1.102      if ( suspend_record != NULL )