Author: hselasky
Date: Tue Oct 20 08:35:16 2020
New Revision: 366888
URL: https://svnweb.freebsd.org/changeset/base/366888

Log:
  MFC r366669:
  Implement more RCU list functions in the LinuxKPI.
  
  This also fixes a bug in the existing list_add_rcu() where the
  prev->prev pointer was updated to the new element instead of
  next->prev. Currently this function is not widely used.
  
  Sponsored by:         Mellanox Technologies // NVIDIA Networking

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

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/rculist.h
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/include/linux/rculist.h        Tue Oct 
20 08:34:03 2020        (r366887)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/rculist.h        Tue Oct 
20 08:35:16 2020        (r366888)
@@ -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
@@ -37,6 +37,7 @@
        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); \
@@ -44,12 +45,44 @@
             pos = list_entry_rcu((pos)->member.next, typeof(*(pos)), member))
 
 static inline void
-list_add_rcu(struct list_head *new, struct list_head *prev)
+linux_list_add_rcu(struct list_head *new, struct list_head *prev,
+    struct list_head *next)
 {
-       new->next = prev->next;
+       new->next = next;
        new->prev = prev;
        rcu_assign_pointer(list_next_rcu(prev), new);
-       prev->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)))
_______________________________________________
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