Skip to contentSkip to conversation

lib-rbtree-enable-userland-test-suite-for-rbtree-related-data-structure.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Mar 17, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: lib/rbtree: enable userland test suite for rbtree related data structure
has been removed from the -mm tree. Its filename was
lib-rbtree-enable-userland-test-suite-for-rbtree-related-data-structure.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Wei Yang <[email protected]>
Subject: lib/rbtree: enable userland test suite for rbtree related data structure
Date: Mon, 10 Mar 2025 07:49:32 +0000

Patch series "lib/interval_tree: add some test cases and cleanup", v2.

Since rbtree/augmented tree/interval tree share similar data structure, besides new cases for interval tree, this patch set also does cleanup for others.

This patch (of 7):

Currently we have some tests for rbtree related data structure, e.g. rbtree, augmented rbtree, interval tree, in lib/ as kernel module.

To facilitate the test and debug for those fundamental data structure, this patch enable those tests in userland.

---

 tools/include/asm/timex.h                          |   13 ++
 tools/include/linux/container_of.h                 |   18 +++
 tools/include/linux/kernel.h                       |   14 --
 tools/include/linux/math64.h                       |    5 +
 tools/include/linux/moduleparam.h                  |    7 +
 tools/include/linux/prandom.h                      |   51 ++++++++++
 tools/include/linux/slab.h                         |    1 
 tools/lib/slab.c                                   |   16 +++
 tools/testing/rbtree/Makefile                      |   31 ++++++
 tools/testing/rbtree/interval_tree_test.c          |   53 +++++++++++
 tools/testing/rbtree/rbtree_test.c                 |   45 +++++++++
 tools/testing/rbtree/test.h                        |    4 
 tools/testing/shared/interval_tree-shim.c          |    5 +
 tools/testing/shared/linux/interval_tree.h         |    7 +
 tools/testing/shared/linux/interval_tree_generic.h |    2 
 tools/testing/shared/linux/rbtree.h                |    8 +
 tools/testing/shared/linux/rbtree_augmented.h      |    7 +
 tools/testing/shared/linux/rbtree_types.h          |    8 +
 tools/testing/shared/rbtree-shim.c                 |    6 +
 19 files changed, 288 insertions(+), 13 deletions(-)
tools/include/asm/timex.h new file +13 -0
new file mode 100644
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __TOOLS_LINUX_ASM_TIMEX_H
+#define __TOOLS_LINUX_ASM_TIMEX_H
+
+#include <time.h>
+
+#define cycles_t clock_t
+
+static inline cycles_t get_cycles(void)
+{
+	return clock();
+}
+#endif // __TOOLS_LINUX_ASM_TIMEX_H
tools/include/linux/container_of.h new file +18 -0
new file mode 100644
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TOOLS_LINUX_CONTAINER_OF_H
+#define _TOOLS_LINUX_CONTAINER_OF_H
+
+#ifndef container_of
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr:	the pointer to the member.
+ * @type:	the type of the container struct this is embedded in.
+ * @member:	the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({			\
+	const typeof(((type *)0)->member) * __mptr = (ptr);	\
+	(type *)((char *)__mptr - offsetof(type, member)); })
+#endif
+
+#endif	/* _TOOLS_LINUX_CONTAINER_OF_H */
tools/include/linux/kernel.h renamed from tools/include/linux/kernel.h~lib-rbtree-enable-userland-test-suite-for-rbtree-related-data-structure +1 -13
@@ -11,6 +11,7 @@
 #include <linux/panic.h>
 #include <endian.h>
 #include <byteswap.h>
+#include <linux/container_of.h>
 
 #ifndef UINT_MAX
 #define UINT_MAX	(~0U)
@@ -25,19 +26,6 @@
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 #endif
 
-#ifndef container_of
-/**
- * container_of - cast a member of a structure out to the containing structure
- * @ptr:	the pointer to the member.
- * @type:	the type of the container struct this is embedded in.
- * @member:	the name of the member within the struct.
- *
- */
-#define container_of(ptr, type, member) ({			\
-	const typeof(((type *)0)->member) * __mptr = (ptr);	\
-	(type *)((char *)__mptr - offsetof(type, member)); })
-#endif
-
 #ifndef max
 #define max(x, y) ({				\
 	typeof(x) _max1 = (x);			\
tools/include/linux/math64.h renamed from tools/include/linux/math64.h~lib-rbtree-enable-userland-test-suite-for-rbtree-related-data-structure +5 -0
@@ -72,4 +72,9 @@ static inline u64 mul_u64_u64_div64(u64
 }
 #endif
 
+static inline u64 div_u64(u64 dividend, u32 divisor)
+{
+	return dividend / divisor;
+}
+
 #endif /* _LINUX_MATH64_H */
