ia64/xen-unstable

changeset 2728:855925dd3bae

bitkeeper revision 1.1159.1.270 (417cd5efuYLEDeFTqZTJOYsZwD2mag)

Get rid of critical-region checking. It gets in the way and has found
precisely zero real bugs!
author kaf24@freefall.cl.cam.ac.uk
date Mon Oct 25 10:31:11 2004 +0000 (2004-10-25)
parents 65295b0e2e99
children 62cd5cf03a25
files xen/arch/x86/nmi.c xen/arch/x86/traps.c xen/common/kernel.c xen/include/asm-x86/shadow.h xen/include/asm-x86/x86_32/uaccess.h xen/include/xen/spinlock.h
line diff
     1.1 --- a/xen/arch/x86/nmi.c	Sun Oct 24 18:57:11 2004 +0000
     1.2 +++ b/xen/arch/x86/nmi.c	Mon Oct 25 10:31:11 2004 +0000
     1.3 @@ -288,7 +288,6 @@ void nmi_watchdog_tick (struct pt_regs *
     1.4          if ( alert_counter[cpu] == 5*nmi_hz )
     1.5          {
     1.6              console_force_unlock();
     1.7 -            disable_criticalregion_checking();
     1.8              die("NMI Watchdog detected LOCKUP on CPU", regs, cpu);
     1.9          }
    1.10      } 
     2.1 --- a/xen/arch/x86/traps.c	Sun Oct 24 18:57:11 2004 +0000
     2.2 +++ b/xen/arch/x86/traps.c	Mon Oct 25 10:31:11 2004 +0000
     2.3 @@ -342,9 +342,6 @@ asmlinkage void do_page_fault(struct pt_
     2.4  
     2.5      perfc_incrc(page_faults);
     2.6  
     2.7 -    ASSERT_no_criticalregion();
     2.8 -
     2.9 -
    2.10      if ( likely(VM_ASSIST(d, VMASST_TYPE_writable_pagetables)) )
    2.11      {
    2.12          if ( unlikely(ptwr_info[cpu].ptinfo[PTWR_PT_ACTIVE].l1va) &&
    2.13 @@ -445,8 +442,6 @@ asmlinkage void do_general_protection(st
    2.14      trap_info_t *ti;
    2.15      unsigned long fixup;
    2.16  
    2.17 -    ASSERT_no_criticalregion();
    2.18 -
    2.19      /* Badness if error in ring 0, or result of an interrupt. */
    2.20      if ( !(regs->xcs & 3) || (error_code & 1) )
    2.21          goto gp_in_kernel;
    2.22 @@ -527,7 +522,6 @@ asmlinkage void do_general_protection(st
    2.23  asmlinkage void mem_parity_error(struct pt_regs *regs)
    2.24  {
    2.25      console_force_unlock();
    2.26 -    disable_criticalregion_checking();
    2.27  
    2.28      printk("\n\n");
    2.29  
    2.30 @@ -548,7 +542,6 @@ asmlinkage void mem_parity_error(struct 
    2.31  asmlinkage void io_check_error(struct pt_regs *regs)
    2.32  {
    2.33      console_force_unlock();
    2.34 -    disable_criticalregion_checking();
    2.35  
    2.36      printk("\n\n");
    2.37  
     3.1 --- a/xen/common/kernel.c	Sun Oct 24 18:57:11 2004 +0000
     3.2 +++ b/xen/common/kernel.c	Mon Oct 25 10:31:11 2004 +0000
     3.3 @@ -372,48 +372,3 @@ long do_ni_hypercall(void)
     3.4      /* No-op hypercall. */
     3.5      return -ENOSYS;
     3.6  }
     3.7 -
     3.8 -/*
     3.9 - * Lock debugging
    3.10 - */
    3.11 -
    3.12 -#ifndef NDEBUG
    3.13 -
    3.14 -static int crit_count[NR_CPUS], crit_checking_disabled[NR_CPUS];
    3.15 -
    3.16 -void disable_criticalregion_checking(void)
    3.17 -{
    3.18 -    int cpu = smp_processor_id();
    3.19 -    crit_checking_disabled[cpu]++;
    3.20 -}
    3.21 -
    3.22 -void criticalregion_enter(void)
    3.23 -{
    3.24 -    int cpu = smp_processor_id();
    3.25 -    if ( crit_checking_disabled[cpu] )
    3.26 -        return;
    3.27 -    ASSERT(crit_count[cpu] >= 0);
    3.28 -    crit_count[cpu]++;
    3.29 -}
    3.30 -
    3.31 -void criticalregion_exit(void)
    3.32 -{
    3.33 -    int cpu = smp_processor_id();
    3.34 -    if ( crit_checking_disabled[cpu] )
    3.35 -        return;
    3.36 -    crit_count[cpu]--;
    3.37 -    ASSERT(crit_count[cpu] >= 0);
    3.38 -}
    3.39 -
    3.40 -void ASSERT_no_criticalregion(void)
    3.41 -{
    3.42 -    int cpu = smp_processor_id();
    3.43 -    if ( (crit_count[cpu] == 0) || crit_checking_disabled[cpu] )
    3.44 -        return;
    3.45 -    disable_criticalregion_checking();
    3.46 -    ASSERT(crit_count[cpu] >= 0); /* -ve count is a special kind of bogus! */
    3.47 -    ASSERT(crit_count[cpu] == 0); /* we should definitely take this path   */
    3.48 -    ASSERT(1); /* NEVER GET HERE! */
    3.49 -}
    3.50 -
    3.51 -#endif /* !NDEBUG */
     4.1 --- a/xen/include/asm-x86/shadow.h	Sun Oct 24 18:57:11 2004 +0000
     4.2 +++ b/xen/include/asm-x86/shadow.h	Mon Oct 25 10:31:11 2004 +0000
     4.3 @@ -24,8 +24,8 @@
     4.4  
     4.5  #define shadow_mode(_d)      ((_d)->mm.shadow_mode)
     4.6  #define shadow_lock_init(_d) spin_lock_init(&(_d)->mm.shadow_lock)
     4.7 -#define shadow_lock(_m)      spin_lock_nochecking(&(_m)->shadow_lock)
     4.8 -#define shadow_unlock(_m)    spin_unlock_nochecking(&(_m)->shadow_lock)
     4.9 +#define shadow_lock(_m)      spin_lock(&(_m)->shadow_lock)
    4.10 +#define shadow_unlock(_m)    spin_unlock(&(_m)->shadow_lock)
    4.11  
    4.12  extern void shadow_mode_init(void);
    4.13  extern int shadow_mode_control(struct domain *p, dom0_shadow_control_t *sc);
     5.1 --- a/xen/include/asm-x86/x86_32/uaccess.h	Sun Oct 24 18:57:11 2004 +0000
     5.2 +++ b/xen/include/asm-x86/x86_32/uaccess.h	Mon Oct 25 10:31:11 2004 +0000
     5.3 @@ -243,7 +243,6 @@ struct __large_struct { unsigned long bu
     5.4   * aliasing issues.
     5.5   */
     5.6  #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret)	\
     5.7 -	ASSERT_no_criticalregion();					\
     5.8  	__asm__ __volatile__(						\
     5.9  		"1:	mov"itype" %"rtype"1,%2\n"			\
    5.10  		"2:\n"							\
    5.11 @@ -292,7 +291,6 @@ do {									\
    5.12  } while (0)
    5.13  
    5.14  #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret)	\
    5.15 -	ASSERT_no_criticalregion();					\
    5.16  	__asm__ __volatile__(						\
    5.17  		"1:	mov"itype" %2,%"rtype"1\n"			\
    5.18  		"2:\n"							\
    5.19 @@ -336,7 +334,6 @@ unsigned long __copy_from_user_ll(void *
    5.20  static always_inline unsigned long
    5.21  __copy_to_user(void __user *to, const void *from, unsigned long n)
    5.22  {
    5.23 -	ASSERT_no_criticalregion();
    5.24  	if (__builtin_constant_p(n)) {
    5.25  		unsigned long ret;
    5.26  
    5.27 @@ -375,7 +372,6 @@ static always_inline unsigned long
    5.28  static always_inline unsigned long
    5.29  __copy_from_user(void *to, const void __user *from, unsigned long n)
    5.30  {
    5.31 -	ASSERT_no_criticalregion();
    5.32  	if (__builtin_constant_p(n)) {
    5.33  		unsigned long ret;
    5.34  
     6.1 --- a/xen/include/xen/spinlock.h	Sun Oct 24 18:57:11 2004 +0000
     6.2 +++ b/xen/include/xen/spinlock.h	Mon Oct 25 10:31:11 2004 +0000
     6.3 @@ -72,46 +72,6 @@ typedef struct { int gcc_is_buggy; } rwl
     6.4  
     6.5  #endif
     6.6  
     6.7 -#ifndef NDEBUG
     6.8 -
     6.9 -extern void criticalregion_enter(void);
    6.10 -extern void criticalregion_exit(void);
    6.11 -extern void ASSERT_no_criticalregion(void);
    6.12 -extern void disable_criticalregion_checking(void);
    6.13 -
    6.14 -#define spin_lock(_lock) \
    6.15 -    do { criticalregion_enter(); _raw_spin_lock(_lock); } while (0)
    6.16 -#define spin_unlock(_lock) \
    6.17 -    do { _raw_spin_unlock(_lock); criticalregion_exit(); } while (0)
    6.18 -#define spin_lock_recursive(_lock) \
    6.19 -    do { criticalregion_enter(); _raw_spin_lock_recursive(_lock); } while (0)
    6.20 -#define spin_unlock_recursive(_lock) \
    6.21 -    do { _raw_spin_unlock_recursive(_lock); criticalregion_exit(); } while (0)
    6.22 -#define read_lock(_lock) \
    6.23 -    do { criticalregion_enter(); _raw_read_lock(_lock); } while (0)
    6.24 -#define read_unlock(_lock) \
    6.25 -    do { _raw_read_unlock(_lock); criticalregion_exit(); } while (0)
    6.26 -#define write_lock(_lock) \
    6.27 -    do { criticalregion_enter(); _raw_write_lock(_lock); } while (0)
    6.28 -#define write_unlock(_lock) \
    6.29 -    do { _raw_write_unlock(_lock); criticalregion_exit(); } while (0)
    6.30 -
    6.31 -static inline int spin_trylock(spinlock_t *lock)
    6.32 -{
    6.33 -    criticalregion_enter();
    6.34 -    if ( !_raw_spin_trylock(lock) )
    6.35 -    {
    6.36 -        criticalregion_exit();
    6.37 -        return 0;
    6.38 -    }
    6.39 -    return 1;
    6.40 -}
    6.41 -
    6.42 -#else
    6.43 -
    6.44 -#define ASSERT_no_criticalregion()        ((void)0)
    6.45 -#define disable_criticalregion_checking() ((void)0)
    6.46 -
    6.47  #define spin_lock(_lock)             _raw_spin_lock(_lock)
    6.48  #define spin_trylock(_lock)          _raw_spin_trylock(_lock)
    6.49  #define spin_unlock(_lock)           _raw_spin_unlock(_lock)
    6.50 @@ -122,15 +82,4 @@ static inline int spin_trylock(spinlock_
    6.51  #define write_lock(_lock)            _raw_write_lock(_lock)
    6.52  #define write_unlock(_lock)          _raw_write_unlock(_lock)
    6.53  
    6.54 -#endif
    6.55 -
    6.56 -/*
    6.57 - * Use these if you have taken special care to ensure that certain unsafe
    6.58 - * things can occur in your critical region (e.g., faults, user-space
    6.59 - * accesses). 
    6.60 - */
    6.61 -#define spin_lock_nochecking(_lock)    _raw_spin_lock(_lock)
    6.62 -#define spin_trylock_nochecking(_lock) _raw_spin_trylock(_lock)
    6.63 -#define spin_unlock_nochecking(_lock)  _raw_spin_unlock(_lock)
    6.64 -
    6.65  #endif /* __SPINLOCK_H__ */