hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/tools/testing/radix-tree/main.c
....@@ -214,7 +214,7 @@
214214 }
215215
216216 // printf("\ncopying tags...\n");
217
- tagged = tag_tagged_items(&tree, NULL, start, end, ITEMS, 0, 1);
217
+ tagged = tag_tagged_items(&tree, start, end, ITEMS, XA_MARK_0, XA_MARK_1);
218218
219219 // printf("checking copied tags\n");
220220 assert(tagged == count);
....@@ -223,7 +223,7 @@
223223 /* Copy tags in several rounds */
224224 // printf("\ncopying tags...\n");
225225 tmp = rand() % (count / 10 + 2);
226
- tagged = tag_tagged_items(&tree, NULL, start, end, tmp, 0, 2);
226
+ tagged = tag_tagged_items(&tree, start, end, tmp, XA_MARK_0, XA_MARK_2);
227227 assert(tagged == count);
228228
229229 // printf("%lu %lu %lu\n", tagged, tmp, count);
....@@ -236,63 +236,6 @@
236236 item_kill_tree(&tree);
237237 }
238238
239
-static void __locate_check(struct radix_tree_root *tree, unsigned long index,
240
- unsigned order)
241
-{
242
- struct item *item;
243
- unsigned long index2;
244
-
245
- item_insert_order(tree, index, order);
246
- item = item_lookup(tree, index);
247
- index2 = find_item(tree, item);
248
- if (index != index2) {
249
- printv(2, "index %ld order %d inserted; found %ld\n",
250
- index, order, index2);
251
- abort();
252
- }
253
-}
254
-
255
-static void __order_0_locate_check(void)
256
-{
257
- RADIX_TREE(tree, GFP_KERNEL);
258
- int i;
259
-
260
- for (i = 0; i < 50; i++)
261
- __locate_check(&tree, rand() % INT_MAX, 0);
262
-
263
- item_kill_tree(&tree);
264
-}
265
-
266
-static void locate_check(void)
267
-{
268
- RADIX_TREE(tree, GFP_KERNEL);
269
- unsigned order;
270
- unsigned long offset, index;
271
-
272
- __order_0_locate_check();
273
-
274
- for (order = 0; order < 20; order++) {
275
- for (offset = 0; offset < (1 << (order + 3));
276
- offset += (1UL << order)) {
277
- for (index = 0; index < (1UL << (order + 5));
278
- index += (1UL << order)) {
279
- __locate_check(&tree, index + offset, order);
280
- }
281
- if (find_item(&tree, &tree) != -1)
282
- abort();
283
-
284
- item_kill_tree(&tree);
285
- }
286
- }
287
-
288
- if (find_item(&tree, &tree) != -1)
289
- abort();
290
- __locate_check(&tree, -1, 0);
291
- if (find_item(&tree, &tree) != -1)
292
- abort();
293
- item_kill_tree(&tree);
294
-}
295
-
296239 static void single_thread_tests(bool long_run)
297240 {
298241 int i;
....@@ -302,10 +245,6 @@
302245 multiorder_checks();
303246 rcu_barrier();
304247 printv(2, "after multiorder_check: %d allocated, preempt %d\n",
305
- nr_allocated, preempt_count);
306
- locate_check();
307
- rcu_barrier();
308
- printv(2, "after locate_check: %d allocated, preempt %d\n",
309248 nr_allocated, preempt_count);
310249 tag_check();
311250 rcu_barrier();
....@@ -365,11 +304,14 @@
365304 rcu_register_thread();
366305 radix_tree_init();
367306
307
+ xarray_tests();
368308 regression1_test();
369309 regression2_test();
370310 regression3_test();
311
+ regression4_test();
371312 iteration_test(0, 10 + 90 * long_run);
372313 iteration_test(7, 10 + 90 * long_run);
314
+ iteration_test2(10 + 90 * long_run);
373315 single_thread_tests(long_run);
374316
375317 /* Free any remaining preallocated nodes */