diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2025-01-26 11:22:33 +0100 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-03-07 16:16:26 -0500 |
commit | bfd9b6e0c05aaa749b752bc8c7b639f54fc29ca3 (patch) | |
tree | ce0243e6397029941e5ef8c55a497c9d2a1ff866 | |
parent | e8352e2b87171e7186f8b8c59b62a344c4ad9751 (diff) |
bcachefs: eytzinger0_find_test improvement
In eytzinger0_find_test(), remember the smallest element seen so far
instead of comparing adjacent array elements.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/util.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index 953ed5ad38a4..55bf19578e3a 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -802,15 +802,18 @@ void eytzinger0_find_test(void) u16 *test_array = kmalloc_array(allocated, sizeof(test_array[0]), GFP_KERNEL); for (nr = 1; nr < allocated; nr++) { + u16 prev = 0; + pr_info("testing %u elems\n", nr); get_random_bytes(test_array, nr * sizeof(test_array[0])); eytzinger0_sort(test_array, nr, sizeof(test_array[0]), cmp_u16, NULL); /* verify array is sorted correctly: */ - eytzinger0_for_each(j, nr) - BUG_ON(j != eytzinger0_last(nr) && - test_array[j] > test_array[eytzinger0_next(j, nr)]); + eytzinger0_for_each(j, nr) { + BUG_ON(test_array[j] < prev); + prev = test_array[j]; + } for (i = 0; i < U16_MAX; i += 1 << 12) eytzinger0_find_test_val(test_array, nr, i); |