diff options
author | Matthew Wilcox <willy@infradead.org> | 2018-06-18 18:10:32 -0400 |
---|---|---|
committer | Matthew Wilcox <willy@infradead.org> | 2018-08-21 23:54:20 -0400 |
commit | 5c78b0b1ebe16fbae39a1cada79ab067965828f5 (patch) | |
tree | a46125bb6d45627bbb8026ba337f1d0518ffcf57 /tools | |
parent | 161b47e31f9912947a3a72dcb161c79978a1fe04 (diff) |
test_ida: Convert check_ida_conv to new API
Move as much as possible to kernel space; leave the parts in user space
that rely on checking memory allocation failures to detect the
transition between an exceptional entry and a bitmap.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/radix-tree/idr-test.c | 56 |
1 files changed, 10 insertions, 46 deletions
diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c index bd9699327f95..c6026cfe3145 100644 --- a/tools/testing/radix-tree/idr-test.c +++ b/tools/testing/radix-tree/idr-test.c | |||
@@ -339,59 +339,23 @@ void ida_check_nomem(void) | |||
339 | /* | 339 | /* |
340 | * Check handling of conversions between exceptional entries and full bitmaps. | 340 | * Check handling of conversions between exceptional entries and full bitmaps. |
341 | */ | 341 | */ |
342 | void ida_check_conv(void) | 342 | void ida_check_conv_user(void) |
343 | { | 343 | { |
344 | DEFINE_IDA(ida); | 344 | DEFINE_IDA(ida); |
345 | int id; | ||
346 | unsigned long i; | 345 | unsigned long i; |
347 | 346 | ||
348 | for (i = 0; i < IDA_BITMAP_BITS * 2; i += IDA_BITMAP_BITS) { | ||
349 | assert(ida_pre_get(&ida, GFP_KERNEL)); | ||
350 | assert(!ida_get_new_above(&ida, i + 1, &id)); | ||
351 | assert(id == i + 1); | ||
352 | assert(!ida_get_new_above(&ida, i + BITS_PER_LONG, &id)); | ||
353 | assert(id == i + BITS_PER_LONG); | ||
354 | ida_remove(&ida, i + 1); | ||
355 | ida_remove(&ida, i + BITS_PER_LONG); | ||
356 | assert(ida_is_empty(&ida)); | ||
357 | } | ||
358 | |||
359 | assert(ida_pre_get(&ida, GFP_KERNEL)); | ||
360 | |||
361 | for (i = 0; i < IDA_BITMAP_BITS * 2; i++) { | ||
362 | assert(ida_pre_get(&ida, GFP_KERNEL)); | ||
363 | assert(!ida_get_new(&ida, &id)); | ||
364 | assert(id == i); | ||
365 | } | ||
366 | |||
367 | for (i = IDA_BITMAP_BITS * 2; i > 0; i--) { | ||
368 | ida_remove(&ida, i - 1); | ||
369 | } | ||
370 | assert(ida_is_empty(&ida)); | ||
371 | |||
372 | for (i = 0; i < IDA_BITMAP_BITS + BITS_PER_LONG - 4; i++) { | ||
373 | assert(ida_pre_get(&ida, GFP_KERNEL)); | ||
374 | assert(!ida_get_new(&ida, &id)); | ||
375 | assert(id == i); | ||
376 | } | ||
377 | |||
378 | for (i = IDA_BITMAP_BITS + BITS_PER_LONG - 4; i > 0; i--) { | ||
379 | ida_remove(&ida, i - 1); | ||
380 | } | ||
381 | assert(ida_is_empty(&ida)); | ||
382 | |||
383 | radix_tree_cpu_dead(1); | 347 | radix_tree_cpu_dead(1); |
384 | for (i = 0; i < 1000000; i++) { | 348 | for (i = 0; i < 1000000; i++) { |
385 | int err = ida_get_new(&ida, &id); | 349 | int id = ida_alloc(&ida, GFP_NOWAIT); |
386 | if (err == -EAGAIN) { | 350 | if (id == -ENOMEM) { |
387 | assert((i % IDA_BITMAP_BITS) == (BITS_PER_LONG - 2)); | 351 | IDA_BUG_ON(&ida, (i % IDA_BITMAP_BITS) != |
388 | assert(ida_pre_get(&ida, GFP_KERNEL)); | 352 | BITS_PER_LONG - 2); |
389 | err = ida_get_new(&ida, &id); | 353 | id = ida_alloc(&ida, GFP_KERNEL); |
390 | } else { | 354 | } else { |
391 | assert((i % IDA_BITMAP_BITS) != (BITS_PER_LONG - 2)); | 355 | IDA_BUG_ON(&ida, (i % IDA_BITMAP_BITS) == |
356 | BITS_PER_LONG - 2); | ||
392 | } | 357 | } |
393 | assert(!err); | 358 | IDA_BUG_ON(&ida, id != i); |
394 | assert(id == i); | ||
395 | } | 359 | } |
396 | ida_destroy(&ida); | 360 | ida_destroy(&ida); |
397 | } | 361 | } |
@@ -507,7 +471,7 @@ void user_ida_checks(void) | |||
507 | ida_destroy(&ida); | 471 | ida_destroy(&ida); |
508 | assert(ida_is_empty(&ida)); | 472 | assert(ida_is_empty(&ida)); |
509 | 473 | ||
510 | ida_check_conv(); | 474 | ida_check_conv_user(); |
511 | ida_check_random(); | 475 | ida_check_random(); |
512 | ida_simple_get_remove_test(); | 476 | ida_simple_get_remove_test(); |
513 | 477 | ||