Author: hselasky
Date: Wed Jun  6 15:49:01 2018
New Revision: 334720
URL: https://svnweb.freebsd.org/changeset/base/334720

Log:
  Make some list functions RCU safe in the LinuxKPI.
  While at it rename hlist_add_after() into hlist_add_behind().
  
  Submitted by: Johannes Lundberg <johal...@gmail.com>
  MFC after:    1 week
  Sponsored by: Mellanox Technologies
  Sponsored by: Limelight Networks

Modified:
  head/sys/compat/linuxkpi/common/include/linux/list.h

Modified: head/sys/compat/linuxkpi/common/include/linux/list.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/list.h        Wed Jun  6 
15:45:57 2018        (r334719)
+++ head/sys/compat/linuxkpi/common/include/linux/list.h        Wed Jun  6 
15:49:01 2018        (r334720)
@@ -337,16 +337,16 @@ static inline int
 hlist_empty(const struct hlist_head *h)
 {
 
-       return !h->first;
+       return !READ_ONCE(h->first);
 }
 
 static inline void
 hlist_del(struct hlist_node *n)
 {
 
-       if (n->next)
+       WRITE_ONCE(*(n->pprev), n->next);
+       if (n->next != NULL)
                n->next->pprev = n->pprev;
-       *n->pprev = n->next;
 }
 
 static inline void
@@ -364,9 +364,9 @@ hlist_add_head(struct hlist_node *n, struct hlist_head
 {
 
        n->next = h->first;
-       if (h->first)
+       if (h->first != NULL)
                h->first->pprev = &n->next;
-       h->first = n;
+       WRITE_ONCE(h->first, n);
        n->pprev = &h->first;
 }
 
@@ -377,18 +377,19 @@ hlist_add_before(struct hlist_node *n, struct hlist_no
        n->pprev = next->pprev;
        n->next = next;
        next->pprev = &n->next;
-       *(n->pprev) = n;
+       WRITE_ONCE(*(n->pprev), n);
 }
 
 static inline void
-hlist_add_after(struct hlist_node *n, struct hlist_node *next)
+hlist_add_behind(struct hlist_node *n, struct hlist_node *prev)
 {
 
-       next->next = n->next;
-       n->next = next;
-       next->pprev = &n->next;
-       if (next->next)
-               next->next->pprev = &next->next;
+       n->next = prev->next;
+       WRITE_ONCE(prev->next, n);
+       n->pprev = &prev->next;
+
+       if (n->next != NULL)
+               n->next->pprev = &n->next;
 }
 
 static inline void
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to