From: Liam R. Howlett Date: Thu, 10 Jan 2019 19:06:51 +0000 (-0500) Subject: test_maple_tree: Add new function to allow __GFP_DIRECT_RECLAIM gfp for X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=32c3d894a540764a021c3b9f0928ed6c9d20da23;p=users%2Fjedix%2Flinux-maple.git test_maple_tree: Add new function to allow __GFP_DIRECT_RECLAIM gfp for a given number of times. Set a variable that allows reclaims to occur for a specific count for testing. Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index e2586362caaa..79c86ce57544 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -937,4 +937,8 @@ void mt_dump(const struct maple_tree *mt) else mt_dump_node(entry, 0, mt_max[mt_node_type(entry)], 0); } +void mt_set_non_kernel(unsigned int val) +{ + kmem_cache_set_non_kernel(maple_node_cache, val); +} #endif diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index b3dbdcd51db2..922cf0b0b2ad 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -322,8 +322,10 @@ static int maple_tree_seed(void) check_load(&tree, set[1], &tree); check_load(&tree, set[2], ptr); check_load(&tree, set[3], &tree); + mt_set_non_kernel(1); check_erase(&tree, set[1]); check_load(&tree, set[1], NULL); + return 0; check_insert(&tree, set[4], ptr); // 1000 < Should split. check_load(&tree, set[0], ptr); diff --git a/tools/testing/radix-tree/linux.c b/tools/testing/radix-tree/linux.c index 4128aab15b13..62bf900413a9 100644 --- a/tools/testing/radix-tree/linux.c +++ b/tools/testing/radix-tree/linux.c @@ -24,15 +24,24 @@ struct kmem_cache { int nr_objs; void *objs; void (*ctor)(void *); + unsigned int non_kernel; }; +void kmem_cache_set_non_kernel(struct kmem_cache *cachep, unsigned int val) +{ + cachep->non_kernel = val; +} + void *kmem_cache_alloc(struct kmem_cache *cachep, int gfp) { void *p; - if (!(gfp & __GFP_DIRECT_RECLAIM)) + if (!(gfp & __GFP_DIRECT_RECLAIM) && !cachep->non_kernel) return NULL; + if (!(gfp & __GFP_DIRECT_RECLAIM)) + cachep->non_kernel--; + pthread_mutex_lock(&cachep->lock); if (cachep->nr_objs) { struct radix_tree_node *node = cachep->objs;