summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@osdl.org>2004-07-29 00:41:06 -0700
committerDavid S. Miller <davem@nuts.davemloft.net>2004-07-29 00:41:06 -0700
commit2f7b3472996d11ad495e688c6faea305a93e61d2 (patch)
tree20be208b938f0c6e940eabb0fa63256ab7017779 /include/linux
parent87dd39edb1d4537f13562b18da0f34cab711633e (diff)
[BRIDGE]: forwarding table RCU
Convert the bridge forwarding database over to using RCU. This avoids a read_lock and atomic_inc/dec in the fast path of output. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: David S. Miller <davem@redhat.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/list.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index 23e287fe4259..978876d258a9 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -678,6 +678,24 @@ static inline void hlist_add_after(struct hlist_node *n,
pos && ({ n = pos->next; 1; }) && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = n)
+
+/**
+ * hlist_for_each_entry_rcu - iterate over rcu list of given type
+ * @pos: the type * to use as a loop counter.
+ * @pos: the &struct hlist_node to use as a loop counter.
+ * @head: the head for your list.
+ * @member: the name of the hlist_node within the struct.
+ *
+ * This list-traversal primitive may safely run concurrently with
+ * the _rcu list-mutation primitives such as hlist_add_rcu()
+ * as long as the traversal is guarded by rcu_read_lock().
+ */
+#define hlist_for_each_entry_rcu(tpos, pos, head, member) \
+ for (pos = (head)->first; \
+ pos && ({ prefetch(pos->next); 1;}) && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next, ({ smp_read_barrier_depends(); 0; }) )
+
#else
#warning "don't include kernel headers in userspace"
#endif /* __KERNEL__ */