]> xenbits.xensource.com Git - xen.git/commit
rbtree: adjust root color in rb_insert_color() only when necessary
authorMichel Lespinasse <walken@google.com>
Wed, 20 Dec 2017 17:02:31 +0000 (18:02 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 20 Dec 2017 17:02:31 +0000 (18:02 +0100)
commit74ed07944ad082dc54d5bcead9faae35ee83099f
tree81b9c32fefbf95c0ead74354e7aab43f66f0a89f
parent344824c0f4b6aae3deca1e8b15d4e3f26a761682
rbtree: adjust root color in rb_insert_color() only when necessary

The root node of an rbtree must always be black.  However,
rb_insert_color() only needs to maintain this invariant when it has been
broken - that is, when it exits the loop due to the current (red) node
being the root.  In all other cases (exiting after tree rotations, or
exiting due to an existing black parent) the invariant is already
satisfied, so there is no need to adjust the root node color.

Signed-off-by: Michel Lespinasse <walken@google.com>
Acked-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[Linux commit 6d58452dc066db61acdff7b84671db1b11a3de1c]

Ported to Xen.

Signed-off-by: Praveen Kumar <kpraveen.lkml@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/common/rbtree.c