aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/radix-tree/linux.c
diff options
context:
space:
mode:
authorMatthew Wilcox <[email protected]>2016-12-14 23:09:25 +0000
committerLinus Torvalds <[email protected]>2016-12-15 00:04:10 +0000
commitde1af8f62a78ea8abcc2dddb6de622e4069a368e (patch)
treea1a43b87398e8356e489a7fa55c23f300e0c76c8 /tools/testing/radix-tree/linux.c
parentidr: reduce the number of bits per level from 8 to 6 (diff)
downloadkernel-de1af8f62a78ea8abcc2dddb6de622e4069a368e.tar.gz
kernel-de1af8f62a78ea8abcc2dddb6de622e4069a368e.zip
radix tree test suite: add some more functionality
IDR needs more functionality from the kernel: kmalloc()/kfree(), and xchg(). Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox <[email protected]> Tested-by: Kirill A. Shutemov <[email protected]> Cc: Konstantin Khlebnikov <[email protected]> Cc: Ross Zwisler <[email protected]> Cc: Matthew Wilcox <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'tools/testing/radix-tree/linux.c')
-rw-r--r--tools/testing/radix-tree/linux.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/testing/radix-tree/linux.c b/tools/testing/radix-tree/linux.c
index 1f32a16a3848..ff0452e8a0c4 100644
--- a/tools/testing/radix-tree/linux.c
+++ b/tools/testing/radix-tree/linux.c
@@ -54,6 +54,21 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp)
free(objp);
}
+void *kmalloc(size_t size, gfp_t gfp)
+{
+ void *ret = malloc(size);
+ uatomic_inc(&nr_allocated);
+ return ret;
+}
+
+void kfree(void *p)
+{
+ if (!p)
+ return;
+ uatomic_dec(&nr_allocated);
+ free(p);
+}
+
struct kmem_cache *
kmem_cache_create(const char *name, size_t size, size_t offset,
unsigned long flags, void (*ctor)(void *))