diff mbox series

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

Message ID 20200420221615.14734-5-hauke@hauke-m.de (mailing list archive)
State New, archived
Headers show
Series backports: Update to version 5.7-rc2 | expand

Commit Message

Hauke Mehrtens April 20, 2020, 10:16 p.m. UTC
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 <hauke@hauke-m.de>
---
 backport/backport-include/linux/rculist.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
diff mbox series

Patch

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 */