~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/spinlock_api_smp.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/linux/spinlock_api_smp.h (Architecture mips) and /include/linux/spinlock_api_smp.h (Architecture ppc)


  1 #ifndef __LINUX_SPINLOCK_API_SMP_H                  1 #ifndef __LINUX_SPINLOCK_API_SMP_H
  2 #define __LINUX_SPINLOCK_API_SMP_H                  2 #define __LINUX_SPINLOCK_API_SMP_H
  3                                                     3 
  4 #ifndef __LINUX_INSIDE_SPINLOCK_H                   4 #ifndef __LINUX_INSIDE_SPINLOCK_H
  5 # error "please don't include this file direct      5 # error "please don't include this file directly"
  6 #endif                                              6 #endif
  7                                                     7 
  8 /*                                                  8 /*
  9  * include/linux/spinlock_api_smp.h                 9  * include/linux/spinlock_api_smp.h
 10  *                                                 10  *
 11  * spinlock API declarations on SMP (and debug     11  * spinlock API declarations on SMP (and debug)
 12  * (implemented in kernel/spinlock.c)              12  * (implemented in kernel/spinlock.c)
 13  *                                                 13  *
 14  * portions Copyright 2005, Red Hat, Inc., Ing     14  * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
 15  * Released under the General Public License (     15  * Released under the General Public License (GPL).
 16  */                                                16  */
 17                                                    17 
 18 int in_lock_functions(unsigned long addr);         18 int in_lock_functions(unsigned long addr);
 19                                                    19 
 20 #define assert_raw_spin_locked(x)       BUG_ON     20 #define assert_raw_spin_locked(x)       BUG_ON(!raw_spin_is_locked(x))
 21                                                    21 
 22 void __lockfunc _raw_spin_lock(raw_spinlock_t      22 void __lockfunc _raw_spin_lock(raw_spinlock_t *lock)            __acquires(lock);
 23 void __lockfunc _raw_spin_lock_nested(raw_spin     23 void __lockfunc _raw_spin_lock_nested(raw_spinlock_t *lock, int subclass)
 24                                                    24                                                                 __acquires(lock);
 25 void __lockfunc                                    25 void __lockfunc
 26 _raw_spin_lock_nest_lock(raw_spinlock_t *lock,     26 _raw_spin_lock_nest_lock(raw_spinlock_t *lock, struct lockdep_map *map)
 27                                                    27                                                                 __acquires(lock);
 28 void __lockfunc _raw_spin_lock_bh(raw_spinlock     28 void __lockfunc _raw_spin_lock_bh(raw_spinlock_t *lock)         __acquires(lock);
 29 void __lockfunc _raw_spin_lock_irq(raw_spinloc     29 void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)
 30                                                    30                                                                 __acquires(lock);
 31                                                    31 
 32 unsigned long __lockfunc _raw_spin_lock_irqsav     32 unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
 33                                                    33                                                                 __acquires(lock);
 34 unsigned long __lockfunc                           34 unsigned long __lockfunc
 35 _raw_spin_lock_irqsave_nested(raw_spinlock_t *     35 _raw_spin_lock_irqsave_nested(raw_spinlock_t *lock, int subclass)
 36                                                    36                                                                 __acquires(lock);
 37 int __lockfunc _raw_spin_trylock(raw_spinlock_     37 int __lockfunc _raw_spin_trylock(raw_spinlock_t *lock);
 38 int __lockfunc _raw_spin_trylock_bh(raw_spinlo     38 int __lockfunc _raw_spin_trylock_bh(raw_spinlock_t *lock);
 39 void __lockfunc _raw_spin_unlock(raw_spinlock_     39 void __lockfunc _raw_spin_unlock(raw_spinlock_t *lock)          __releases(lock);
 40 void __lockfunc _raw_spin_unlock_bh(raw_spinlo     40 void __lockfunc _raw_spin_unlock_bh(raw_spinlock_t *lock)       __releases(lock);
 41 void __lockfunc _raw_spin_unlock_irq(raw_spinl     41 void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)      __releases(lock);
 42 void __lockfunc                                    42 void __lockfunc
 43 _raw_spin_unlock_irqrestore(raw_spinlock_t *lo     43 _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)
 44                                                    44                                                                 __releases(lock);
 45                                                    45 
 46 #ifdef CONFIG_INLINE_SPIN_LOCK                     46 #ifdef CONFIG_INLINE_SPIN_LOCK
 47 #define _raw_spin_lock(lock) __raw_spin_lock(l     47 #define _raw_spin_lock(lock) __raw_spin_lock(lock)
 48 #endif                                             48 #endif
 49                                                    49 
 50 #ifdef CONFIG_INLINE_SPIN_LOCK_BH                  50 #ifdef CONFIG_INLINE_SPIN_LOCK_BH
 51 #define _raw_spin_lock_bh(lock) __raw_spin_loc     51 #define _raw_spin_lock_bh(lock) __raw_spin_lock_bh(lock)
 52 #endif                                             52 #endif
 53                                                    53 
 54 #ifdef CONFIG_INLINE_SPIN_LOCK_IRQ                 54 #ifdef CONFIG_INLINE_SPIN_LOCK_IRQ
 55 #define _raw_spin_lock_irq(lock) __raw_spin_lo     55 #define _raw_spin_lock_irq(lock) __raw_spin_lock_irq(lock)
 56 #endif                                             56 #endif
 57                                                    57 
 58 #ifdef CONFIG_INLINE_SPIN_LOCK_IRQSAVE             58 #ifdef CONFIG_INLINE_SPIN_LOCK_IRQSAVE
 59 #define _raw_spin_lock_irqsave(lock) __raw_spi     59 #define _raw_spin_lock_irqsave(lock) __raw_spin_lock_irqsave(lock)
 60 #endif                                             60 #endif
 61                                                    61 
 62 #ifdef CONFIG_INLINE_SPIN_TRYLOCK                  62 #ifdef CONFIG_INLINE_SPIN_TRYLOCK
 63 #define _raw_spin_trylock(lock) __raw_spin_try     63 #define _raw_spin_trylock(lock) __raw_spin_trylock(lock)
 64 #endif                                             64 #endif
 65                                                    65 
 66 #ifdef CONFIG_INLINE_SPIN_TRYLOCK_BH               66 #ifdef CONFIG_INLINE_SPIN_TRYLOCK_BH
 67 #define _raw_spin_trylock_bh(lock) __raw_spin_     67 #define _raw_spin_trylock_bh(lock) __raw_spin_trylock_bh(lock)
 68 #endif                                             68 #endif
 69                                                    69 
 70 #ifndef CONFIG_UNINLINE_SPIN_UNLOCK                70 #ifndef CONFIG_UNINLINE_SPIN_UNLOCK
 71 #define _raw_spin_unlock(lock) __raw_spin_unlo     71 #define _raw_spin_unlock(lock) __raw_spin_unlock(lock)
 72 #endif                                             72 #endif
 73                                                    73 
 74 #ifdef CONFIG_INLINE_SPIN_UNLOCK_BH                74 #ifdef CONFIG_INLINE_SPIN_UNLOCK_BH
 75 #define _raw_spin_unlock_bh(lock) __raw_spin_u     75 #define _raw_spin_unlock_bh(lock) __raw_spin_unlock_bh(lock)
 76 #endif                                             76 #endif
 77                                                    77 
 78 #ifdef CONFIG_INLINE_SPIN_UNLOCK_IRQ               78 #ifdef CONFIG_INLINE_SPIN_UNLOCK_IRQ
 79 #define _raw_spin_unlock_irq(lock) __raw_spin_     79 #define _raw_spin_unlock_irq(lock) __raw_spin_unlock_irq(lock)
 80 #endif                                             80 #endif
 81                                                    81 
 82 #ifdef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE        82 #ifdef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE
 83 #define _raw_spin_unlock_irqrestore(lock, flag     83 #define _raw_spin_unlock_irqrestore(lock, flags) __raw_spin_unlock_irqrestore(lock, flags)
 84 #endif                                             84 #endif
 85                                                    85 
 86 static inline int __raw_spin_trylock(raw_spinl     86 static inline int __raw_spin_trylock(raw_spinlock_t *lock)
 87 {                                                  87 {
 88         preempt_disable();                         88         preempt_disable();
 89         if (do_raw_spin_trylock(lock)) {           89         if (do_raw_spin_trylock(lock)) {
 90                 spin_acquire(&lock->dep_map, 0     90                 spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
 91                 return 1;                          91                 return 1;
 92         }                                          92         }
 93         preempt_enable();                          93         preempt_enable();
 94         return 0;                                  94         return 0;
 95 }                                                  95 }
 96                                                    96 
 97 /*                                                 97 /*
 98  * If lockdep is enabled then we use the non-p     98  * If lockdep is enabled then we use the non-preemption spin-ops
 99  * even on CONFIG_PREEMPTION, because lockdep      99  * even on CONFIG_PREEMPTION, because lockdep assumes that interrupts are
100  * not re-enabled during lock-acquire (which t    100  * not re-enabled during lock-acquire (which the preempt-spin-ops do):
101  */                                               101  */
102 #if !defined(CONFIG_GENERIC_LOCKBREAK) || defi    102 #if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_DEBUG_LOCK_ALLOC)
103                                                   103 
104 static inline unsigned long __raw_spin_lock_ir    104 static inline unsigned long __raw_spin_lock_irqsave(raw_spinlock_t *lock)
105 {                                                 105 {
106         unsigned long flags;                      106         unsigned long flags;
107                                                   107 
108         local_irq_save(flags);                    108         local_irq_save(flags);
109         preempt_disable();                        109         preempt_disable();
110         spin_acquire(&lock->dep_map, 0, 0, _RE    110         spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
111         LOCK_CONTENDED(lock, do_raw_spin_trylo    111         LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
112         return flags;                             112         return flags;
113 }                                                 113 }
114                                                   114 
115 static inline void __raw_spin_lock_irq(raw_spi    115 static inline void __raw_spin_lock_irq(raw_spinlock_t *lock)
116 {                                                 116 {
117         local_irq_disable();                      117         local_irq_disable();
118         preempt_disable();                        118         preempt_disable();
119         spin_acquire(&lock->dep_map, 0, 0, _RE    119         spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
120         LOCK_CONTENDED(lock, do_raw_spin_trylo    120         LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
121 }                                                 121 }
122                                                   122 
123 static inline void __raw_spin_lock_bh(raw_spin    123 static inline void __raw_spin_lock_bh(raw_spinlock_t *lock)
124 {                                                 124 {
125         __local_bh_disable_ip(_RET_IP_, SOFTIR    125         __local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
126         spin_acquire(&lock->dep_map, 0, 0, _RE    126         spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
127         LOCK_CONTENDED(lock, do_raw_spin_trylo    127         LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
128 }                                                 128 }
129                                                   129 
130 static inline void __raw_spin_lock(raw_spinloc    130 static inline void __raw_spin_lock(raw_spinlock_t *lock)
131 {                                                 131 {
132         preempt_disable();                        132         preempt_disable();
133         spin_acquire(&lock->dep_map, 0, 0, _RE    133         spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
134         LOCK_CONTENDED(lock, do_raw_spin_trylo    134         LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
135 }                                                 135 }
136                                                   136 
137 #endif /* !CONFIG_GENERIC_LOCKBREAK || CONFIG_    137 #endif /* !CONFIG_GENERIC_LOCKBREAK || CONFIG_DEBUG_LOCK_ALLOC */
138                                                   138 
139 static inline void __raw_spin_unlock(raw_spinl    139 static inline void __raw_spin_unlock(raw_spinlock_t *lock)
140 {                                                 140 {
141         spin_release(&lock->dep_map, _RET_IP_)    141         spin_release(&lock->dep_map, _RET_IP_);
142         do_raw_spin_unlock(lock);                 142         do_raw_spin_unlock(lock);
143         preempt_enable();                         143         preempt_enable();
144 }                                                 144 }
145                                                   145 
146 static inline void __raw_spin_unlock_irqrestor    146 static inline void __raw_spin_unlock_irqrestore(raw_spinlock_t *lock,
147                                             un    147                                             unsigned long flags)
148 {                                                 148 {
149         spin_release(&lock->dep_map, _RET_IP_)    149         spin_release(&lock->dep_map, _RET_IP_);
150         do_raw_spin_unlock(lock);                 150         do_raw_spin_unlock(lock);
151         local_irq_restore(flags);                 151         local_irq_restore(flags);
152         preempt_enable();                         152         preempt_enable();
153 }                                                 153 }
154                                                   154 
155 static inline void __raw_spin_unlock_irq(raw_s    155 static inline void __raw_spin_unlock_irq(raw_spinlock_t *lock)
156 {                                                 156 {
157         spin_release(&lock->dep_map, _RET_IP_)    157         spin_release(&lock->dep_map, _RET_IP_);
158         do_raw_spin_unlock(lock);                 158         do_raw_spin_unlock(lock);
159         local_irq_enable();                       159         local_irq_enable();
160         preempt_enable();                         160         preempt_enable();
161 }                                                 161 }
162                                                   162 
163 static inline void __raw_spin_unlock_bh(raw_sp    163 static inline void __raw_spin_unlock_bh(raw_spinlock_t *lock)
164 {                                                 164 {
165         spin_release(&lock->dep_map, _RET_IP_)    165         spin_release(&lock->dep_map, _RET_IP_);
166         do_raw_spin_unlock(lock);                 166         do_raw_spin_unlock(lock);
167         __local_bh_enable_ip(_RET_IP_, SOFTIRQ    167         __local_bh_enable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
168 }                                                 168 }
169                                                   169 
170 static inline int __raw_spin_trylock_bh(raw_sp    170 static inline int __raw_spin_trylock_bh(raw_spinlock_t *lock)
171 {                                                 171 {
172         __local_bh_disable_ip(_RET_IP_, SOFTIR    172         __local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
173         if (do_raw_spin_trylock(lock)) {          173         if (do_raw_spin_trylock(lock)) {
174                 spin_acquire(&lock->dep_map, 0    174                 spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
175                 return 1;                         175                 return 1;
176         }                                         176         }
177         __local_bh_enable_ip(_RET_IP_, SOFTIRQ    177         __local_bh_enable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
178         return 0;                                 178         return 0;
179 }                                                 179 }
180                                                   180 
181 /* PREEMPT_RT has its own rwlock implementatio    181 /* PREEMPT_RT has its own rwlock implementation */
182 #ifndef CONFIG_PREEMPT_RT                         182 #ifndef CONFIG_PREEMPT_RT
183 #include <linux/rwlock_api_smp.h>                 183 #include <linux/rwlock_api_smp.h>
184 #endif                                            184 #endif
185                                                   185 
186 #endif /* __LINUX_SPINLOCK_API_SMP_H */           186 #endif /* __LINUX_SPINLOCK_API_SMP_H */
187                                                   187 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php