rbtree: handle 1-child recoloring in rb_erase() instead of rb_erase_color()
authorMichel Lespinasse <walken@google.com>
Wed, 3 Jan 2018 11:41:47 +0000 (12:41 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 3 Jan 2018 11:41:47 +0000 (12:41 +0100)
commit4da1856bc03c7c5d6c0a4a9e8815d6373dc0a0de
tree1897c23f481ace4d4c0779673534884eb58a8b91
parenta6b1da2915b195cda66026e1024dc54375da08b4
rbtree: handle 1-child recoloring in rb_erase() instead of rb_erase_color()

An interesting observation for rb_erase() is that when a node has
exactly one child, the node must be black and the child must be red.
An interesting consequence is that removing such a node can be done by
simply replacing it with its child and making the child black,
which we can do efficiently in rb_erase(). __rb_erase_color() then
only needs to handle the no-childs case and can be modified accordingly.

Signed-off-by: Michel Lespinasse <walken@google.com>
Acked-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[Linux commit 46b6135a7402ac23c5b25f2bd79b03bab8f98278]

Ported to Xen.

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