diff options
| author | Vladimir Kondratyev <wulf@FreeBSD.org> | 2021-07-05 00:19:35 +0000 |
|---|---|---|
| committer | Vladimir Kondratyev <wulf@FreeBSD.org> | 2021-07-20 22:43:52 +0000 |
| commit | ddebb8c0f780626d1dbd24725bbf9bc16bf4b819 (patch) | |
| tree | e4310a965671b57c0b572793770b2aba3ba5c82a | |
| parent | 71d815861f1cd0281443a216998c23000fb4b301 (diff) | |
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)
| -rw-r--r-- | sys/compat/linuxkpi/common/include/linux/list.h | 2 | ||||
| -rw-r--r-- | 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) |
