Skip to content

Commit a460bec

Browse files
Davidlohr Buesotorvalds
authored andcommitted
rbtree: use READ_ONCE in RB_EMPTY_ROOT
With commit d72da4a ("rbtree: Make lockless searches non-fatal") our rbtrees provide weak guarantees that allows us to do lockless (and very speculative) reads of the tree. Such readers cannot see partial stores on nodes, ie left/right as well as root. As such, similar to the WRITE_ONCE semantics when doing rotations, use READ_ONCE when checking the root node in RB_EMPTY_ROOT. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Michel Lespinasse <walken@google.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a253f1e commit a460bec

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎include/linux/rbtree.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct rb_root {
5050
#define RB_ROOT (struct rb_root) { NULL, }
5151
#define rb_entry(ptr, type, member) container_of(ptr, type, member)
5252

53-
#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL)
53+
#define RB_EMPTY_ROOT(root) (READ_ONCE((root)->rb_node) == NULL)
5454

5555
/* 'empty' nodes are nodes that are known not to be inserted in an rbtree */
5656
#define RB_EMPTY_NODE(node) \

0 commit comments

Comments
 (0)