aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/radix-tree/linux.c
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2017-01-16 16:41:29 -0500
committerMatthew Wilcox <mawilcox@microsoft.com>2017-02-13 21:44:04 -0500
commit1293d5c5f54d5118fbb34fc94e01ba02fcd25fc1 (patch)
treed2ff3550817eb4110766b56e4a2032e8502a0b33 /tools/testing/radix-tree/linux.c
parent73bc029b76482260a144219786d19951f561716e (diff)
radix-tree: Chain preallocated nodes through ->parent
Chaining through the ->private_data member means we have to zero ->private_data after removing preallocated nodes from the list. We're about to initialise ->parent anyway, so we can avoid zeroing it. Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Diffstat (limited to 'tools/testing/radix-tree/linux.c')
-rw-r--r--tools/testing/radix-tree/linux.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/testing/radix-tree/linux.c b/tools/testing/radix-tree/linux.c
index 94bcdb992bbf..cf48c8473f48 100644
--- a/tools/testing/radix-tree/linux.c
+++ b/tools/testing/radix-tree/linux.c
@@ -35,9 +35,9 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, int flags)
35 if (cachep->nr_objs) { 35 if (cachep->nr_objs) {
36 cachep->nr_objs--; 36 cachep->nr_objs--;
37 node = cachep->objs; 37 node = cachep->objs;
38 cachep->objs = node->private_data; 38 cachep->objs = node->parent;
39 pthread_mutex_unlock(&cachep->lock); 39 pthread_mutex_unlock(&cachep->lock);
40 node->private_data = NULL; 40 node->parent = NULL;
41 } else { 41 } else {
42 pthread_mutex_unlock(&cachep->lock); 42 pthread_mutex_unlock(&cachep->lock);
43 node = malloc(cachep->size); 43 node = malloc(cachep->size);
@@ -64,7 +64,7 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp)
64 } else { 64 } else {
65 struct radix_tree_node *node = objp; 65 struct radix_tree_node *node = objp;
66 cachep->nr_objs++; 66 cachep->nr_objs++;
67 node->private_data = cachep->objs; 67 node->parent = cachep->objs;
68 cachep->objs = node; 68 cachep->objs = node;
69 } 69 }
70 pthread_mutex_unlock(&cachep->lock); 70 pthread_mutex_unlock(&cachep->lock);