[PATCH] tools: Add SLUB percpu array functions for testing
From: Liam R. Howlett
Date: Tue Aug 08 2023 - 14:58:13 EST
Support new percpu array functions to the test code so they can be used
in the maple tree testing.
Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx>
---
tools/include/linux/slab.h | 4 ++++
tools/testing/radix-tree/linux.c | 14 ++++++++++++++
tools/testing/radix-tree/linux/kernel.h | 1 +
3 files changed, 19 insertions(+)
diff --git a/tools/include/linux/slab.h b/tools/include/linux/slab.h
index 311759ea25e9..1043f9c5ef4e 100644
--- a/tools/include/linux/slab.h
+++ b/tools/include/linux/slab.h
@@ -7,6 +7,7 @@
=20
#define SLAB_PANIC 2
#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are rec=
laimable */
+#define SLAB_NO_MERGE 0x01000000UL /* Prevent merging with compatible km=
em caches */
=20
#define kzalloc_node(size, flags, node) kmalloc(size, flags)
=20
@@ -45,4 +46,7 @@ void kmem_cache_free_bulk(struct kmem_cache *cachep, size=
_t size, void **list);
int kmem_cache_alloc_bulk(struct kmem_cache *cachep, gfp_t gfp, size_t siz=
e,
void **list);
=20
+int kmem_cache_setup_percpu_array(struct kmem_cache *s, unsigned int count=
);
+int kmem_cache_prefill_percpu_array(struct kmem_cache *s, unsigned int cou=
nt,
+ gfp_t gfp);
#endif /* _TOOLS_SLAB_H */
diff --git a/tools/testing/radix-tree/linux.c b/tools/testing/radix-tree/li=
nux.c
index d587a558997f..cbe7937fdd5e 100644
--- a/tools/testing/radix-tree/linux.c
+++ b/tools/testing/radix-tree/linux.c
@@ -187,6 +187,20 @@ int kmem_cache_alloc_bulk(struct kmem_cache *cachep, g=
fp_t gfp, size_t size,
return size;
}
=20
+int kmem_cache_setup_percpu_array(struct kmem_cache *s, unsigned int count=
)
+{
+ return 0;
+}
+
+int kmem_cache_prefill_percpu_array(struct kmem_cache *s, unsigned int cou=
nt,
+ gfp_t gfp)
+{
+ if (count > s->non_kernel)
+ return s->non_kernel;
+
+ return count;
+}
+
struct kmem_cache *
kmem_cache_create(const char *name, unsigned int size, unsigned int align,
unsigned int flags, void (*ctor)(void *))
diff --git a/tools/testing/radix-tree/linux/kernel.h b/tools/testing/radix-=
tree/linux/kernel.h
index c5c9d05f29da..fc75018974de 100644
--- a/tools/testing/radix-tree/linux/kernel.h
+++ b/tools/testing/radix-tree/linux/kernel.h
@@ -15,6 +15,7 @@
=20
#define printk printf
#define pr_err printk
+#define pr_warn printk
#define pr_info printk
#define pr_debug printk
#define pr_cont printk
--=20
2.39.2
--yvvp2yzdjcas7lni--