From 55a1259ca7e2f78ab99451ce4a373687ecf81fb2 Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Tue, 29 May 2012 15:07:34 -0700 Subject: [PATCH] --- yaml --- r: 308985 b: refs/heads/master c: 5536805292e64393f57054de66578f17eb1ea994 h: refs/heads/master i: 308983: 4d2ecac8e67b02c6ea5b75bf2f663573036b3955 v: v3 --- [refs] | 2 +- trunk/lib/radix-tree.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 0c3670c309a9..d09c9622f6c2 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: fd0a37355c4d39affa39d5cd75168fb94b292318 +refs/heads/master: 5536805292e64393f57054de66578f17eb1ea994 diff --git a/trunk/lib/radix-tree.c b/trunk/lib/radix-tree.c index 86516f5588e3..d7c878cc006c 100644 --- a/trunk/lib/radix-tree.c +++ b/trunk/lib/radix-tree.c @@ -72,12 +72,25 @@ static unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH + 1] __read_mostly; */ static struct kmem_cache *radix_tree_node_cachep; +/* + * The radix tree is variable-height, so an insert operation not only has + * to build the branch to its corresponding item, it also has to build the + * branch to existing items if the size has to be increased (by + * radix_tree_extend). + * + * The worst case is a zero height tree with just a single item at index 0, + * and then inserting an item at index ULONG_MAX. This requires 2 new branches + * of RADIX_TREE_MAX_PATH size to be created, with only the root node shared. + * Hence: + */ +#define RADIX_TREE_PRELOAD_SIZE (RADIX_TREE_MAX_PATH * 2 - 1) + /* * Per-cpu pool of preloaded nodes */ struct radix_tree_preload { int nr; - struct radix_tree_node *nodes[RADIX_TREE_MAX_PATH]; + struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE]; }; static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };