|
2 | 2 | #define _LINUX_LIST_BL_H |
3 | 3 |
|
4 | 4 | #include <linux/list.h> |
| 5 | +#include <linux/spinlock.h> |
5 | 6 | #include <linux/bit_spinlock.h> |
6 | 7 |
|
7 | 8 | /* |
|
32 | 33 |
|
33 | 34 | struct hlist_bl_head { |
34 | 35 | struct hlist_bl_node *first; |
| 36 | +#ifdef CONFIG_PREEMPT_RT_BASE |
| 37 | + raw_spinlock_t lock; |
| 38 | +#endif |
35 | 39 | }; |
36 | 40 |
|
37 | 41 | struct hlist_bl_node { |
38 | 42 | struct hlist_bl_node *next, **pprev; |
39 | 43 | }; |
40 | | -#define INIT_HLIST_BL_HEAD(ptr) \ |
41 | | - ((ptr)->first = NULL) |
| 44 | + |
| 45 | +static inline void INIT_HLIST_BL_HEAD(struct hlist_bl_head *h) |
| 46 | +{ |
| 47 | + h->first = NULL; |
| 48 | +#ifdef CONFIG_PREEMPT_RT_BASE |
| 49 | + raw_spin_lock_init(&h->lock); |
| 50 | +#endif |
| 51 | +} |
42 | 52 |
|
43 | 53 | static inline void INIT_HLIST_BL_NODE(struct hlist_bl_node *h) |
44 | 54 | { |
@@ -118,12 +128,26 @@ static inline void hlist_bl_del_init(struct hlist_bl_node *n) |
118 | 128 |
|
119 | 129 | static inline void hlist_bl_lock(struct hlist_bl_head *b) |
120 | 130 | { |
| 131 | +#ifndef CONFIG_PREEMPT_RT_BASE |
121 | 132 | bit_spin_lock(0, (unsigned long *)b); |
| 133 | +#else |
| 134 | + raw_spin_lock(&b->lock); |
| 135 | +#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) |
| 136 | + __set_bit(0, (unsigned long *)b); |
| 137 | +#endif |
| 138 | +#endif |
122 | 139 | } |
123 | 140 |
|
124 | 141 | static inline void hlist_bl_unlock(struct hlist_bl_head *b) |
125 | 142 | { |
| 143 | +#ifndef CONFIG_PREEMPT_RT_BASE |
126 | 144 | __bit_spin_unlock(0, (unsigned long *)b); |
| 145 | +#else |
| 146 | +#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) |
| 147 | + __clear_bit(0, (unsigned long *)b); |
| 148 | +#endif |
| 149 | + raw_spin_unlock(&b->lock); |
| 150 | +#endif |
127 | 151 | } |
128 | 152 |
|
129 | 153 | static inline bool hlist_bl_is_locked(struct hlist_bl_head *b) |
|
0 commit comments