LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

[PATCH RFC net-next 01/14] rculist_bl: add hlist_bl_for_each_entry_conti

To: Simon Horman <horms@xxxxxxxxxxxx>
Subject: [PATCH RFC net-next 01/14] rculist_bl: add hlist_bl_for_each_entry_continue_rcu
Cc: lvs-devel@xxxxxxxxxxxxxxx, netfilter-devel@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx, "Paul E . McKenney" <paulmck@xxxxxxxxxx>, rcu@xxxxxxxxxxxxxxx, Dust Li <dust.li@xxxxxxxxxxxxxxxxx>, Jiejian Wu <jiejian@xxxxxxxxxxxxxxxxx>, Jiri Wiesner <jwiesner@xxxxxxx>
From: Julian Anastasov <ja@xxxxxx>
Date: Tue, 15 Aug 2023 20:30:18 +0300
Add hlist_bl_for_each_entry_continue_rcu and hlist_bl_next_rcu

Signed-off-by: Julian Anastasov <ja@xxxxxx>
---
 include/linux/rculist_bl.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/linux/rculist_bl.h b/include/linux/rculist_bl.h
index 0b952d06eb0b..93a757793d83 100644
--- a/include/linux/rculist_bl.h
+++ b/include/linux/rculist_bl.h
@@ -24,6 +24,10 @@ static inline struct hlist_bl_node 
*hlist_bl_first_rcu(struct hlist_bl_head *h)
                ((unsigned long)rcu_dereference_check(h->first, 
hlist_bl_is_locked(h)) & ~LIST_BL_LOCKMASK);
 }
 
+/* return the next element in an RCU protected list */
+#define hlist_bl_next_rcu(node)        \
+       (*((struct hlist_bl_node __rcu **)(&(node)->next)))
+
 /**
  * hlist_bl_del_rcu - deletes entry from hash list without re-initialization
  * @n: the element to delete from the hash list.
@@ -98,4 +102,17 @@ static inline void hlist_bl_add_head_rcu(struct 
hlist_bl_node *n,
                ({ tpos = hlist_bl_entry(pos, typeof(*tpos), member); 1; }); \
                pos = rcu_dereference_raw(pos->next))
 
+/**
+ * hlist_bl_for_each_entry_continue_rcu - iterate over a list continuing after
+ *   current point
+ * @tpos:      the type * to use as a loop cursor.
+ * @pos:       the &struct hlist_bl_node to use as a loop cursor.
+ * @member:    the name of the hlist_bl_node within the struct.
+ */
+#define hlist_bl_for_each_entry_continue_rcu(tpos, pos, member)                
\
+       for (pos = rcu_dereference_raw(hlist_bl_next_rcu(&(tpos)->member)); \
+            pos &&                                                     \
+            ({ tpos = hlist_bl_entry(pos, typeof(*tpos), member); 1; }); \
+            pos = rcu_dereference_raw(hlist_bl_next_rcu(pos)))
+
 #endif
-- 
2.41.0



<Prev in Thread] Current Thread [Next in Thread>