git: ddebb8c0f780 - stable/13 - LinuxKPI: Add compiler barriers to list_for_each_entry_lockless macro

Vladimir Kondratyev wulf at FreeBSD.org
Tue Jul 20 23:46:23 UTC 2021


The branch stable/13 has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=ddebb8c0f780626d1dbd24725bbf9bc16bf4b819

commit ddebb8c0f780626d1dbd24725bbf9bc16bf4b819
Author:     Vladimir Kondratyev <wulf at FreeBSD.org>
AuthorDate: 2021-07-05 00:19:35 +0000
Commit:     Vladimir Kondratyev <wulf at FreeBSD.org>
CommitDate: 2021-07-20 22:43:52 +0000

    LinuxKPI: Add compiler barriers to list_for_each_entry_lockless macro
    
    so 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().
    
    Do it by reusing the "list_for_each_entry_rcu" macro which does the same.
    On Linux it implements some additional lockdep stuff which we skip.
    
    Also move the macro to linux/rculist.h where it resides on Linux.
    
    Reviewed by:    hselasky
    Differential revision:  https://reviews.freebsd.org/D30795
    
    (cherry picked from commit c0862b2b1fa91636d308a1a41d8dc370691d656e)
---
 sys/compat/linuxkpi/common/include/linux/list.h    | 2 --
 sys/compat/linuxkpi/common/include/linux/rculist.h | 3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/list.h b/sys/compat/linuxkpi/common/include/linux/list.h
index 93db449a4473..37b5b751d21b 100644
--- a/sys/compat/linuxkpi/common/include/linux/list.h
+++ b/sys/compat/linuxkpi/common/include/linux/list.h
@@ -202,8 +202,6 @@ list_del_init(struct list_head *entry)
 	for (p = list_entry((h)->next, typeof(*p), field); &(p)->field != (h); \
 	    p = list_entry((p)->field.next, typeof(*p), field))
 
-#define list_for_each_entry_lockless(...) list_for_each_entry(__VA_ARGS__)
-
 #define list_for_each_entry_safe(p, n, h, field)			\
 	for (p = list_entry((h)->next, typeof(*p), field),		\
 	    n = list_entry((p)->field.next, typeof(*p), field); &(p)->field != (h);\
diff --git a/sys/compat/linuxkpi/common/include/linux/rculist.h b/sys/compat/linuxkpi/common/include/linux/rculist.h
index bff2f7e13184..6c21a6943f98 100644
--- a/sys/compat/linuxkpi/common/include/linux/rculist.h
+++ b/sys/compat/linuxkpi/common/include/linux/rculist.h
@@ -44,6 +44,9 @@
 	     &(pos)->member != (head);					\
 	     pos = list_entry_rcu((pos)->member.next, typeof(*(pos)), member))
 
+#define	list_for_each_entry_lockless(pos, head, member) \
+	list_for_each_entry_rcu(pos, head, member)
+
 static inline void
 linux_list_add_rcu(struct list_head *new, struct list_head *prev,
     struct list_head *next)


More information about the dev-commits-src-all mailing list