Skip to content

Commit 3d4d5d6

Browse files
author
Matthew Wilcox
committed
radix tree test suite: Fix build
- Add an empty linux/compiler_types.h (now being included by kconfig.h) - Add __GFP_ZERO - Add kzalloc - Test __GFP_DIRECT_RECLAIM instead of __GFP_NOWARN Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
1 parent 3664ce2 commit 3d4d5d6

4 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎tools/testing/radix-tree/linux.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, int flags)
2929
{
3030
struct radix_tree_node *node;
3131

32-
if (flags & __GFP_NOWARN)
32+
if (!(flags & __GFP_DIRECT_RECLAIM))
3333
return NULL;
3434

3535
pthread_mutex_lock(&cachep->lock);
@@ -73,10 +73,17 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp)
7373

7474
void *kmalloc(size_t size, gfp_t gfp)
7575
{
76-
void *ret = malloc(size);
76+
void *ret;
77+
78+
if (!(gfp & __GFP_DIRECT_RECLAIM))
79+
return NULL;
80+
81+
ret = malloc(size);
7782
uatomic_inc(&nr_allocated);
7883
if (kmalloc_verbose)
7984
printf("Allocating %p from malloc\n", ret);
85+
if (gfp & __GFP_ZERO)
86+
memset(ret, 0, size);
8087
return ret;
8188
}
8289

‎tools/testing/radix-tree/linux/compiler_types.h‎

Whitespace-only changes.

‎tools/testing/radix-tree/linux/gfp.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define __GFP_IO 0x40u
1212
#define __GFP_FS 0x80u
1313
#define __GFP_NOWARN 0x200u
14+
#define __GFP_ZERO 0x8000u
1415
#define __GFP_ATOMIC 0x80000u
1516
#define __GFP_ACCOUNT 0x100000u
1617
#define __GFP_DIRECT_RECLAIM 0x400000u

‎tools/testing/radix-tree/linux/slab.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define SLAB_H
44

55
#include <linux/types.h>
6+
#include <linux/gfp.h>
67

78
#define SLAB_HWCACHE_ALIGN 1
89
#define SLAB_PANIC 2
@@ -11,6 +12,11 @@
1112
void *kmalloc(size_t size, gfp_t);
1213
void kfree(void *);
1314

15+
static inline void *kzalloc(size_t size, gfp_t gfp)
16+
{
17+
return kmalloc(size, gfp | __GFP_ZERO);
18+
}
19+
1420
void *kmem_cache_alloc(struct kmem_cache *cachep, int flags);
1521
void kmem_cache_free(struct kmem_cache *cachep, void *objp);
1622

0 commit comments

Comments
 (0)