diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/radix-tree/linux.c | 11 | ||||
-rw-r--r-- | tools/testing/radix-tree/linux/compiler_types.h | 0 | ||||
-rw-r--r-- | tools/testing/radix-tree/linux/gfp.h | 1 | ||||
-rw-r--r-- | tools/testing/radix-tree/linux/slab.h | 6 |
4 files changed, 16 insertions, 2 deletions
diff --git a/tools/testing/radix-tree/linux.c b/tools/testing/radix-tree/linux.c index 6903ccf35595..44a0d1ad4408 100644 --- a/tools/testing/radix-tree/linux.c +++ b/tools/testing/radix-tree/linux.c | |||
@@ -29,7 +29,7 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, int flags) | |||
29 | { | 29 | { |
30 | struct radix_tree_node *node; | 30 | struct radix_tree_node *node; |
31 | 31 | ||
32 | if (flags & __GFP_NOWARN) | 32 | if (!(flags & __GFP_DIRECT_RECLAIM)) |
33 | return NULL; | 33 | return NULL; |
34 | 34 | ||
35 | pthread_mutex_lock(&cachep->lock); | 35 | pthread_mutex_lock(&cachep->lock); |
@@ -73,10 +73,17 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp) | |||
73 | 73 | ||
74 | void *kmalloc(size_t size, gfp_t gfp) | 74 | void *kmalloc(size_t size, gfp_t gfp) |
75 | { | 75 | { |
76 | void *ret = malloc(size); | 76 | void *ret; |
77 | |||
78 | if (!(gfp & __GFP_DIRECT_RECLAIM)) | ||
79 | return NULL; | ||
80 | |||
81 | ret = malloc(size); | ||
77 | uatomic_inc(&nr_allocated); | 82 | uatomic_inc(&nr_allocated); |
78 | if (kmalloc_verbose) | 83 | if (kmalloc_verbose) |
79 | printf("Allocating %p from malloc\n", ret); | 84 | printf("Allocating %p from malloc\n", ret); |
85 | if (gfp & __GFP_ZERO) | ||
86 | memset(ret, 0, size); | ||
80 | return ret; | 87 | return ret; |
81 | } | 88 | } |
82 | 89 | ||
diff --git a/tools/testing/radix-tree/linux/compiler_types.h b/tools/testing/radix-tree/linux/compiler_types.h new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/tools/testing/radix-tree/linux/compiler_types.h | |||
diff --git a/tools/testing/radix-tree/linux/gfp.h b/tools/testing/radix-tree/linux/gfp.h index e9fff59dfd8a..e3201ccf54c3 100644 --- a/tools/testing/radix-tree/linux/gfp.h +++ b/tools/testing/radix-tree/linux/gfp.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #define __GFP_IO 0x40u | 11 | #define __GFP_IO 0x40u |
12 | #define __GFP_FS 0x80u | 12 | #define __GFP_FS 0x80u |
13 | #define __GFP_NOWARN 0x200u | 13 | #define __GFP_NOWARN 0x200u |
14 | #define __GFP_ZERO 0x8000u | ||
14 | #define __GFP_ATOMIC 0x80000u | 15 | #define __GFP_ATOMIC 0x80000u |
15 | #define __GFP_ACCOUNT 0x100000u | 16 | #define __GFP_ACCOUNT 0x100000u |
16 | #define __GFP_DIRECT_RECLAIM 0x400000u | 17 | #define __GFP_DIRECT_RECLAIM 0x400000u |
diff --git a/tools/testing/radix-tree/linux/slab.h b/tools/testing/radix-tree/linux/slab.h index 979baeec7e70..a037def0dec6 100644 --- a/tools/testing/radix-tree/linux/slab.h +++ b/tools/testing/radix-tree/linux/slab.h | |||
@@ -3,6 +3,7 @@ | |||
3 | #define SLAB_H | 3 | #define SLAB_H |
4 | 4 | ||
5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | #include <linux/gfp.h> | ||
6 | 7 | ||
7 | #define SLAB_HWCACHE_ALIGN 1 | 8 | #define SLAB_HWCACHE_ALIGN 1 |
8 | #define SLAB_PANIC 2 | 9 | #define SLAB_PANIC 2 |
@@ -11,6 +12,11 @@ | |||
11 | void *kmalloc(size_t size, gfp_t); | 12 | void *kmalloc(size_t size, gfp_t); |
12 | void kfree(void *); | 13 | void kfree(void *); |
13 | 14 | ||
15 | static inline void *kzalloc(size_t size, gfp_t gfp) | ||
16 | { | ||
17 | return kmalloc(size, gfp | __GFP_ZERO); | ||
18 | } | ||
19 | |||
14 | void *kmem_cache_alloc(struct kmem_cache *cachep, int flags); | 20 | void *kmem_cache_alloc(struct kmem_cache *cachep, int flags); |
15 | void kmem_cache_free(struct kmem_cache *cachep, void *objp); | 21 | void kmem_cache_free(struct kmem_cache *cachep, void *objp); |
16 | 22 | ||