@@ -242,7 +242,7 @@ void eytzinger0_sort(void *base, size_t n, size_t size,
return eytzinger0_sort_r(base, n, size, _CMP_WRAPPER, SWAP_WRAPPER, &w);
}
-#if 0
+#if 1
#include <linux/slab.h>
#include <linux/random.h>
#include <linux/ktime.h>
@@ -263,7 +263,7 @@ static int mycmp(const void *a, const void *b)
return 0;
}
-static int test(void)
+void eytzinger_sort_test(void)
{
size_t N, i;
ktime_t start, end;
@@ -288,17 +288,11 @@ static int test(void)
u32 prev = 0;
eytzinger0_for_each(i, N) {
- if (prev > arr[i])
- goto err;
+ BUG_ON(prev > arr[i]);
prev = arr[i];
}
kfree(arr);
}
- return 0;
-
-err:
- kfree(arr);
- return -1;
}
#endif
@@ -5,6 +5,8 @@
#include <linux/bitops.h>
#include <linux/log2.h>
+#define EYTZINGER_DEBUG
+
#ifdef EYTZINGER_DEBUG
#define EYTZINGER_BUG_ON(cond) BUG_ON(cond)
#else
@@ -316,4 +318,6 @@ void eytzinger0_sort_r(void *, size_t, size_t,
cmp_r_func_t, swap_r_func_t, const void *);
void eytzinger0_sort(void *, size_t, size_t, cmp_func_t, swap_func_t);
+void eytzinger_sort_test(void);
+
#endif /* _EYTZINGER_H */
@@ -2120,6 +2120,11 @@ static int __init bcachefs_init(void)
{
bch2_bkey_pack_test();
+ eytzinger_sort_test();
+ eytzinger1_test();
+ eytzinger0_test();
+ eytzinger0_find_test();
+
if (!(bcachefs_kset = kset_create_and_add("bcachefs", NULL, fs_kobj)) ||
bch2_btree_key_cache_init() ||
bch2_chardev_init() ||
@@ -698,7 +698,7 @@ void memcpy_from_bio(void *dst, struct bio *src, struct bvec_iter src_iter)
}
}
-#if 0
+#if 1
void eytzinger1_test(void)
{
unsigned inorder, eytz, size;
@@ -696,4 +696,8 @@ static inline bool test_bit_le64(size_t bit, __le64 *addr)
return (addr[bit / 64] & cpu_to_le64(BIT_ULL(bit % 64))) != 0;
}
+void eytzinger1_test(void);
+void eytzinger0_test(void);
+void eytzinger0_find_test(void);
+
#endif /* _BCACHEFS_UTIL_H */
FOR DEBUGGING ONLY -- DO NOT MERGE! Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> --- fs/bcachefs/eytzinger.c | 12 +++--------- fs/bcachefs/eytzinger.h | 4 ++++ fs/bcachefs/super.c | 5 +++++ fs/bcachefs/util.c | 2 +- fs/bcachefs/util.h | 4 ++++ 5 files changed, 17 insertions(+), 10 deletions(-)