hc
2023-12-02 57e32c52610e6a560beda60bf33c48f9f42306d5
kernel/include/linux/list_bl.h
....@@ -3,6 +3,7 @@
33 #define _LINUX_LIST_BL_H
44
55 #include <linux/list.h>
6
+#include <linux/spinlock.h>
67 #include <linux/bit_spinlock.h>
78
89 /*
....@@ -33,13 +34,24 @@
3334
3435 struct hlist_bl_head {
3536 struct hlist_bl_node *first;
37
+#ifdef CONFIG_PREEMPT_RT_BASE
38
+ raw_spinlock_t lock;
39
+#endif
3640 };
3741
3842 struct hlist_bl_node {
3943 struct hlist_bl_node *next, **pprev;
4044 };
41
-#define INIT_HLIST_BL_HEAD(ptr) \
42
- ((ptr)->first = NULL)
45
+
46
+#ifdef CONFIG_PREEMPT_RT_BASE
47
+#define INIT_HLIST_BL_HEAD(h) \
48
+do { \
49
+ (h)->first = NULL; \
50
+ raw_spin_lock_init(&(h)->lock); \
51
+} while (0)
52
+#else
53
+#define INIT_HLIST_BL_HEAD(h) (h)->first = NULL
54
+#endif
4355
4456 static inline void INIT_HLIST_BL_NODE(struct hlist_bl_node *h)
4557 {
....@@ -119,12 +131,26 @@
119131
120132 static inline void hlist_bl_lock(struct hlist_bl_head *b)
121133 {
134
+#ifndef CONFIG_PREEMPT_RT_BASE
122135 bit_spin_lock(0, (unsigned long *)b);
136
+#else
137
+ raw_spin_lock(&b->lock);
138
+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
139
+ __set_bit(0, (unsigned long *)b);
140
+#endif
141
+#endif
123142 }
124143
125144 static inline void hlist_bl_unlock(struct hlist_bl_head *b)
126145 {
146
+#ifndef CONFIG_PREEMPT_RT_BASE
127147 __bit_spin_unlock(0, (unsigned long *)b);
148
+#else
149
+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
150
+ __clear_bit(0, (unsigned long *)b);
151
+#endif
152
+ raw_spin_unlock(&b->lock);
153
+#endif
128154 }
129155
130156 static inline bool hlist_bl_is_locked(struct hlist_bl_head *b)