summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/test_xarray.c32
-rw-r--r--tools/testing/radix-tree/multiorder.c24
2 files changed, 32 insertions, 24 deletions
diff --git a/lib/test_xarray.c b/lib/test_xarray.c
index ca86141641cb..38cab4ccb24e 100644
--- a/lib/test_xarray.c
+++ b/lib/test_xarray.c
@@ -1019,6 +1019,37 @@ static noinline void check_workingset(struct xarray *xa, unsigned long index)
1019 XA_BUG_ON(xa, !xa_empty(xa)); 1019 XA_BUG_ON(xa, !xa_empty(xa));
1020} 1020}
1021 1021
1022/*
1023 * Check that the pointer / value / sibling entries are accounted the
1024 * way we expect them to be.
1025 */
1026static noinline void check_account(struct xarray *xa)
1027{
1028#ifdef CONFIG_XARRAY_MULTI
1029 unsigned int order;
1030
1031 for (order = 1; order < 12; order++) {
1032 XA_STATE(xas, xa, 1 << order);
1033
1034 xa_store_order(xa, 0, order, xa, GFP_KERNEL);
1035 xas_load(&xas);
1036 XA_BUG_ON(xa, xas.xa_node->count == 0);
1037 XA_BUG_ON(xa, xas.xa_node->count > (1 << order));
1038 XA_BUG_ON(xa, xas.xa_node->nr_values != 0);
1039
1040 xa_store_order(xa, 1 << order, order, xa_mk_value(1 << order),
1041 GFP_KERNEL);
1042 XA_BUG_ON(xa, xas.xa_node->count != xas.xa_node->nr_values * 2);
1043
1044 xa_erase(xa, 1 << order);
1045 XA_BUG_ON(xa, xas.xa_node->nr_values != 0);
1046
1047 xa_erase(xa, 0);
1048 XA_BUG_ON(xa, !xa_empty(xa));
1049 }
1050#endif
1051}
1052
1022static noinline void check_destroy(struct xarray *xa) 1053static noinline void check_destroy(struct xarray *xa)
1023{ 1054{
1024 unsigned long index; 1055 unsigned long index;
@@ -1068,6 +1099,7 @@ static int xarray_checks(void)
1068 check_xa_alloc(); 1099 check_xa_alloc();
1069 check_find(&array); 1100 check_find(&array);
1070 check_find_entry(&array); 1101 check_find_entry(&array);
1102 check_account(&array);
1071 check_destroy(&array); 1103 check_destroy(&array);
1072 check_move(&array); 1104 check_move(&array);
1073 check_create_range(&array); 1105 check_create_range(&array);
diff --git a/tools/testing/radix-tree/multiorder.c b/tools/testing/radix-tree/multiorder.c
index 0436554a099a..dc27a3da210a 100644
--- a/tools/testing/radix-tree/multiorder.c
+++ b/tools/testing/radix-tree/multiorder.c
@@ -356,29 +356,6 @@ void multiorder_tagged_iteration(void)
356 item_kill_tree(&tree); 356 item_kill_tree(&tree);
357} 357}
358 358
359static void multiorder_account(void)
360{
361 RADIX_TREE(tree, GFP_KERNEL);
362 struct radix_tree_node *node;
363 void **slot;
364
365 item_insert_order(&tree, 0, 5);
366
367 __radix_tree_insert(&tree, 1 << 5, 5, xa_mk_value(5));
368 __radix_tree_lookup(&tree, 0, &node, NULL);
369 assert(node->count == node->nr_values * 2);
370 radix_tree_delete(&tree, 1 << 5);
371 assert(node->nr_values == 0);
372
373 __radix_tree_insert(&tree, 1 << 5, 5, xa_mk_value(5));
374 __radix_tree_lookup(&tree, 1 << 5, &node, &slot);
375 assert(node->count == node->nr_values * 2);
376 __radix_tree_replace(&tree, node, slot, NULL);
377 assert(node->nr_values == 0);
378
379 item_kill_tree(&tree);
380}
381
382bool stop_iteration = false; 359bool stop_iteration = false;
383 360
384static void *creator_func(void *ptr) 361static void *creator_func(void *ptr)
@@ -457,7 +434,6 @@ void multiorder_checks(void)
457 multiorder_tag_tests(); 434 multiorder_tag_tests();
458 multiorder_iteration(); 435 multiorder_iteration();
459 multiorder_tagged_iteration(); 436 multiorder_tagged_iteration();
460 multiorder_account();
461 multiorder_iteration_race(); 437 multiorder_iteration_race();
462 438
463 radix_tree_cpu_dead(0); 439 radix_tree_cpu_dead(0);