ia64/xen-unstable
changeset 6984:d3bc8314b6f5
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@xensource.com>
in a preemptible region (it is always safe).
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Tue Sep 20 14:44:49 2005 +0000 (2005-09-20) |
parents | 659ad553199e |
children | 1bea937e53cc 95e589a9b2f6 |
files | linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h |
line diff
1.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h Tue Sep 20 14:18:23 2005 +0000 1.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h Tue Sep 20 14:44:49 2005 +0000 1.3 @@ -497,11 +497,22 @@ unsigned long __set_mb_temp; 1.4 * includes these barriers, for example. 1.5 */ 1.6 1.7 +/* 1.8 + * Don't use smp_processor_id() in preemptible code: debug builds will barf. 1.9 + * It's okay in these cases as we only read the upcall mask in preemptible 1.10 + * regions, which is always safe. 1.11 + */ 1.12 +#ifdef CONFIG_SMP 1.13 +#define __this_cpu() __smp_processor_id() 1.14 +#else 1.15 +#define __this_cpu() 0 1.16 +#endif 1.17 + 1.18 #define __cli() \ 1.19 do { \ 1.20 vcpu_info_t *_vcpu; \ 1.21 preempt_disable(); \ 1.22 - _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \ 1.23 + _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \ 1.24 _vcpu->evtchn_upcall_mask = 1; \ 1.25 preempt_enable_no_resched(); \ 1.26 barrier(); \ 1.27 @@ -512,7 +523,7 @@ do { \ 1.28 vcpu_info_t *_vcpu; \ 1.29 barrier(); \ 1.30 preempt_disable(); \ 1.31 - _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \ 1.32 + _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \ 1.33 _vcpu->evtchn_upcall_mask = 0; \ 1.34 barrier(); /* unmask then check (avoid races) */ \ 1.35 if ( unlikely(_vcpu->evtchn_upcall_pending) ) \ 1.36 @@ -523,7 +534,7 @@ do { \ 1.37 #define __save_flags(x) \ 1.38 do { \ 1.39 vcpu_info_t *_vcpu; \ 1.40 - _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \ 1.41 + _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \ 1.42 (x) = _vcpu->evtchn_upcall_mask; \ 1.43 } while (0) 1.44 1.45 @@ -532,7 +543,7 @@ do { \ 1.46 vcpu_info_t *_vcpu; \ 1.47 barrier(); \ 1.48 preempt_disable(); \ 1.49 - _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \ 1.50 + _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \ 1.51 if ((_vcpu->evtchn_upcall_mask = (x)) == 0) { \ 1.52 barrier(); /* unmask then check (avoid races) */ \ 1.53 if ( unlikely(_vcpu->evtchn_upcall_pending) ) \ 1.54 @@ -548,7 +559,7 @@ do { \ 1.55 do { \ 1.56 vcpu_info_t *_vcpu; \ 1.57 preempt_disable(); \ 1.58 - _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \ 1.59 + _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \ 1.60 (x) = _vcpu->evtchn_upcall_mask; \ 1.61 _vcpu->evtchn_upcall_mask = 1; \ 1.62 preempt_enable_no_resched(); \ 1.63 @@ -561,14 +572,8 @@ do { \ 1.64 #define local_irq_disable() __cli() 1.65 #define local_irq_enable() __sti() 1.66 1.67 -/* Don't use smp_processor_id: this is called in debug versions of that fn. */ 1.68 -#ifdef CONFIG_SMP 1.69 -#define irqs_disabled() \ 1.70 - HYPERVISOR_shared_info->vcpu_data[__smp_processor_id()].evtchn_upcall_mask 1.71 -#else 1.72 -#define irqs_disabled() \ 1.73 - HYPERVISOR_shared_info->vcpu_data[0].evtchn_upcall_mask 1.74 -#endif 1.75 +#define irqs_disabled() \ 1.76 + HYPERVISOR_shared_info->vcpu_data[__this_cpu()].evtchn_upcall_mask 1.77 1.78 /* 1.79 * disable hlt during certain critical i/o operations
2.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h Tue Sep 20 14:18:23 2005 +0000 2.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h Tue Sep 20 14:44:49 2005 +0000 2.3 @@ -321,11 +321,22 @@ static inline unsigned long __cmpxchg(vo 2.4 * includes these barriers, for example. 2.5 */ 2.6 2.7 +/* 2.8 + * Don't use smp_processor_id() in preemptible code: debug builds will barf. 2.9 + * It's okay in these cases as we only read the upcall mask in preemptible 2.10 + * regions, which is always safe. 2.11 + */ 2.12 +#ifdef CONFIG_SMP 2.13 +#define __this_cpu() __smp_processor_id() 2.14 +#else 2.15 +#define __this_cpu() 0 2.16 +#endif 2.17 + 2.18 #define __cli() \ 2.19 do { \ 2.20 vcpu_info_t *_vcpu; \ 2.21 preempt_disable(); \ 2.22 - _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \ 2.23 + _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \ 2.24 _vcpu->evtchn_upcall_mask = 1; \ 2.25 preempt_enable_no_resched(); \ 2.26 barrier(); \ 2.27 @@ -336,7 +347,7 @@ do { \ 2.28 vcpu_info_t *_vcpu; \ 2.29 barrier(); \ 2.30 preempt_disable(); \ 2.31 - _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \ 2.32 + _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \ 2.33 _vcpu->evtchn_upcall_mask = 0; \ 2.34 barrier(); /* unmask then check (avoid races) */ \ 2.35 if ( unlikely(_vcpu->evtchn_upcall_pending) ) \ 2.36 @@ -347,7 +358,7 @@ do { \ 2.37 #define __save_flags(x) \ 2.38 do { \ 2.39 vcpu_info_t *_vcpu; \ 2.40 - _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \ 2.41 + _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \ 2.42 (x) = _vcpu->evtchn_upcall_mask; \ 2.43 } while (0) 2.44 2.45 @@ -356,7 +367,7 @@ do { \ 2.46 vcpu_info_t *_vcpu; \ 2.47 barrier(); \ 2.48 preempt_disable(); \ 2.49 - _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \ 2.50 + _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \ 2.51 if ((_vcpu->evtchn_upcall_mask = (x)) == 0) { \ 2.52 barrier(); /* unmask then check (avoid races) */ \ 2.53 if ( unlikely(_vcpu->evtchn_upcall_pending) ) \ 2.54 @@ -372,7 +383,7 @@ do { \ 2.55 do { \ 2.56 vcpu_info_t *_vcpu; \ 2.57 preempt_disable(); \ 2.58 - _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \ 2.59 + _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \ 2.60 (x) = _vcpu->evtchn_upcall_mask; \ 2.61 _vcpu->evtchn_upcall_mask = 1; \ 2.62 preempt_enable_no_resched(); \ 2.63 @@ -387,14 +398,8 @@ void cpu_idle_wait(void); 2.64 #define local_irq_disable() __cli() 2.65 #define local_irq_enable() __sti() 2.66 2.67 -/* Don't use smp_processor_id: this is called in debug versions of that fn. */ 2.68 -#ifdef CONFIG_SMP 2.69 -#define irqs_disabled() \ 2.70 - HYPERVISOR_shared_info->vcpu_data[__smp_processor_id()].evtchn_upcall_mask 2.71 -#else 2.72 -#define irqs_disabled() \ 2.73 - HYPERVISOR_shared_info->vcpu_data[0].evtchn_upcall_mask 2.74 -#endif 2.75 +#define irqs_disabled() \ 2.76 + HYPERVISOR_shared_info->vcpu_data[__this_cpu()].evtchn_upcall_mask 2.77 2.78 /* 2.79 * disable hlt during certain critical i/o operations