Merge branch 'proc-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm...
[platform/kernel/linux-starfive.git] / include / linux / rculist.h
index 7375bb3..df587d1 100644 (file)
@@ -506,6 +506,27 @@ static inline void hlist_replace_rcu(struct hlist_node *old,
        WRITE_ONCE(old->pprev, LIST_POISON2);
 }
 
+/**
+ * hlists_swap_heads_rcu - swap the lists the hlist heads point to
+ * @left:  The hlist head on the left
+ * @right: The hlist head on the right
+ *
+ * The lists start out as [@left  ][node1 ... ] and
+                          [@right ][node2 ... ]
+ * The lists end up as    [@left  ][node2 ... ]
+ *                        [@right ][node1 ... ]
+ */
+static inline void hlists_swap_heads_rcu(struct hlist_head *left, struct hlist_head *right)
+{
+       struct hlist_node *node1 = left->first;
+       struct hlist_node *node2 = right->first;
+
+       rcu_assign_pointer(left->first, node2);
+       rcu_assign_pointer(right->first, node1);
+       WRITE_ONCE(node2->pprev, &left->first);
+       WRITE_ONCE(node1->pprev, &right->first);
+}
+
 /*
  * return the first or the next element in an RCU protected hlist
  */