Lines Matching +full:total +full:- +full:timeout

1 // SPDX-License-Identifier: MIT
16 #define TIMEOUT(name__) \ macro
27 static bool __timeout(unsigned long timeout, const char *fmt, ...) in __timeout() argument
33 if (time_before(jiffies, timeout)) in __timeout()
50 block->header, drm_buddy_block_state(block), in __dump_block()
52 drm_buddy_block_size(mm, block), !block->parent, buddy); in __dump_block()
81 err = -EINVAL; in check_block()
87 if (block_size < mm->chunk_size) { in check_block()
89 err = -EINVAL; in check_block()
94 err = -EINVAL; in check_block()
97 if (!IS_ALIGNED(block_size, mm->chunk_size)) { in check_block()
99 err = -EINVAL; in check_block()
102 if (!IS_ALIGNED(offset, mm->chunk_size)) { in check_block()
104 err = -EINVAL; in check_block()
109 err = -EINVAL; in check_block()
114 if (!buddy && block->parent) { in check_block()
116 err = -EINVAL; in check_block()
122 err = -EINVAL; in check_block()
127 err = -EINVAL; in check_block()
133 err = -EINVAL; in check_block()
145 u64 total; in check_blocks() local
150 total = 0; in check_blocks()
157 err = -EINVAL; in check_blocks()
171 err = -EINVAL; in check_blocks()
178 total += drm_buddy_block_size(mm, block); in check_blocks()
183 if (total != expected_size) { in check_blocks()
185 expected_size, total); in check_blocks()
186 err = -EINVAL; in check_blocks()
207 u64 total; in check_mm() local
210 if (!mm->n_roots) { in check_mm()
212 return -EINVAL; in check_mm()
215 if (mm->n_roots != hweight64(mm->size)) { in check_mm()
217 mm->n_roots, hweight64(mm->size)); in check_mm()
218 return -EINVAL; in check_mm()
223 total = 0; in check_mm()
225 for (i = 0; i < mm->n_roots; ++i) { in check_mm()
229 root = mm->roots[i]; in check_mm()
232 err = -EINVAL; in check_mm()
240 err = -EINVAL; in check_mm()
246 if (order != mm->max_order) { in check_mm()
248 err = -EINVAL; in check_mm()
263 err = -EINVAL; in check_mm()
267 block = list_first_entry_or_null(&mm->free_list[order], in check_mm()
271 err = -EINVAL; in check_mm()
278 total += drm_buddy_block_size(mm, root); in check_mm()
282 if (total != mm->size) { in check_mm()
284 mm->size, total); in check_mm()
285 err = -EINVAL; in check_mm()
291 kunit_err(test, "prev root(%u), dump:\n", i - 1); in check_mm()
313 s = 1 + drm_prandom_u32_max_state((BIT(33 - 12)) - 1, &prng); in mm_config()
317 s &= -ms; in mm_config()
337 * Create a pot-sized mm, then allocate one of each possible in drm_test_buddy_alloc_pathological()
349 for (top = max_order; top; top--) { in drm_test_buddy_alloc_pathological()
353 list_del(&block->link); in drm_test_buddy_alloc_pathological()
357 for (order = top; order--;) { in drm_test_buddy_alloc_pathological()
362 "buddy_alloc hit -ENOMEM with order=%d, top=%d\n", in drm_test_buddy_alloc_pathological()
368 list_move_tail(&block->link, &blocks); in drm_test_buddy_alloc_pathological()
371 /* There should be one final page for this sub-allocation */ in drm_test_buddy_alloc_pathological()
375 "buddy_alloc hit -ENOMEM for hole\n"); in drm_test_buddy_alloc_pathological()
380 list_move_tail(&block->link, &holes); in drm_test_buddy_alloc_pathological()
385 "buddy_alloc unexpectedly succeeded at top-order %d/%d, it should be full!", in drm_test_buddy_alloc_pathological()
414 TIMEOUT(end_time); in drm_test_buddy_alloc_smoke()
427 bool timeout = false; in drm_test_buddy_alloc_smoke() local
429 u64 total, size; in drm_test_buddy_alloc_smoke() local
434 "pre-mm check failed, abort\n"); in drm_test_buddy_alloc_smoke()
437 total = 0; in drm_test_buddy_alloc_smoke()
444 if (err == -ENOMEM) { in drm_test_buddy_alloc_smoke()
445 KUNIT_FAIL(test, "buddy_alloc hit -ENOMEM with order=%d\n", in drm_test_buddy_alloc_smoke()
448 if (order--) { in drm_test_buddy_alloc_smoke()
463 list_move_tail(&block->link, &blocks); in drm_test_buddy_alloc_smoke()
467 total += drm_buddy_block_size(&mm, block); in drm_test_buddy_alloc_smoke()
470 timeout = true; in drm_test_buddy_alloc_smoke()
473 } while (total < mm.size); in drm_test_buddy_alloc_smoke()
476 err = check_blocks(test, &mm, &blocks, total, false); in drm_test_buddy_alloc_smoke()
482 "post-mm check failed\n"); in drm_test_buddy_alloc_smoke()
485 if (err || timeout) in drm_test_buddy_alloc_smoke()
507 * Create a pot-sized mm, then allocate one of each possible in drm_test_buddy_alloc_pessimistic()
522 "buddy_alloc hit -ENOMEM with order=%d\n", in drm_test_buddy_alloc_pessimistic()
528 list_move_tail(&block->link, &blocks); in drm_test_buddy_alloc_pessimistic()
535 "buddy_alloc hit -ENOMEM on final alloc\n"); in drm_test_buddy_alloc_pessimistic()
540 list_move_tail(&block->link, &blocks); in drm_test_buddy_alloc_pessimistic()
543 for (order = max_order; order--;) { in drm_test_buddy_alloc_pessimistic()
551 list_del(&block->link); in drm_test_buddy_alloc_pessimistic()
557 list_del(&block->link); in drm_test_buddy_alloc_pessimistic()
563 "buddy_alloc hit -ENOMEM with order=%d\n", in drm_test_buddy_alloc_pessimistic()
569 list_del(&block->link); in drm_test_buddy_alloc_pessimistic()
578 "buddy_alloc (realloc) hit -ENOMEM with order=%d\n", in drm_test_buddy_alloc_pessimistic()
584 list_del(&block->link); in drm_test_buddy_alloc_pessimistic()
606 mm_size = PAGE_SIZE * ((1 << (max_order + 1)) - 1); in drm_test_buddy_alloc_optimistic()
617 "buddy_alloc hit -ENOMEM with order=%d\n", in drm_test_buddy_alloc_optimistic()
623 list_move_tail(&block->link, &blocks); in drm_test_buddy_alloc_optimistic()
650 "pre-mm check failed, abort!"); in drm_test_buddy_alloc_range()
655 for_each_prime_number_from(page_num, 1, ULONG_MAX - 1) { in drm_test_buddy_alloc_range()
680 rem -= size; in drm_test_buddy_alloc_range()
689 KUNIT_EXPECT_FALSE_MSG(test, check_mm(test, &mm), "post-mm check failed\n"); in drm_test_buddy_alloc_range()