Commit-ID: f1c9f84fca758be082b427df820b9cdd7eedc24f Gitweb: http://git.kernel.org/tip/f1c9f84fca758be082b427df820b9cdd7eedc24f Author: Ingo Molnar <mingo@xxxxxxx> AuthorDate: Sat, 20 Oct 2012 01:22:33 +0200 Committer: Pekka Enberg <penberg@xxxxxxxxxx> CommitDate: Sat, 20 Oct 2012 10:59:34 +0300 kvm tools: Port to v3.7-rc1 There were a number of changes that caused problems: - UAPI conversion - the old version of the rbtree-augmented API got removed, I updated the implementation to the new API - lib/rbtree.c wants a 'true' definition Lightly tested: it boots a v3.7-rc1 defconfig+kvmconfig kernel. Signed-off-by: Ingo Molnar <mingo@xxxxxxx> Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx> --- tools/kvm/Makefile | 2 +- tools/kvm/include/kvm/rbtree-interval.h | 2 +- tools/kvm/include/linux/kernel.h | 2 + tools/kvm/util/rbtree-interval.c | 49 ++++++++++++++++++++++++------ 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index e0d07dc..903001e 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -244,7 +244,7 @@ DEFINES += -DKVMTOOLS_VERSION='"$(KVMTOOLS_VERSION)"' DEFINES += -DBUILD_ARCH='"$(ARCH)"' KVM_INCLUDE := include -CFLAGS += $(CPPFLAGS) $(DEFINES) -I$(KVM_INCLUDE) -I$(ARCH_INCLUDE) -I$(KINCL_PATH)/include -I$(KINCL_PATH)/arch/$(ARCH)/include/ -O2 -fno-strict-aliasing -g -flto +CFLAGS += $(CPPFLAGS) $(DEFINES) -I$(KVM_INCLUDE) -I$(ARCH_INCLUDE) -I$(KINCL_PATH)/include/uapi -I$(KINCL_PATH)/include -I$(KINCL_PATH)/arch/$(ARCH)/include/ -O2 -fno-strict-aliasing -g -flto WARNINGS += -Wall WARNINGS += -Wcast-align diff --git a/tools/kvm/include/kvm/rbtree-interval.h b/tools/kvm/include/kvm/rbtree-interval.h index 13245ba..e97d05b 100644 --- a/tools/kvm/include/kvm/rbtree-interval.h +++ b/tools/kvm/include/kvm/rbtree-interval.h @@ -1,7 +1,7 @@ #ifndef KVM__INTERVAL_RBTREE_H #define KVM__INTERVAL_RBTREE_H -#include <linux/rbtree.h> +#include <linux/rbtree_augmented.h> #include <linux/types.h> #define RB_INT_INIT(l, h) (struct rb_int_node){.low = l, .high = h} diff --git a/tools/kvm/include/linux/kernel.h b/tools/kvm/include/linux/kernel.h index d2ec4a3..1e9abe9 100644 --- a/tools/kvm/include/linux/kernel.h +++ b/tools/kvm/include/linux/kernel.h @@ -36,4 +36,6 @@ (void) (&_max1 == &_max2); \ _max1 > _max2 ? _max1 : _max2; }) +#define true 1 + #endif diff --git a/tools/kvm/util/rbtree-interval.c b/tools/kvm/util/rbtree-interval.c index f9bf4b8..c82ce98 100644 --- a/tools/kvm/util/rbtree-interval.c +++ b/tools/kvm/util/rbtree-interval.c @@ -43,7 +43,10 @@ struct rb_int_node *rb_int_search_range(struct rb_root *root, u64 low, u64 high) return range; } -static void update_node_max_high(struct rb_node *node, void *arg) +/* + * Update a node after it has been linked into the tree: + */ +static void propagate_callback(struct rb_node *node, struct rb_node *stop) { struct rb_int_node *i_node = rb_int(node); @@ -55,9 +58,41 @@ static void update_node_max_high(struct rb_node *node, void *arg) i_node->max_high = max(i_node->max_high, rb_int(node->rb_right)->max_high); } +/* + * Copy the extra data to a new node: + */ +static void copy_callback(struct rb_node *node_old, struct rb_node *node_new) +{ + struct rb_int_node *i_node_old = rb_int(node_old); + struct rb_int_node *i_node_new = rb_int(node_new); + + i_node_new->low = i_node_old->low; + i_node_new->high = i_node_old->high; + + i_node_new->max_high = i_node_old->max_high; +} + +/* + * Update after tree rotation: + */ +static void rotate_callback(struct rb_node *node_old, struct rb_node *node_new) +{ + propagate_callback(node_old, NULL); + propagate_callback(node_new, NULL); +} + +/* + * All augmented rbtree callbacks: + */ +struct rb_augment_callbacks callbacks = { + .propagate = propagate_callback, + .copy = copy_callback, + .rotate = rotate_callback, +}; + int rb_int_insert(struct rb_root *root, struct rb_int_node *i_node) { - struct rb_node **node = &(root->rb_node), *parent = NULL; + struct rb_node **node = &root->rb_node, *parent = NULL; while (*node) { int result = i_node->low - rb_int(*node)->low; @@ -72,18 +107,12 @@ 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_insert_augmented(&i_node->node, root, &callbacks); - rb_augment_insert(&i_node->node, update_node_max_high, NULL); return 0; } void rb_int_erase(struct rb_root *root, struct rb_int_node *node) { - struct rb_node *deepest; - - deepest = rb_augment_erase_begin(&node->node); - rb_erase(&node->node, root); - rb_augment_erase_end(deepest, update_node_max_high, NULL); - + rb_erase_augmented(&node->node, root, &callbacks); } -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html