aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@linux.intel.com>2016-12-14 18:09:25 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-14 19:04:10 -0500
commitde1af8f62a78ea8abcc2dddb6de622e4069a368e (patch)
treea1a43b87398e8356e489a7fa55c23f300e0c76c8
parent424251a4a929a1b6dff2056d49135e3805132e32 (diff)
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/1480369871-5271-67-git-send-email-mawilcox@linuxonhyperv.com Signed-off-by: Matthew Wilcox <willy@linux.intel.com> Tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Konstantin Khlebnikov <koct9i@gmail.com> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: Matthew Wilcox <mawilcox@microsoft.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--tools/testing/radix-tree/linux.c15
-rw-r--r--tools/testing/radix-tree/linux/kernel.h3
-rw-r--r--tools/testing/radix-tree/linux/slab.h3
3 files changed, 21 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)
54 free(objp); 54 free(objp);
55} 55}
56 56
57void *kmalloc(size_t size, gfp_t gfp)
58{
59 void *ret = malloc(size);
60 uatomic_inc(&nr_allocated);
61 return ret;
62}
63
64void kfree(void *p)
65{
66 if (!p)
67 return;
68 uatomic_dec(&nr_allocated);
69 free(p);
70}
71
57struct kmem_cache * 72struct kmem_cache *
58kmem_cache_create(const char *name, size_t size, size_t offset, 73kmem_cache_create(const char *name, size_t size, size_t offset,
59 unsigned long flags, void (*ctor)(void *)) 74 unsigned long flags, void (*ctor)(void *))
diff --git a/tools/testing/radix-tree/linux/kernel.h b/tools/testing/radix-tree/linux/kernel.h
index 23e77f5673ce..9b43b4975d83 100644
--- a/tools/testing/radix-tree/linux/kernel.h
+++ b/tools/testing/radix-tree/linux/kernel.h
@@ -8,6 +8,7 @@
8#include <limits.h> 8#include <limits.h>
9 9
10#include "../../include/linux/compiler.h" 10#include "../../include/linux/compiler.h"
11#include "../../include/linux/err.h"
11#include "../../../include/linux/kconfig.h" 12#include "../../../include/linux/kconfig.h"
12 13
13#ifdef BENCHMARK 14#ifdef BENCHMARK
@@ -58,4 +59,6 @@ static inline int in_interrupt(void)
58#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) 59#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
59#define round_down(x, y) ((x) & ~__round_mask(x, y)) 60#define round_down(x, y) ((x) & ~__round_mask(x, y))
60 61
62#define xchg(ptr, x) uatomic_xchg(ptr, x)
63
61#endif /* _KERNEL_H */ 64#endif /* _KERNEL_H */
diff --git a/tools/testing/radix-tree/linux/slab.h b/tools/testing/radix-tree/linux/slab.h
index 452e2bf502e3..446639f78fc1 100644
--- a/tools/testing/radix-tree/linux/slab.h
+++ b/tools/testing/radix-tree/linux/slab.h
@@ -7,6 +7,9 @@
7#define SLAB_PANIC 2 7#define SLAB_PANIC 2
8#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */ 8#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */
9 9
10void *kmalloc(size_t size, gfp_t);
11void kfree(void *);
12
10struct kmem_cache { 13struct kmem_cache {
11 int size; 14 int size;
12 void (*ctor)(void *); 15 void (*ctor)(void *);