Author: hselasky
Date: Tue Oct 20 08:40:39 2020
New Revision: 366889
URL: https://svnweb.freebsd.org/changeset/base/366889

Log:
  MFC r349277 and r366669:
  Implement more RCU list functions in the LinuxKPI.
  
  Differential Revision:  https://reviews.freebsd.org/D20719
  Sponsored by:         Mellanox Technologies // NVIDIA Networking

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/rculist.h
  stable/11/sys/sys/param.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/rculist.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/linux/rculist.h        Tue Oct 
20 08:35:16 2020        (r366888)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/rculist.h        Tue Oct 
20 08:40:39 2020        (r366889)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2015 François Tigeot
- * Copyright (c) 2016-2017 Mellanox Technologies, Ltd.
+ * Copyright (c) 2016-2020 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,58 @@
 #include <linux/list.h>
 #include <linux/rcupdate.h>
 
+#define        list_entry_rcu(ptr, type, member) \
+       container_of(READ_ONCE(ptr), type, member)
+
+#define        list_next_rcu(head)     (*((struct list_head 
**)(&(head)->next)))
+#define        list_prev_rcu(head)     (*((struct list_head 
**)(&(head)->prev)))
+
+#define        list_for_each_entry_rcu(pos, head, member) \
+       for (pos = list_entry_rcu((head)->next, typeof(*(pos)), member); \
+            &(pos)->member != (head);                                  \
+            pos = list_entry_rcu((pos)->member.next, typeof(*(pos)), member))
+
+static inline void
+linux_list_add_rcu(struct list_head *new, struct list_head *prev,
+    struct list_head *next)
+{
+       new->next = next;
+       new->prev = prev;
+       rcu_assign_pointer(list_next_rcu(prev), new);
+       next->prev = new;
+}
+
+static inline void
+list_add_rcu(struct list_head *new, struct list_head *head)
+{
+       linux_list_add_rcu(new, head, head->next);
+}
+
+static inline void
+list_add_tail_rcu(struct list_head *new, struct list_head *head)
+{
+       linux_list_add_rcu(new, head->prev, head);
+}
+
+static inline void
+__list_del_rcu(struct list_head *prev, struct list_head *next)
+{
+       next->prev = prev;
+       rcu_assign_pointer(list_next_rcu(prev), next);
+}
+
+static inline void
+__list_del_entry_rcu(struct list_head *entry)
+{
+       __list_del_rcu(entry->prev, entry->next);
+}
+
+static inline void
+list_del_rcu(struct list_head *entry)
+{
+       __list_del_rcu(entry->prev, entry->next);
+}
+
 #define        hlist_first_rcu(head)   (*((struct hlist_node 
**)(&(head)->first)))
 #define        hlist_next_rcu(node)    (*((struct hlist_node 
**)(&(node)->next)))
 #define        hlist_pprev_rcu(node)   (*((struct hlist_node 
**)((node)->pprev)))
@@ -47,8 +99,12 @@ hlist_add_behind_rcu(struct hlist_node *n, struct hlis
                n->next->pprev = &n->next;
 }
 
-#define        hlist_for_each_entry_rcu(pos, head, member)     \
-       hlist_for_each_entry(pos, head, member)
+#define        hlist_for_each_entry_rcu(pos, head, member)                     
\
+       for (pos = hlist_entry_safe 
(rcu_dereference_raw(hlist_first_rcu(head)),\
+               typeof(*(pos)), member);                                \
+            (pos);                                                     \
+            pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
+                       &(pos)->member)), typeof(*(pos)), member))
 
 static inline void
 hlist_del_rcu(struct hlist_node *n)

Modified: stable/11/sys/sys/param.h
==============================================================================
--- stable/11/sys/sys/param.h   Tue Oct 20 08:35:16 2020        (r366888)
+++ stable/11/sys/sys/param.h   Tue Oct 20 08:40:39 2020        (r366889)
@@ -58,7 +58,7 @@
  *             in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1104508      /* Master, propagated to newvers */
+#define __FreeBSD_version 1104509      /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to