git: 09ba3ece1817 - main - linuxkpi: Add `list_for_each_rcu()`

From: Jean-Sébastien Pédron <dumbbell_at_FreeBSD.org>
Date: Thu, 20 Mar 2025 19:53:56 UTC
The branch main has been updated by dumbbell:

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

commit 09ba3ece18177c6ed96f8be75c6d648e9d20acdf
Author:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2025-02-22 18:25:51 +0000
Commit:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2025-03-20 19:43:44 +0000

    linuxkpi: Add `list_for_each_rcu()`
    
    This is a variant of `list_for_each()` where the next item in the list
    is read using `rcu_dereference()`.
    
    This is used by the i915 DRM driver starting with Linux 6.8.
    
    Reviewed by:    emaste
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D49375
---
 sys/compat/linuxkpi/common/include/linux/list.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/list.h b/sys/compat/linuxkpi/common/include/linux/list.h
index eecb517d780e..a6c74a324dac 100644
--- a/sys/compat/linuxkpi/common/include/linux/list.h
+++ b/sys/compat/linuxkpi/common/include/linux/list.h
@@ -234,6 +234,11 @@ list_del_init(struct list_head *entry)
 	for (; &p->field != (h);			\
 	     p = list_prev_entry(p, field))
 
+#define	list_for_each_rcu(p, head)					\
+	for (p = rcu_dereference((head)->next);				\
+	     p != (head);						\
+	     p = rcu_dereference((p)->next))
+
 static inline void
 list_add(struct list_head *new, struct list_head *head)
 {