]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Fix atomics
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 29 Jan 2021 15:11:11 +0000 (10:11 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 29 Jan 2021 15:11:11 +0000 (10:11 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
include/linux/maple_tree.h
lib/maple_tree.c
tools/testing/radix-tree/linux/maple_tree.h

index 142bdea3bfbcfb9192b5be1142e9fe2505655729..de8e1a2b0d825e616adc6648a3ab6461df0de9c1 100644 (file)
@@ -257,8 +257,8 @@ void *mas_prev(struct ma_state *mas, unsigned long min);
 void *mas_next(struct ma_state *mas, unsigned long max);
 
 /* Finds a sufficient hole */
-int mas_get_empty_area(struct ma_state *mas, unsigned long min,
-               unsigned long max, unsigned long size);
+int mas_empty_area(struct ma_state *mas, unsigned long min, unsigned long max,
+                  unsigned long size);
 
 /* Checks if a mas has not found anything */
 static inline bool mas_is_none(struct ma_state *mas)
@@ -271,8 +271,8 @@ void mas_dup_store(struct ma_state *mas, void *entry);
 /* This finds an empty area from the highest address to the lowest.
  * AKA "Topdown" version,
  */
-int mas_get_empty_area_rev(struct ma_state *mas, unsigned long min,
-               unsigned long max, unsigned long size);
+int mas_empty_area_rev(struct ma_state *mas, unsigned long min,
+                      unsigned long max, unsigned long size);
 /**
  * mas_reset() - Reset a Maple Tree operation state.
  * @mas: Maple Tree operation state.
@@ -415,21 +415,22 @@ void *_mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max,
 
 
 #ifdef CONFIG_DEBUG_MAPLE_TREE
-extern unsigned int maple_tree_tests_run;
-extern unsigned int maple_tree_tests_passed;
+extern atomic_t maple_tree_tests_run;
+extern atomic_t maple_tree_tests_passed;
 
 void mt_dump(const struct maple_tree *mt);
 #define MT_BUG_ON(tree, x) do {                                                \
-       uatomic_inc(&maple_tree_tests_run);                             \
+       atomic_inc(&maple_tree_tests_run);                              \
        if (x) {                                                        \
                pr_info("BUG at %s:%d (%u)\n",                          \
                __func__, __LINE__, x);                                 \
                mt_dump(tree);                                          \
-               pr_info("Pass: %u Run:%u\n", maple_tree_tests_passed,   \
-                       maple_tree_tests_run);                          \
+               pr_info("Pass: %u Run:%u\n",                            \
+                       atomic_read(&maple_tree_tests_passed),          \
+                       atomic_read(&maple_tree_tests_run));            \
                dump_stack();                                           \
        } else {                                                        \
-               uatomic_inc(&maple_tree_tests_passed);                  \
+               atomic_inc(&maple_tree_tests_passed);                   \
        }                                                               \
 } while (0)
 #else
index b529bff1c1ad86c929ed333b4a8a811f18e73fd3..36655edced526ef6c4eeba7e146131fc048a0a78 100644 (file)
@@ -5816,9 +5816,9 @@ void *mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max)
 EXPORT_SYMBOL(mt_find);
 
 #ifdef CONFIG_DEBUG_MAPLE_TREE
-unsigned int maple_tree_tests_run;
+atomic_t maple_tree_tests_run;
 EXPORT_SYMBOL_GPL(maple_tree_tests_run);
-unsigned int maple_tree_tests_passed;
+atomic_t maple_tree_tests_passed;
 EXPORT_SYMBOL_GPL(maple_tree_tests_passed);
 
 #ifndef __KERNEL__
@@ -5833,6 +5833,7 @@ unsigned long mt_get_alloc_size(void)
 {
        return kmem_cache_get_alloc(maple_node_cache);
 }
+
 #define MA_PTR "%p"
 #else // __KERNEL__ is defined.
 #define MA_PTR "%px"
index 993ac3c3026f7b5138403b098c8c485dcde64f3c..89f561e68841e7038797577473df9a327fef1756 100644 (file)
@@ -1,3 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
+#define atomic_t int32_t
 #include "../../../../include/linux/maple_tree.h"
+#define atomic_inc(x) uatomic_inc(x)
+#define atomic_read(x) uatomic_read(x)
+#define atomic_set(x, y) do {} while(0)
 #define U8_MAX UCHAR_MAX