Commit 4130f0ef authored by Davidlohr Bueso's avatar Davidlohr Bueso Committed by Linus Torvalds

rbtree_test: add extra rbtree integrity check

Account for the rbtree having  2**bh(v)-1 internal nodes.

While this can be seen as a consequence of other checks, Michel states
that it nicely sums up what the other properties are for.
Signed-off-by: default avatarDavidlohr Bueso <davidlohr.bueso@hp.com>
Reviewed-by: default avatarMichel Lespinasse <walken@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 31c3a3fe
...@@ -117,8 +117,7 @@ static int black_path_count(struct rb_node *rb) ...@@ -117,8 +117,7 @@ static int black_path_count(struct rb_node *rb)
static void check(int nr_nodes) static void check(int nr_nodes)
{ {
struct rb_node *rb; struct rb_node *rb;
int count = 0; int count = 0, blacks = 0;
int blacks = 0;
u32 prev_key = 0; u32 prev_key = 0;
for (rb = rb_first(&root); rb; rb = rb_next(rb)) { for (rb = rb_first(&root); rb; rb = rb_next(rb)) {
...@@ -134,7 +133,9 @@ static void check(int nr_nodes) ...@@ -134,7 +133,9 @@ static void check(int nr_nodes)
prev_key = node->key; prev_key = node->key;
count++; count++;
} }
WARN_ON_ONCE(count != nr_nodes); WARN_ON_ONCE(count != nr_nodes);
WARN_ON_ONCE(count < (1 << black_path_count(rb_last(&root))) - 1);
} }
static void check_augmented(int nr_nodes) static void check_augmented(int nr_nodes)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment