Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rculist_bl.h
Go to the documentation of this file.
1 #ifndef _LINUX_RCULIST_BL_H
2 #define _LINUX_RCULIST_BL_H
3 
4 /*
5  * RCU-protected bl list version. See include/linux/list_bl.h.
6  */
7 #include <linux/list_bl.h>
8 #include <linux/rcupdate.h>
9 
10 static inline void hlist_bl_set_first_rcu(struct hlist_bl_head *h,
11  struct hlist_bl_node *n)
12 {
13  LIST_BL_BUG_ON((unsigned long)n & LIST_BL_LOCKMASK);
14  LIST_BL_BUG_ON(((unsigned long)h->first & LIST_BL_LOCKMASK) !=
15  LIST_BL_LOCKMASK);
17  (struct hlist_bl_node *)((unsigned long)n | LIST_BL_LOCKMASK));
18 }
19 
20 static inline struct hlist_bl_node *hlist_bl_first_rcu(struct hlist_bl_head *h)
21 {
22  return (struct hlist_bl_node *)
23  ((unsigned long)rcu_dereference(h->first) & ~LIST_BL_LOCKMASK);
24 }
25 
46 static inline void hlist_bl_del_init_rcu(struct hlist_bl_node *n)
47 {
48  if (!hlist_bl_unhashed(n)) {
49  __hlist_bl_del(n);
50  n->pprev = NULL;
51  }
52 }
53 
73 static inline void hlist_bl_del_rcu(struct hlist_bl_node *n)
74 {
75  __hlist_bl_del(n);
76  n->pprev = LIST_POISON2;
77 }
78 
98 static inline void hlist_bl_add_head_rcu(struct hlist_bl_node *n,
99  struct hlist_bl_head *h)
100 {
101  struct hlist_bl_node *first;
102 
103  /* don't need hlist_bl_first_rcu because we're under lock */
104  first = hlist_bl_first(h);
105 
106  n->next = first;
107  if (first)
108  first->pprev = &n->next;
109  n->pprev = &h->first;
110 
111  /* need _rcu because we can have concurrent lock free readers */
112  hlist_bl_set_first_rcu(h, n);
113 }
122 #define hlist_bl_for_each_entry_rcu(tpos, pos, head, member) \
123  for (pos = hlist_bl_first_rcu(head); \
124  pos && \
125  ({ tpos = hlist_bl_entry(pos, typeof(*tpos), member); 1; }); \
126  pos = rcu_dereference_raw(pos->next))
127 
128 #endif