Lines Matching defs:size
185 static size_t setup_test_cache(struct kunit *test, size_t size, slab_flags_t flags,
189 return size;
191 kunit_info(test, "%s: size=%zu, ctor=%ps\n", __func__, size, ctor);
198 test_cache = kmem_cache_create("test", size, 1, flags, ctor);
201 return size;
213 static inline size_t kmalloc_cache_alignment(size_t size)
217 return kmalloc_caches[type][__kmalloc_index(size, false)]->align;
244 static void *test_alloc(struct kunit *test, size_t size, gfp_t gfp, enum allocation_policy policy)
265 kunit_info(test, "%s: size=%zu, gfp=%x, policy=%s, cache=%i\n", __func__, size, gfp,
283 alloc = kmalloc(size, gfp);
289 kmalloc_caches[type][__kmalloc_index(size, false)];
320 size_t size = 32;
328 setup_test_cache(test, size, 0, NULL);
335 size = kmalloc_cache_alignment(size);
339 buf = test_alloc(test, size, GFP_KERNEL, ALLOCATE_LEFT);
345 buf = test_alloc(test, size, GFP_KERNEL, ALLOCATE_RIGHT);
346 expect.addr = buf + size;
354 size_t size = 32;
362 setup_test_cache(test, size, 0, NULL);
363 buf = test_alloc(test, size, GFP_KERNEL, ALLOCATE_LEFT);
372 const size_t size = 32;
379 setup_test_cache(test, size, 0, NULL);
380 expect.addr = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY);
388 const size_t size = 32;
393 setup_test_cache(test, size, 0, NULL);
394 addr = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY);
404 const size_t size = 32;
410 setup_test_cache(test, size, 0, NULL);
411 expect.addr = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY);
419 const size_t size = 32;
426 setup_test_cache(test, size, 0, NULL);
427 buf = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY);
436 size_t size = 32;
443 setup_test_cache(test, size, 0, NULL);
447 buf = test_alloc(test, size, GFP_KERNEL, ALLOCATE_LEFT);
448 expect.addr = buf + size;
453 buf = test_alloc(test, size, GFP_KERNEL, ALLOCATE_RIGHT);
472 const size_t size = 73;
473 const size_t align = kmalloc_cache_alignment(size);
481 buf = test_alloc(test, size, GFP_KERNEL, ALLOCATE_RIGHT);
491 * @buf must be aligned on @align, therefore buf + size belongs to the
494 READ_ONCE(*(buf + size));
498 expect.addr = buf + size + align;
507 const size_t size = 73;
514 buf = test_alloc(test, size, GFP_KERNEL, ALLOCATE_RIGHT);
519 expect.addr = buf + size;
529 const size_t size = 32;
532 setup_test_cache(test, size, 0, NULL);
534 buf = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY);
553 const size_t size = setup_test_cache(test, get_random_u32_inclusive(8, 307),
556 test_alloc(test, size, GFP_KERNEL, ALLOCATE_RIGHT),
557 test_alloc(test, size, GFP_KERNEL, ALLOCATE_NONE),
558 test_alloc(test, size, GFP_KERNEL, ALLOCATE_LEFT),
559 test_alloc(test, size, GFP_KERNEL, ALLOCATE_NONE),
560 test_alloc(test, size, GFP_KERNEL, ALLOCATE_NONE),
572 const size_t size = 32;
583 setup_test_cache(test, size, 0, NULL);
584 expect.addr = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY);
585 for (i = 0; i < size; i++)
589 for (i = 0; i < size; i++) {
605 const size_t size = 32;
609 setup_test_cache(test, size, 0, ctor_set_x);
610 buf = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY);
623 const size_t size = PAGE_SIZE; /* PAGE_SIZE so we can use ALLOCATE_ANY. */
630 setup_test_cache(test, size, 0, NULL);
631 buf1 = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY);
632 for (i = 0; i < size; i++)
638 buf2 = test_alloc(test, size, GFP_KERNEL | __GFP_ZERO, ALLOCATE_ANY);
650 for (i = 0; i < size; i++)
674 const size_t size = 32;
681 setup_test_cache(test, size, SLAB_TYPESAFE_BY_RCU, NULL);
684 expect.addr = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY);
710 const size_t size = 32;
714 .addr = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY),
721 KUNIT_EXPECT_EQ(test, ksize(buf), size); /* Precise size match after KFENCE alloc. */
722 for (i = 0; i < size; i++)
725 /* Check that we successfully change the size. */
726 buf = krealloc(buf, size * 3, GFP_KERNEL); /* Grow. */
728 KUNIT_EXPECT_GE(test, ksize(buf), size * 3);
729 for (i = 0; i < size; i++)
731 for (; i < size * 3; i++) /* Fill to extra bytes. */
734 buf = krealloc(buf, size * 2, GFP_KERNEL); /* Shrink. */
735 KUNIT_EXPECT_GE(test, ksize(buf), size * 2);
736 for (i = 0; i < size * 2; i++)
750 const size_t size = 32;
754 setup_test_cache(test, size, 0, NULL);