tools/include/linux/moduleparam.h new file +7 -0
new file mode 100644
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TOOLS_LINUX_MODULE_PARAMS_H
+#define _TOOLS_LINUX_MODULE_PARAMS_H
+
+#define MODULE_PARM_DESC(parm, desc)
+
+#endif // _TOOLS_LINUX_MODULE_PARAMS_H
tools/include/linux/prandom.h new file +51 -0

51 lines not on this page · raw message

tools/include/linux/slab.h renamed from tools/include/linux/slab.h~lib-rbtree-enable-userland-test-suite-for-rbtree-related-data-structure +1 -0
@@ -12,6 +12,7 @@
 
 void *kmalloc(size_t size, gfp_t gfp);
 void kfree(void *p);
+void *kmalloc_array(size_t n, size_t size, gfp_t gfp);
 
 bool slab_is_available(void);
 
tools/lib/slab.c renamed from tools/lib/slab.c~lib-rbtree-enable-userland-test-suite-for-rbtree-related-data-structure +16 -0
@@ -36,3 +36,19 @@ void kfree(void *p)
 		printf("Freeing %p to malloc\n", p);
 	free(p);
 }
+
+void *kmalloc_array(size_t n, size_t size, gfp_t gfp)
+{
+	void *ret;
+
+	if (!(gfp & __GFP_DIRECT_RECLAIM))
+		return NULL;
+
+	ret = calloc(n, size);
+	uatomic_inc(&kmalloc_nr_allocated);
+	if (kmalloc_verbose)
+		printf("Allocating %p from calloc\n", ret);
+	if (gfp & __GFP_ZERO)
+		memset(ret, 0, n * size);
+	return ret;
+}
tools/testing/rbtree/interval_tree_test.c new file +53 -0

53 lines not on this page · raw message

tools/testing/rbtree/Makefile new file +31 -0
new file mode 100644
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: GPL-2.0
+
+.PHONY: clean
+
+TARGETS = rbtree_test interval_tree_test
+OFILES = $(LIBS) rbtree-shim.o interval_tree-shim.o
+DEPS = ../../../include/linux/rbtree.h \
+	../../../include/linux/rbtree_types.h \
+	../../../include/linux/rbtree_augmented.h \
+	../../../include/linux/interval_tree.h \
+	../../../include/linux/interval_tree_generic.h \
+	../../../lib/rbtree.c \
+	../../../lib/interval_tree.c
+
+targets: $(TARGETS)
+
+include ../shared/shared.mk
+
+ifeq ($(DEBUG), 1)
+	CFLAGS += -g
+endif
+
+$(TARGETS):	$(OFILES)
+
+rbtree-shim.o: $(DEPS)
+rbtree_test.o:  ../../../lib/rbtree_test.c
+interval_tree-shim.o: $(DEPS)
+interval_tree_test.o: 	../../../lib/interval_tree_test.c
+
+clean:
+	$(RM) $(TARGETS) *.o generated/*
tools/testing/rbtree/rbtree_test.c new file +45 -0

45 lines not on this page · raw message

tools/testing/rbtree/test.h new file +4 -0
new file mode 100644
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+void rbtree_tests(void);
+void interval_tree_tests(void);
tools/testing/shared/interval_tree-shim.c new file +5 -0
new file mode 100644
@@ -0,0 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/* Very simple shim around the interval tree. */
+
+#include "../../../lib/interval_tree.c"
tools/testing/shared/linux/interval_tree_generic.h new file +2 -0
new file mode 100644
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#include "../../../../include/linux/interval_tree_generic.h"
tools/testing/shared/linux/interval_tree.h new file +7 -0
new file mode 100644
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TEST_INTERVAL_TREE_H
+#define _TEST_INTERVAL_TREE_H
+
+#include "../../../../include/linux/interval_tree.h"
+
+#endif /* _TEST_INTERVAL_TREE_H */
tools/testing/shared/linux/rbtree_augmented.h new file +7 -0
new file mode 100644
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TEST_RBTREE_AUGMENTED_H
+#define _TEST_RBTREE_AUGMENTED_H
+
+#include "../../../../include/linux/rbtree_augmented.h"
+
+#endif /* _TEST_RBTREE_AUGMENTED_H */
tools/testing/shared/linux/rbtree.h new file +8 -0
new file mode 100644
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TEST_RBTREE_H
+#define _TEST_RBTREE_H
+
+#include <linux/kernel.h>
+#include "../../../../include/linux/rbtree.h"
+
+#endif /* _TEST_RBTREE_H */
tools/testing/shared/linux/rbtree_types.h new file +8 -0
new file mode 100644
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TEST_RBTREE_TYPES_H
+#define _TEST_RBTREE_TYPES_H
+
+#include "../../../../include/linux/rbtree_types.h"
+
+#endif /* _TEST_RBTREE_TYPES_H */
+
tools/testing/shared/rbtree-shim.c new file +6 -0
new file mode 100644
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/* Very simple shim around the rbtree. */
+
+#include "../../../lib/rbtree.c"
+

_

Patches currently in -mm which might be from [email protected] are