summaryrefslogtreecommitdiff
path: root/include/linux/rbtree_augmented.h
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2016-07-01 07:53:51 +0100
committerDavid Howells <dhowells@redhat.com>2016-07-06 10:51:14 +0100
commitc1adf20052d80f776849fa2c1acb472cdeb7786c (patch)
treee73407fdc52ab77e9666ae7798c8b38b6da1ed09 /include/linux/rbtree_augmented.h
parent1291e9d1084506c5cba6313ce809d7516bb5868a (diff)
Introduce rb_replace_node_rcu()
Implement an RCU-safe variant of rb_replace_node() and rearrange rb_replace_node() to do things in the same order. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Diffstat (limited to 'include/linux/rbtree_augmented.h')
-rw-r--r--include/linux/rbtree_augmented.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
index 14d7b831b63a..d076183e49be 100644
--- a/include/linux/rbtree_augmented.h
+++ b/include/linux/rbtree_augmented.h
@@ -130,6 +130,19 @@ __rb_change_child(struct rb_node *old, struct rb_node *new,
WRITE_ONCE(root->rb_node, new);
}
+static inline void
+__rb_change_child_rcu(struct rb_node *old, struct rb_node *new,
+ struct rb_node *parent, struct rb_root *root)
+{
+ if (parent) {
+ if (parent->rb_left == old)
+ rcu_assign_pointer(parent->rb_left, new);
+ else
+ rcu_assign_pointer(parent->rb_right, new);
+ } else
+ rcu_assign_pointer(root->rb_node, new);
+}
+
extern void __rb_erase_color(struct rb_node *parent, struct rb_root *root,
void (*augment_rotate)(struct rb_node *old, struct rb_node *new));