Date: Mon, 5 Jul 2021 00:23:43 GMT From: Vladimir Kondratyev <wulf@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: c0862b2b1fa9 - main - LinuxKPI: Add compiler barriers to list_for_each_entry_lockless macro Message-ID: <202107050023.1650Nh6L022558@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=c0862b2b1fa91636d308a1a41d8dc370691d656e commit c0862b2b1fa91636d308a1a41d8dc370691d656e Author: Vladimir Kondratyev <wulf@FreeBSD.org> AuthorDate: 2021-07-05 00:19:35 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2021-07-05 00:19:35 +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 --- 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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107050023.1650Nh6L022558>