[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Only hotplug cpus and save/restore vcpu context on SMP builds.



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID b88e1417bd14b6625f55645f81ea01ef7727deea
# Parent  936be0ae823fd3a94ea06d92fdacad65b85d6014
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@xxxxxxxxxxxx>

diff -r 936be0ae823f -r b88e1417bd14 
linux-2.6-xen-sparse/arch/xen/kernel/reboot.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c     Mon Aug 29 14:53:38 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c     Mon Aug 29 17:14:08 2005
@@ -65,6 +65,7 @@
 #define cpu_up(x) (-EOPNOTSUPP)
 #endif
 
+#ifdef CONFIG_SMP
 static void save_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
 {
     int r;
@@ -119,12 +120,12 @@
 
     return 0;
 }
+#endif
 
 static int __do_suspend(void *ignore)
 {
     int i, j;
     suspend_record_t *suspend_record;
-    static vcpu_guest_context_t suspended_cpu_records[NR_CPUS];
 
     /* Hmmm... a cleaner interface to suspend/resume blkdevs would be nice. */
        /* XXX SMH: yes it would :-( */ 
@@ -147,7 +148,11 @@
     extern unsigned long max_pfn;
     extern unsigned int *pfn_to_mfn_frame_list;
 
+#ifdef CONFIG_SMP
+    static vcpu_guest_context_t suspended_cpu_records[NR_CPUS];
     cpumask_t prev_online_cpus, prev_present_cpus;
+#endif
+
     int err = 0;
 
     BUG_ON(smp_processor_id() != 0);
@@ -164,6 +169,8 @@
     if ( suspend_record == NULL )
         goto out;
 
+    preempt_disable();
+#ifdef CONFIG_SMP
     /* Take all of the other cpus offline.  We need to be careful not
        to get preempted between the final test for num_online_cpus()
        == 1 and disabling interrupts, since otherwise userspace could
@@ -175,7 +182,6 @@
        since by the time num_online_cpus() == 1, there aren't any
        other cpus) */
     cpus_clear(prev_online_cpus);
-    preempt_disable();
     while (num_online_cpus() > 1) {
        preempt_enable();
        for_each_online_cpu(i) {
@@ -190,6 +196,7 @@
        }
        preempt_disable();
     }
+#endif
 
     suspend_record->nr_pfns = max_pfn; /* final number of pfns */
 
@@ -197,6 +204,7 @@
 
     preempt_enable();
 
+#ifdef CONFIG_SMP
     cpus_clear(prev_present_cpus);
     for_each_present_cpu(i) {
        if (i == 0)
@@ -204,6 +212,7 @@
        save_vcpu_context(i, &suspended_cpu_records[i]);
        cpu_set(i, prev_present_cpus);
     }
+#endif
 
 #ifdef __i386__
     mm_pin_all();
@@ -269,12 +278,14 @@
 
     usbif_resume();
 
-    for_each_cpu_mask(i, prev_present_cpus) {
+#ifdef CONFIG_SMP
+    for_each_cpu_mask(i, prev_present_cpus)
        restore_vcpu_context(i, &suspended_cpu_records[i]);
-    }
+#endif
 
     __sti();
 
+#ifdef CONFIG_SMP
  out_reenable_cpus:
     for_each_cpu_mask(i, prev_online_cpus) {
        j = cpu_up(i);
@@ -284,6 +295,7 @@
            err = j;
        }
     }
+#endif
 
  out:
     if ( suspend_record != NULL )

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.