From: Sasha Levin Subject: [PATCH 1/2] kvm tools: Fix rbtree-interval balancing Date: Sat, 21 May 2011 11:51:50 +0300 Message-ID: <1305967911-30045-1-git-send-email-levinsasha928@gmail.com> Cc: mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, kvm@vger.kernel.org, Sasha Levin To: penberg@kernel.org Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:45882 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751145Ab1EUIwF (ORCPT ); Sat, 21 May 2011 04:52:05 -0400 Received: by wwa36 with SMTP id 36so4709689wwa.1 for ; Sat, 21 May 2011 01:52:03 -0700 (PDT) Sender: kvm-owner@vger.kernel.org List-ID: Augmentation is started on the pre-rotation node found in the search, augment the rotated node instead. Max high is the max of max highs below it, not the max of highs below it. Signed-off-by: Sasha Levin --- tools/kvm/util/rbtree-interval.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/kvm/util/rbtree-interval.c b/tools/kvm/util/rbtree-interval.c index 735e912..d02fbf0 100644 --- a/tools/kvm/util/rbtree-interval.c +++ b/tools/kvm/util/rbtree-interval.c @@ -51,9 +51,9 @@ static void update_node_max_high(struct rb_node *node, void *arg) i_node->max_high = i_node->high; if (node->rb_left) - i_node->max_high = max(i_node->max_high, rb_int(node->rb_left)->high); + i_node->max_high = max(i_node->max_high, rb_int(node->rb_left)->max_high); if (node->rb_right) - i_node->max_high = max(i_node->max_high, rb_int(node->rb_right)->high); + i_node->max_high = max(i_node->max_high, rb_int(node->rb_right)->max_high); } int rb_int_insert(struct rb_root *root, struct rb_int_node *i_node) @@ -75,7 +75,7 @@ int rb_int_insert(struct rb_root *root, struct rb_int_node *i_node) rb_link_node(&i_node->node, parent, node); rb_insert_color(&i_node->node, root); - rb_augment_insert(*node, update_node_max_high, NULL); + rb_augment_insert(&i_node->node, update_node_max_high, NULL); return 1; } -- 1.7.5.rc3