]> Pileus Git - ~andy/linux/blobdiff - include/linux/rculist.h
udp: introduce sk_for_each_rcu_safenext()
[~andy/linux] / include / linux / rculist.h
index eb4443c7e05be213f49596b81b50f209923ab4da..3ba2998b22ba64f33b127d7ac368b1ac8196a03c 100644 (file)
@@ -198,20 +198,6 @@ static inline void list_splice_init_rcu(struct list_head *list,
        at->prev = last;
 }
 
-/**
- * list_for_each_rcu   -       iterate over an rcu-protected list
- * @pos:       the &struct list_head to use as a loop cursor.
- * @head:      the head for your list.
- *
- * This list-traversal primitive may safely run concurrently with
- * the _rcu list-mutation primitives such as list_add_rcu()
- * as long as the traversal is guarded by rcu_read_lock().
- */
-#define list_for_each_rcu(pos, head) \
-       for (pos = rcu_dereference((head)->next); \
-               prefetch(pos->next), pos != (head); \
-               pos = rcu_dereference(pos->next))
-
 #define __list_for_each_rcu(pos, head) \
        for (pos = rcu_dereference((head)->next); \
                pos != (head); \
@@ -397,5 +383,22 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
                ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \
                pos = rcu_dereference(pos->next))
 
+/**
+ * hlist_for_each_entry_rcu_safenext - iterate over rcu list of given type
+ * @tpos:      the type * to use as a loop cursor.
+ * @pos:       the &struct hlist_node to use as a loop cursor.
+ * @head:      the head for your list.
+ * @member:    the name of the hlist_node within the struct.
+ * @next:       the &struct hlist_node to use as a next cursor
+ *
+ * Special version of hlist_for_each_entry_rcu that make sure
+ * each next pointer is fetched before each iteration.
+ */
+#define hlist_for_each_entry_rcu_safenext(tpos, pos, head, member, next) \
+       for (pos = rcu_dereference((head)->first);                       \
+               pos && ({ next = pos->next; smp_rmb(); prefetch(next); 1; }) && \
+               ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \
+               pos = rcu_dereference(next))
+
 #endif /* __KERNEL__ */
 #endif