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

[Xen-changelog] Fix __save_flags() to not complain when smp_processor_id() is used



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID d3bc8314b6f510208cae15fa42c013e0b12335da
# Parent  659ad553199e39c315748f8ebe044cbaa8451cf7
Fix __save_flags() to not complain when smp_processor_id() is used
in a preemptible region (it is always safe).

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r 659ad553199e -r d3bc8314b6f5 
linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h    Tue Sep 20 
14:18:23 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h    Tue Sep 20 
14:44:49 2005
@@ -497,11 +497,22 @@
  * includes these barriers, for example.
  */
 
+/*
+ * Don't use smp_processor_id() in preemptible code: debug builds will barf.
+ * It's okay in these cases as we only read the upcall mask in preemptible
+ * regions, which is always safe.
+ */
+#ifdef CONFIG_SMP
+#define __this_cpu()   __smp_processor_id()
+#else
+#define __this_cpu()   0
+#endif
+
 #define __cli()                                                                
\
 do {                                                                   \
        vcpu_info_t *_vcpu;                                             \
        preempt_disable();                                              \
-       _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
+       _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()];       \
        _vcpu->evtchn_upcall_mask = 1;                                  \
        preempt_enable_no_resched();                                    \
        barrier();                                                      \
@@ -512,7 +523,7 @@
        vcpu_info_t *_vcpu;                                             \
        barrier();                                                      \
        preempt_disable();                                              \
-       _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
+       _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()];       \
        _vcpu->evtchn_upcall_mask = 0;                                  \
        barrier(); /* unmask then check (avoid races) */                \
        if ( unlikely(_vcpu->evtchn_upcall_pending) )                   \
@@ -523,7 +534,7 @@
 #define __save_flags(x)                                                        
\
 do {                                                                   \
        vcpu_info_t *_vcpu;                                             \
-       _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
+       _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()];       \
        (x) = _vcpu->evtchn_upcall_mask;                                \
 } while (0)
 
@@ -532,7 +543,7 @@
        vcpu_info_t *_vcpu;                                             \
        barrier();                                                      \
        preempt_disable();                                              \
-       _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
+       _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()];       \
        if ((_vcpu->evtchn_upcall_mask = (x)) == 0) {                   \
                barrier(); /* unmask then check (avoid races) */        \
                if ( unlikely(_vcpu->evtchn_upcall_pending) )           \
@@ -548,7 +559,7 @@
 do {                                                                   \
        vcpu_info_t *_vcpu;                                             \
        preempt_disable();                                              \
-       _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
+       _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()];       \
        (x) = _vcpu->evtchn_upcall_mask;                                \
        _vcpu->evtchn_upcall_mask = 1;                                  \
        preempt_enable_no_resched();                                    \
@@ -561,14 +572,8 @@
 #define local_irq_disable()    __cli()
 #define local_irq_enable()     __sti()
 
-/* Don't use smp_processor_id: this is called in debug versions of that fn. */
-#ifdef CONFIG_SMP
-#define irqs_disabled()                        \
-    HYPERVISOR_shared_info->vcpu_data[__smp_processor_id()].evtchn_upcall_mask
-#else
-#define irqs_disabled()                        \
-    HYPERVISOR_shared_info->vcpu_data[0].evtchn_upcall_mask
-#endif
+#define irqs_disabled()                                                        
\
+       HYPERVISOR_shared_info->vcpu_data[__this_cpu()].evtchn_upcall_mask
 
 /*
  * disable hlt during certain critical i/o operations
diff -r 659ad553199e -r d3bc8314b6f5 
linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h  Tue Sep 20 
14:18:23 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h  Tue Sep 20 
14:44:49 2005
@@ -321,11 +321,22 @@
  * includes these barriers, for example.
  */
 
+/*
+ * Don't use smp_processor_id() in preemptible code: debug builds will barf.
+ * It's okay in these cases as we only read the upcall mask in preemptible
+ * regions, which is always safe.
+ */
+#ifdef CONFIG_SMP
+#define __this_cpu()   __smp_processor_id()
+#else
+#define __this_cpu()   0
+#endif
+
 #define __cli()                                                                
\
 do {                                                                   \
        vcpu_info_t *_vcpu;                                             \
        preempt_disable();                                              \
-       _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
+       _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()];       \
        _vcpu->evtchn_upcall_mask = 1;                                  \
        preempt_enable_no_resched();                                    \
        barrier();                                                      \
@@ -336,7 +347,7 @@
        vcpu_info_t *_vcpu;                                             \
        barrier();                                                      \
        preempt_disable();                                              \
-       _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
+       _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()];       \
        _vcpu->evtchn_upcall_mask = 0;                                  \
        barrier(); /* unmask then check (avoid races) */                \
        if ( unlikely(_vcpu->evtchn_upcall_pending) )                   \
@@ -347,7 +358,7 @@
 #define __save_flags(x)                                                        
\
 do {                                                                   \
        vcpu_info_t *_vcpu;                                             \
-       _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
+       _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()];       \
        (x) = _vcpu->evtchn_upcall_mask;                                \
 } while (0)
 
@@ -356,7 +367,7 @@
        vcpu_info_t *_vcpu;                                             \
        barrier();                                                      \
        preempt_disable();                                              \
-       _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
+       _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()];       \
        if ((_vcpu->evtchn_upcall_mask = (x)) == 0) {                   \
                barrier(); /* unmask then check (avoid races) */        \
                if ( unlikely(_vcpu->evtchn_upcall_pending) )           \
@@ -372,7 +383,7 @@
 do {                                                                   \
        vcpu_info_t *_vcpu;                                             \
        preempt_disable();                                              \
-       _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
+       _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()];       \
        (x) = _vcpu->evtchn_upcall_mask;                                \
        _vcpu->evtchn_upcall_mask = 1;                                  \
        preempt_enable_no_resched();                                    \
@@ -387,14 +398,8 @@
 #define local_irq_disable()    __cli()
 #define local_irq_enable()     __sti()
 
-/* Don't use smp_processor_id: this is called in debug versions of that fn. */
-#ifdef CONFIG_SMP
-#define irqs_disabled()                        \
-    HYPERVISOR_shared_info->vcpu_data[__smp_processor_id()].evtchn_upcall_mask
-#else
-#define irqs_disabled()                        \
-    HYPERVISOR_shared_info->vcpu_data[0].evtchn_upcall_mask
-#endif
+#define irqs_disabled()                                                        
\
+       HYPERVISOR_shared_info->vcpu_data[__this_cpu()].evtchn_upcall_mask
 
 /*
  * disable hlt during certain critical i/o operations

_______________________________________________
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®.