]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
radix tree test suite: Enhancements for Maple Tree
authorLiam Howlett <Liam.Howlett@oracle.com>
Thu, 27 Feb 2020 20:13:20 +0000 (15:13 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 23 Jul 2020 01:51:07 +0000 (21:51 -0400)
Signed-off-by: Liam Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
tools/testing/radix-tree/linux.c
tools/testing/radix-tree/linux/kernel.h

index 2d9c59df60de03be87fc92a5482b7c3eb17a4463..93f7de81fbe87b61bd67a2066584198cafabc31a 100644 (file)
@@ -24,15 +24,28 @@ 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;
+}
+
+unsigned long kmem_cache_get_alloc(struct kmem_cache *cachep)
+{
+       return cachep->size * nr_allocated;
+}
 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;
@@ -116,5 +129,6 @@ kmem_cache_create(const char *name, unsigned int size, unsigned int align,
        ret->nr_objs = 0;
        ret->objs = NULL;
        ret->ctor = ctor;
+       ret->non_kernel = 0;
        return ret;
 }
index 39867fd80c8faa7db47dd070f7f71d99faa58dd0..c5c9d05f29da95e4b7d0b462675fde9dcc028924 100644 (file)
@@ -14,6 +14,7 @@
 #include "../../../include/linux/kconfig.h"
 
 #define printk printf
+#define pr_err printk
 #define pr_info printk
 #define pr_debug printk
 #define pr_cont printk