1 #ifndef __LINUX_SPINLOCK_API_SMP_H
2 #define __LINUX_SPINLOCK_API_SMP_H
4 #ifndef __LINUX_SPINLOCK_H
5 # error "please don't include this file directly"
9 * include/linux/spinlock_api_smp.h
11 * spinlock API declarations on SMP (and debug)
12 * (implemented in kernel/spinlock.c)
14 * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
15 * Released under the General Public License (GPL).
18 int in_lock_functions(unsigned long addr
);
20 #define assert_raw_spin_locked(x) BUG_ON(!raw_spin_is_locked(x))
22 void __lockfunc
_raw_spin_lock(raw_spinlock_t
*lock
) __acquires(lock
);
23 void __lockfunc
_raw_spin_lock_nested(raw_spinlock_t
*lock
, int subclass
)
25 void __lockfunc
_raw_spin_lock_bh_nested(raw_spinlock_t
*lock
, int subclass
)
28 _raw_spin_lock_nest_lock(raw_spinlock_t
*lock
, struct lockdep_map
*map
)
30 void __lockfunc
_raw_spin_lock_bh(raw_spinlock_t
*lock
) __acquires(lock
);
31 void __lockfunc
_raw_spin_lock_irq(raw_spinlock_t
*lock
)
34 unsigned long __lockfunc
_raw_spin_lock_irqsave(raw_spinlock_t
*lock
)
36 unsigned long __lockfunc
37 _raw_spin_lock_irqsave_nested(raw_spinlock_t
*lock
, int subclass
)
39 int __lockfunc
_raw_spin_trylock(raw_spinlock_t
*lock
);
40 int __lockfunc
_raw_spin_trylock_bh(raw_spinlock_t
*lock
);
41 void __lockfunc
_raw_spin_unlock(raw_spinlock_t
*lock
) __releases(lock
);
42 void __lockfunc
_raw_spin_unlock_bh(raw_spinlock_t
*lock
) __releases(lock
);
43 void __lockfunc
_raw_spin_unlock_irq(raw_spinlock_t
*lock
) __releases(lock
);
45 _raw_spin_unlock_irqrestore(raw_spinlock_t
*lock
, unsigned long flags
)
48 #ifdef CONFIG_INLINE_SPIN_LOCK
49 #define _raw_spin_lock(lock) __raw_spin_lock(lock)
52 #ifdef CONFIG_INLINE_SPIN_LOCK_BH
53 #define _raw_spin_lock_bh(lock) __raw_spin_lock_bh(lock)
56 #ifdef CONFIG_INLINE_SPIN_LOCK_IRQ
57 #define _raw_spin_lock_irq(lock) __raw_spin_lock_irq(lock)
60 #ifdef CONFIG_INLINE_SPIN_LOCK_IRQSAVE
61 #define _raw_spin_lock_irqsave(lock) __raw_spin_lock_irqsave(lock)
64 #ifdef CONFIG_INLINE_SPIN_TRYLOCK
65 #define _raw_spin_trylock(lock) __raw_spin_trylock(lock)
68 #ifdef CONFIG_INLINE_SPIN_TRYLOCK_BH
69 #define _raw_spin_trylock_bh(lock) __raw_spin_trylock_bh(lock)
72 #ifndef CONFIG_UNINLINE_SPIN_UNLOCK
73 #define _raw_spin_unlock(lock) __raw_spin_unlock(lock)
76 #ifdef CONFIG_INLINE_SPIN_UNLOCK_BH
77 #define _raw_spin_unlock_bh(lock) __raw_spin_unlock_bh(lock)
80 #ifdef CONFIG_INLINE_SPIN_UNLOCK_IRQ
81 #define _raw_spin_unlock_irq(lock) __raw_spin_unlock_irq(lock)
84 #ifdef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE
85 #define _raw_spin_unlock_irqrestore(lock, flags) __raw_spin_unlock_irqrestore(lock, flags)
88 static inline int __raw_spin_trylock(raw_spinlock_t
*lock
)
91 if (do_raw_spin_trylock(lock
)) {
92 spin_acquire(&lock
->dep_map
, 0, 1, _RET_IP_
);
100 * If lockdep is enabled then we use the non-preemption spin-ops
101 * even on CONFIG_PREEMPT, because lockdep assumes that interrupts are
102 * not re-enabled during lock-acquire (which the preempt-spin-ops do):
104 #if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_DEBUG_LOCK_ALLOC)
106 static inline unsigned long __raw_spin_lock_irqsave(raw_spinlock_t
*lock
)
110 local_irq_save(flags
);
112 spin_acquire(&lock
->dep_map
, 0, 0, _RET_IP_
);
114 * On lockdep we dont want the hand-coded irq-enable of
115 * do_raw_spin_lock_flags() code, because lockdep assumes
116 * that interrupts are not re-enabled during lock-acquire:
118 #ifdef CONFIG_LOCKDEP
119 LOCK_CONTENDED(lock
, do_raw_spin_trylock
, do_raw_spin_lock
);
121 do_raw_spin_lock_flags(lock
, &flags
);
126 static inline void __raw_spin_lock_irq(raw_spinlock_t
*lock
)
130 spin_acquire(&lock
->dep_map
, 0, 0, _RET_IP_
);
131 LOCK_CONTENDED(lock
, do_raw_spin_trylock
, do_raw_spin_lock
);
134 static inline void __raw_spin_lock_bh(raw_spinlock_t
*lock
)
136 __local_bh_disable_ip(_RET_IP_
, SOFTIRQ_LOCK_OFFSET
);
137 spin_acquire(&lock
->dep_map
, 0, 0, _RET_IP_
);
138 LOCK_CONTENDED(lock
, do_raw_spin_trylock
, do_raw_spin_lock
);
141 static inline void __raw_spin_lock(raw_spinlock_t
*lock
)
144 spin_acquire(&lock
->dep_map
, 0, 0, _RET_IP_
);
145 LOCK_CONTENDED(lock
, do_raw_spin_trylock
, do_raw_spin_lock
);
148 #endif /* !CONFIG_GENERIC_LOCKBREAK || CONFIG_DEBUG_LOCK_ALLOC */
150 static inline void __raw_spin_unlock(raw_spinlock_t
*lock
)
152 spin_release(&lock
->dep_map
, 1, _RET_IP_
);
153 do_raw_spin_unlock(lock
);
157 static inline void __raw_spin_unlock_irqrestore(raw_spinlock_t
*lock
,
160 spin_release(&lock
->dep_map
, 1, _RET_IP_
);
161 do_raw_spin_unlock(lock
);
162 local_irq_restore(flags
);
166 static inline void __raw_spin_unlock_irq(raw_spinlock_t
*lock
)
168 spin_release(&lock
->dep_map
, 1, _RET_IP_
);
169 do_raw_spin_unlock(lock
);
174 static inline void __raw_spin_unlock_bh(raw_spinlock_t
*lock
)
176 spin_release(&lock
->dep_map
, 1, _RET_IP_
);
177 do_raw_spin_unlock(lock
);
178 __local_bh_enable_ip(_RET_IP_
, SOFTIRQ_LOCK_OFFSET
);
181 static inline int __raw_spin_trylock_bh(raw_spinlock_t
*lock
)
183 __local_bh_disable_ip(_RET_IP_
, SOFTIRQ_LOCK_OFFSET
);
184 if (do_raw_spin_trylock(lock
)) {
185 spin_acquire(&lock
->dep_map
, 0, 1, _RET_IP_
);
188 __local_bh_enable_ip(_RET_IP_
, SOFTIRQ_LOCK_OFFSET
);
192 #include <linux/rwlock_api_smp.h>
194 #endif /* __LINUX_SPINLOCK_API_SMP_H */
This page took 0.035367 seconds and 6 git commands to generate.