[PATCH 4/9] backports: rculist: Add additional parameter to list_for_each_entry_rcu()

Hauke Mehrtens <[email protected]>
Newsgroups org.kernel.vger.backports
Message-ID <[email protected]>
Upstream commit 28875945ba98 ("rcu: Add support for consolidated-RCU
reader checking") adds a new paramater for lock checking to
list_for_each_entry_rcu().
Older kernel versions do not support CONFIG_PROVE_RCU_LIST, just
ignore the extra parameter.

Signed-off-by: Hauke Mehrtens <[email protected]>
---
 backport/backport-include/linux/rculist.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/backport/backport-include/linux/rculist.h b/backport/backport-include/linux/rculist.h
index 9671e7c4..967cdb86 100644
--- a/backport/backport-include/linux/rculist.h
+++ b/backport/backport-include/linux/rculist.h
@@ -1,6 +1,7 @@
 #ifndef __BACKPORT_RCULIST_H
 #define __BACKPORT_RCULIST_H
 #include_next <linux/rculist.h>
+#include <linux/version.h>
 
 #if LINUX_VERSION_IS_LESS(3,9,0)
 #include <backport/magic.h>
@@ -54,4 +55,25 @@
 })
 #endif /* list_first_or_null_rcu */
 
+
+#if LINUX_VERSION_IS_LESS(5,4,0)
+
+/**
+ * list_for_each_entry_rcu	-	iterate over rcu list of given type
+ * @pos:	the type * to use as a loop cursor.
+ * @head:	the head for your list.
+ * @member:	the name of the list_head within the struct.
+ * @cond...:	optional lockdep expression if called from non-RCU protection.
+ *
+ * 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().
+ */
+#undef list_for_each_entry_rcu
+#define list_for_each_entry_rcu(pos, head, member, cond...)		\
+	for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \
+		&pos->member != (head); \
+		pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
+#endif /* < 5.4 */
+
 #endif /* __BACKPORT_RCULIST_H */
-- 
2.20.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.