Lines Matching +full:reserved +full:- +full:memory

1 // SPDX-License-Identifier: GPL-2.0-or-later
21 * A simple test that tries to allocate a small memory region.
22 * Expect to allocate an aligned region near the end of the available memory.
26 struct memblock_region *rgn = &memblock.reserved.regions[0]; in alloc_top_down_simple_check()
34 expected_start = memblock_end_of_DRAM() - SMP_CACHE_BYTES; in alloc_top_down_simple_check()
41 ASSERT_EQ(rgn->size, size); in alloc_top_down_simple_check()
42 ASSERT_EQ(rgn->base, expected_start); in alloc_top_down_simple_check()
44 ASSERT_EQ(memblock.reserved.cnt, 1); in alloc_top_down_simple_check()
45 ASSERT_EQ(memblock.reserved.total_size, size); in alloc_top_down_simple_check()
53 * A test that tries to allocate memory next to a reserved region that starts at
58 * | +--------+ +--------|
60 * +------------+--------+---------+--------+
65 * The allocation direction is top-down and region arrays are sorted from lower
67 * memory.reserved array. The previously reserved region does not get modified.
73 struct memblock_region *rgn1 = &memblock.reserved.regions[1]; in alloc_top_down_disjoint_check()
74 struct memblock_region *rgn2 = &memblock.reserved.regions[0]; in alloc_top_down_disjoint_check()
86 r1.base = memblock_end_of_DRAM() - SZ_2; in alloc_top_down_disjoint_check()
90 expected_start = memblock_end_of_DRAM() - alignment; in alloc_top_down_disjoint_check()
99 ASSERT_EQ(rgn1->size, r1.size); in alloc_top_down_disjoint_check()
100 ASSERT_EQ(rgn1->base, r1.base); in alloc_top_down_disjoint_check()
102 ASSERT_EQ(rgn2->size, r2_size); in alloc_top_down_disjoint_check()
103 ASSERT_EQ(rgn2->base, expected_start); in alloc_top_down_disjoint_check()
105 ASSERT_EQ(memblock.reserved.cnt, 2); in alloc_top_down_disjoint_check()
106 ASSERT_EQ(memblock.reserved.total_size, total_size); in alloc_top_down_disjoint_check()
114 * A test that tries to allocate memory when there is enough space at the end
115 * of the previously reserved block (i.e. first fit):
117 * | +--------+--------------|
119 * +--------------+--------+--------------+
125 struct memblock_region *rgn = &memblock.reserved.regions[0]; in alloc_top_down_before_check()
137 memblock_reserve(memblock_end_of_DRAM() - total_size, r1_size); in alloc_top_down_before_check()
144 ASSERT_EQ(rgn->size, total_size); in alloc_top_down_before_check()
145 ASSERT_EQ(rgn->base, memblock_end_of_DRAM() - total_size); in alloc_top_down_before_check()
147 ASSERT_EQ(memblock.reserved.cnt, 1); in alloc_top_down_before_check()
148 ASSERT_EQ(memblock.reserved.total_size, total_size); in alloc_top_down_before_check()
156 * A test that tries to allocate memory when there is not enough space at the
157 * end of the previously reserved block (i.e. second fit):
159 * | +-----------+------+ |
161 * +------------+-----------+------+-----+
168 struct memblock_region *rgn = &memblock.reserved.regions[0]; in alloc_top_down_after_check()
180 r1.base = memblock_end_of_DRAM() - SMP_CACHE_BYTES; in alloc_top_down_after_check()
192 ASSERT_EQ(rgn->size, total_size); in alloc_top_down_after_check()
193 ASSERT_EQ(rgn->base, r1.base - r2_size); in alloc_top_down_after_check()
195 ASSERT_EQ(memblock.reserved.cnt, 1); in alloc_top_down_after_check()
196 ASSERT_EQ(memblock.reserved.total_size, total_size); in alloc_top_down_after_check()
204 * A test that tries to allocate memory when there are two reserved regions with
207 * | +--------+----------+ +------|
209 * +-------+--------+----------+---+------+
217 struct memblock_region *rgn = &memblock.reserved.regions[0]; in alloc_top_down_second_fit_check()
226 r1.base = memblock_end_of_DRAM() - SZ_512; in alloc_top_down_second_fit_check()
229 r2.base = r1.base - SZ_512; in alloc_top_down_second_fit_check()
242 ASSERT_EQ(rgn->size, r2.size + r3_size); in alloc_top_down_second_fit_check()
243 ASSERT_EQ(rgn->base, r2.base - r3_size); in alloc_top_down_second_fit_check()
245 ASSERT_EQ(memblock.reserved.cnt, 2); in alloc_top_down_second_fit_check()
246 ASSERT_EQ(memblock.reserved.total_size, total_size); in alloc_top_down_second_fit_check()
254 * A test that tries to allocate memory when there are two reserved regions with
257 * | +--------+--------+--------+ |
259 * +-----+--------+--------+--------+-----+
261 * Expect to merge all of them, creating one big entry in memblock.reserved
266 struct memblock_region *rgn = &memblock.reserved.regions[0]; in alloc_in_between_generic_check()
274 phys_addr_t rgn_size = (MEM_SIZE - (2 * gap_size + r3_size)) / 2; in alloc_in_between_generic_check()
281 r1.base = memblock_end_of_DRAM() - (gap_size + rgn_size); in alloc_in_between_generic_check()
296 ASSERT_EQ(rgn->size, total_size); in alloc_in_between_generic_check()
297 ASSERT_EQ(rgn->base, r1.base - r2.size - r3_size); in alloc_in_between_generic_check()
299 ASSERT_EQ(memblock.reserved.cnt, 1); in alloc_in_between_generic_check()
300 ASSERT_EQ(memblock.reserved.total_size, total_size); in alloc_in_between_generic_check()
308 * A test that tries to allocate memory when the memory is filled with reserved
309 * regions with memory gaps too small to fit the new region:
311 * +-------+
313 * +--+----+
314 * | +-----+ +-----+ +-----+ |
316 * +----+-----+----+-----+----+-----+----+
347 * A test that tries to allocate memory when all memory is reserved.
357 /* Simulate full memory */ in alloc_all_reserved_generic_check()
370 * A test that tries to allocate memory when the memory is almost full,
373 * +-------+
375 * +-------+
376 * |-----------------------------+ |
377 * | reserved | |
378 * +-----------------------------+---+
386 phys_addr_t reserved_size = MEM_SIZE - available_size; in alloc_no_space_generic_check()
391 /* Simulate almost-full memory */ in alloc_no_space_generic_check()
404 * A test that tries to allocate memory when the memory is almost full,
407 * |---------------------------+---------|
408 * | reserved | new |
409 * +---------------------------+---------+
411 * Expect to allocate memory and merge all the regions. The total size field
416 struct memblock_region *rgn = &memblock.reserved.regions[0]; in alloc_limited_space_generic_check()
419 phys_addr_t reserved_size = MEM_SIZE - available_size; in alloc_limited_space_generic_check()
424 /* Simulate almost-full memory */ in alloc_limited_space_generic_check()
432 ASSERT_EQ(rgn->size, MEM_SIZE); in alloc_limited_space_generic_check()
433 ASSERT_EQ(rgn->base, memblock_start_of_DRAM()); in alloc_limited_space_generic_check()
435 ASSERT_EQ(memblock.reserved.cnt, 1); in alloc_limited_space_generic_check()
436 ASSERT_EQ(memblock.reserved.total_size, MEM_SIZE); in alloc_limited_space_generic_check()
444 * A test that tries to allocate memory when there is no available memory
445 * registered (i.e. memblock.memory has only a dummy entry).
450 struct memblock_region *rgn = &memblock.reserved.regions[0]; in alloc_no_memory_generic_check()
460 ASSERT_EQ(rgn->size, 0); in alloc_no_memory_generic_check()
461 ASSERT_EQ(rgn->base, 0); in alloc_no_memory_generic_check()
462 ASSERT_EQ(memblock.reserved.total_size, 0); in alloc_no_memory_generic_check()
471 * available memory (memblock.memory):
473 * +-----------------------------------+
475 * +-----------------------------------+
478 * +---------------------------------+
484 struct memblock_region *rgn = &memblock.reserved.regions[0]; in alloc_too_large_generic_check()
493 ASSERT_EQ(rgn->size, 0); in alloc_too_large_generic_check()
494 ASSERT_EQ(rgn->base, 0); in alloc_too_large_generic_check()
495 ASSERT_EQ(memblock.reserved.total_size, 0); in alloc_too_large_generic_check()
503 * A simple test that tries to allocate a small memory region.
505 * memory.
509 struct memblock_region *rgn = &memblock.reserved.regions[0]; in alloc_bottom_up_simple_check()
520 ASSERT_EQ(rgn->size, SZ_2); in alloc_bottom_up_simple_check()
521 ASSERT_EQ(rgn->base, memblock_start_of_DRAM()); in alloc_bottom_up_simple_check()
523 ASSERT_EQ(memblock.reserved.cnt, 1); in alloc_bottom_up_simple_check()
524 ASSERT_EQ(memblock.reserved.total_size, SZ_2); in alloc_bottom_up_simple_check()
532 * A test that tries to allocate memory next to a reserved region that starts at
537 * | +----------+ +----------+ |
539 * +----+----------+---+----------+-----+
544 * The allocation direction is bottom-up, so the new region will be the second
545 * entry in memory.reserved array. The previously reserved region does not get
550 struct memblock_region *rgn1 = &memblock.reserved.regions[0]; in alloc_bottom_up_disjoint_check()
551 struct memblock_region *rgn2 = &memblock.reserved.regions[1]; in alloc_bottom_up_disjoint_check()
576 ASSERT_EQ(rgn1->size, r1.size); in alloc_bottom_up_disjoint_check()
577 ASSERT_EQ(rgn1->base, r1.base); in alloc_bottom_up_disjoint_check()
579 ASSERT_EQ(rgn2->size, r2_size); in alloc_bottom_up_disjoint_check()
580 ASSERT_EQ(rgn2->base, expected_start); in alloc_bottom_up_disjoint_check()
582 ASSERT_EQ(memblock.reserved.cnt, 2); in alloc_bottom_up_disjoint_check()
583 ASSERT_EQ(memblock.reserved.total_size, total_size); in alloc_bottom_up_disjoint_check()
591 * A test that tries to allocate memory when there is enough space at
592 * the beginning of the previously reserved block (i.e. first fit):
594 * |------------------+--------+ |
596 * +------------------+--------+---------+
602 struct memblock_region *rgn = &memblock.reserved.regions[0]; in alloc_bottom_up_before_check()
618 ASSERT_EQ(rgn->size, total_size); in alloc_bottom_up_before_check()
619 ASSERT_EQ(rgn->base, memblock_start_of_DRAM()); in alloc_bottom_up_before_check()
621 ASSERT_EQ(memblock.reserved.cnt, 1); in alloc_bottom_up_before_check()
622 ASSERT_EQ(memblock.reserved.total_size, total_size); in alloc_bottom_up_before_check()
630 * A test that tries to allocate memory when there is not enough space at
631 * the beginning of the previously reserved block (i.e. second fit):
633 * | +--------+--------------+ |
635 * +----+--------+--------------+---------+
641 struct memblock_region *rgn = &memblock.reserved.regions[0]; in alloc_bottom_up_after_check()
665 ASSERT_EQ(rgn->size, total_size); in alloc_bottom_up_after_check()
666 ASSERT_EQ(rgn->base, r1.base); in alloc_bottom_up_after_check()
668 ASSERT_EQ(memblock.reserved.cnt, 1); in alloc_bottom_up_after_check()
669 ASSERT_EQ(memblock.reserved.total_size, total_size); in alloc_bottom_up_after_check()
677 * A test that tries to allocate memory when there are two reserved regions, the
678 * first one starting at the beginning of the available memory, with a gap too
681 * |------------+ +--------+--------+ |
683 * +------------+-----+--------+--------+--+
691 struct memblock_region *rgn = &memblock.reserved.regions[1]; in alloc_bottom_up_second_fit_check()
716 ASSERT_EQ(rgn->size, r2.size + r3_size); in alloc_bottom_up_second_fit_check()
717 ASSERT_EQ(rgn->base, r2.base); in alloc_bottom_up_second_fit_check()
719 ASSERT_EQ(memblock.reserved.cnt, 2); in alloc_bottom_up_second_fit_check()
720 ASSERT_EQ(memblock.reserved.total_size, total_size); in alloc_bottom_up_second_fit_check()