]> git.karo-electronics.de Git - karo-tx-linux.git/commit
rbtree: adjust root color in rb_insert_color() only when necessary
authorMichel Lespinasse <walken@google.com>
Fri, 7 Sep 2012 00:23:47 +0000 (10:23 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 7 Sep 2012 05:36:19 +0000 (15:36 +1000)
commite88eefd9565d78b523a2e8081a0094a82d783df7
treecd825dced4896dc83716eb52c44f4bac8cb38f20
parent2be4c892e6215649c4daf72090d2eadee5713734
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>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Acked-by: David Woodhouse <David.Woodhouse@intel.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Daniel Santos <daniel.santos@pobox.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/rbtree.c