[patch 2/5] radix tree: use prealloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2/5

--
SUSE Labs, Novell Inc.

Prefer radix_tree_preloads to kmem_cache_alloc. If we've allocated them,
why not use them? They're also faster because they needn't turn off
interrupts, so using them in radix tree critical sections is a good idea.

Signed-off-by: Nick Piggin <[email protected]>

Index: linux-2.6/lib/radix-tree.c
===================================================================
--- linux-2.6.orig/lib/radix-tree.c
+++ linux-2.6/lib/radix-tree.c
@@ -82,20 +82,18 @@ DEFINE_PER_CPU(struct radix_tree_preload
 static struct radix_tree_node *
 radix_tree_node_alloc(struct radix_tree_root *root)
 {
-	struct radix_tree_node *ret;
-
-	ret = kmem_cache_alloc(radix_tree_node_cachep, root->gfp_mask);
-	if (ret == NULL && !(root->gfp_mask & __GFP_WAIT)) {
-		struct radix_tree_preload *rtp;
+	struct radix_tree_preload *rtp;
 
-		rtp = &__get_cpu_var(radix_tree_preloads);
-		if (rtp->nr) {
-			ret = rtp->nodes[rtp->nr - 1];
-			rtp->nodes[rtp->nr - 1] = NULL;
-			rtp->nr--;
-		}
+	rtp = &__get_cpu_var(radix_tree_preloads);
+	if (rtp->nr) {
+		struct radix_tree_node *ret;
+		ret = rtp->nodes[rtp->nr - 1];
+		rtp->nodes[rtp->nr - 1] = NULL;
+		rtp->nr--;
+		return ret;
 	}
-	return ret;
+
+	return kmem_cache_alloc(radix_tree_node_cachep, root->gfp_mask);
 }
 
 static inline void

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux