]> 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>
Tue, 14 Aug 2012 03:22:41 +0000 (13:22 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 21 Aug 2012 05:18:16 +0000 (15:18 +1000)
commit31f614cdeab9de31319e888d48007667bb7482cc
tree2e5e2d974591012dec12d5dfc0392026b5dfb3e2
parent5a4bf1b8edbdc7236d604c591458708dfd8900a8
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