Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Matthew Wilcox and committed by
Linus Torvalds
de1af8f6 424251a4

+21
+15
tools/testing/radix-tree/linux.c
··· 54 54 free(objp); 55 55 } 56 56 57 + void *kmalloc(size_t size, gfp_t gfp) 58 + { 59 + void *ret = malloc(size); 60 + uatomic_inc(&nr_allocated); 61 + return ret; 62 + } 63 + 64 + void kfree(void *p) 65 + { 66 + if (!p) 67 + return; 68 + uatomic_dec(&nr_allocated); 69 + free(p); 70 + } 71 + 57 72 struct kmem_cache * 58 73 kmem_cache_create(const char *name, size_t size, size_t offset, 59 74 unsigned long flags, void (*ctor)(void *))
+3
tools/testing/radix-tree/linux/kernel.h
··· 8 8 #include <limits.h> 9 9 10 10 #include "../../include/linux/compiler.h" 11 + #include "../../include/linux/err.h" 11 12 #include "../../../include/linux/kconfig.h" 12 13 13 14 #ifdef BENCHMARK ··· 58 57 #define __round_mask(x, y) ((__typeof__(x))((y)-1)) 59 58 #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) 60 59 #define round_down(x, y) ((x) & ~__round_mask(x, y)) 60 + 61 + #define xchg(ptr, x) uatomic_xchg(ptr, x) 61 62 62 63 #endif /* _KERNEL_H */
+3
tools/testing/radix-tree/linux/slab.h
··· 7 7 #define SLAB_PANIC 2 8 8 #define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */ 9 9 10 + void *kmalloc(size_t size, gfp_t); 11 + void kfree(void *); 12 + 10 13 struct kmem_cache { 11 14 int size; 12 15 void (*ctor)(void *);