Lines Matching +full:memory +full:- +full:to +full:- +full:memory

1 // SPDX-License-Identifier: GPL-2.0-or-later
17 ASSERT_NE(memblock.memory.regions, NULL); in memblock_initialization_check()
18 ASSERT_EQ(memblock.memory.cnt, 0); in memblock_initialization_check()
19 ASSERT_EQ(memblock.memory.max, EXPECTED_MEMBLOCK_REGIONS); in memblock_initialization_check()
20 ASSERT_EQ(strcmp(memblock.memory.name, "memory"), 0); in memblock_initialization_check()
24 ASSERT_EQ(memblock.memory.max, EXPECTED_MEMBLOCK_REGIONS); in memblock_initialization_check()
36 * A simple test that adds a memory block of a specified base address
37 * and size to the collection of available memory regions (memblock.memory).
38 * Expect to create a new entry. The region counter and total memory get
45 rgn = &memblock.memory.regions[0]; in memblock_add_simple_check()
57 ASSERT_EQ(rgn->base, r.base); in memblock_add_simple_check()
58 ASSERT_EQ(rgn->size, r.size); in memblock_add_simple_check()
60 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_add_simple_check()
61 ASSERT_EQ(memblock.memory.total_size, r.size); in memblock_add_simple_check()
69 * A simple test that adds a memory block of a specified base address, size,
70 * NUMA node and memory flags to the collection of available memory regions.
71 * Expect to create a new entry. The region counter and total memory get
78 rgn = &memblock.memory.regions[0]; in memblock_add_node_simple_check()
90 ASSERT_EQ(rgn->base, r.base); in memblock_add_node_simple_check()
91 ASSERT_EQ(rgn->size, r.size); in memblock_add_node_simple_check()
93 ASSERT_EQ(rgn->nid, 1); in memblock_add_node_simple_check()
95 ASSERT_EQ(rgn->flags, MEMBLOCK_HOTPLUG); in memblock_add_node_simple_check()
97 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_add_node_simple_check()
98 ASSERT_EQ(memblock.memory.total_size, r.size); in memblock_add_node_simple_check()
106 * A test that tries to add two memory blocks that don't overlap with one
109 * | +--------+ +--------+ |
111 * +--------+--------+--------+--------+--+
113 * Expect to add two correctly initialized entries to the collection of
114 * available memory regions (memblock.memory). The total size and
121 rgn1 = &memblock.memory.regions[0]; in memblock_add_disjoint_check()
122 rgn2 = &memblock.memory.regions[1]; in memblock_add_disjoint_check()
139 ASSERT_EQ(rgn1->base, r1.base); in memblock_add_disjoint_check()
140 ASSERT_EQ(rgn1->size, r1.size); in memblock_add_disjoint_check()
142 ASSERT_EQ(rgn2->base, r2.base); in memblock_add_disjoint_check()
143 ASSERT_EQ(rgn2->size, r2.size); in memblock_add_disjoint_check()
145 ASSERT_EQ(memblock.memory.cnt, 2); in memblock_add_disjoint_check()
146 ASSERT_EQ(memblock.memory.total_size, r1.size + r2.size); in memblock_add_disjoint_check()
154 * A test that tries to add two memory blocks r1 and r2, where r2 overlaps
157 * | +----+----+------------+ |
159 * +----+----+----+------------+----------+
166 * Expect to merge the two entries into one region that starts at r2.base
168 * the available memory is updated, and the region counter stays the same.
175 rgn = &memblock.memory.regions[0]; in memblock_add_overlap_top_check()
188 total_size = (r1.base - r2.base) + r1.size; in memblock_add_overlap_top_check()
194 ASSERT_EQ(rgn->base, r2.base); in memblock_add_overlap_top_check()
195 ASSERT_EQ(rgn->size, total_size); in memblock_add_overlap_top_check()
197 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_add_overlap_top_check()
198 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_add_overlap_top_check()
206 * A test that tries to add two memory blocks r1 and r2, where r2 overlaps
209 * | +--+------+----------+ |
211 * +--+--+------+----------+--------------+
218 * Expect to merge the two entries into one region that starts at r1.base
220 * the available memory is updated, and the region counter stays the same.
227 rgn = &memblock.memory.regions[0]; in memblock_add_overlap_bottom_check()
240 total_size = (r2.base - r1.base) + r2.size; in memblock_add_overlap_bottom_check()
246 ASSERT_EQ(rgn->base, r1.base); in memblock_add_overlap_bottom_check()
247 ASSERT_EQ(rgn->size, total_size); in memblock_add_overlap_bottom_check()
249 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_add_overlap_bottom_check()
250 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_add_overlap_bottom_check()
258 * A test that tries to add two memory blocks r1 and r2, where r2 is
262 * | +-------+--+-----------------------+
264 * +---+-------+--+-----------------------+
269 * Expect to merge two entries into one region that stays the same.
270 * The counter and total size of available memory are not updated.
276 rgn = &memblock.memory.regions[0]; in memblock_add_within_check()
293 ASSERT_EQ(rgn->base, r1.base); in memblock_add_within_check()
294 ASSERT_EQ(rgn->size, r1.size); in memblock_add_within_check()
296 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_add_within_check()
297 ASSERT_EQ(memblock.memory.total_size, r1.size); in memblock_add_within_check()
305 * A simple test that tries to add the same memory block twice. Expect
306 * the counter and total size of available memory to not be updated.
322 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_add_twice_check()
323 ASSERT_EQ(memblock.memory.total_size, r.size); in memblock_add_twice_check()
331 * A test that tries to add two memory blocks that don't overlap with one
332 * another and then add a third memory block in the space between the first two:
334 * | +--------+--------+--------+ |
336 * +--------+--------+--------+--------+--+
338 * Expect to merge the three entries into one region that starts at r1.base
340 * size of the available memory are updated.
347 rgn = &memblock.memory.regions[0]; in memblock_add_between_check()
371 ASSERT_EQ(rgn->base, r1.base); in memblock_add_between_check()
372 ASSERT_EQ(rgn->size, total_size); in memblock_add_between_check()
374 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_add_between_check()
375 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_add_between_check()
383 * A simple test that tries to add a memory block r when r extends past
386 * +--------+
388 * +--------+
389 * | +----+
391 * +----------------------------+----+
393 * Expect to add a memory block of size PHYS_ADDR_MAX - r.base. Expect the
394 * total size of available memory and the counter to be updated.
401 rgn = &memblock.memory.regions[0]; in memblock_add_near_max_check()
404 .base = PHYS_ADDR_MAX - SZ_1M, in memblock_add_near_max_check()
410 total_size = PHYS_ADDR_MAX - r.base; in memblock_add_near_max_check()
415 ASSERT_EQ(rgn->base, r.base); in memblock_add_near_max_check()
416 ASSERT_EQ(rgn->size, total_size); in memblock_add_near_max_check()
418 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_add_near_max_check()
419 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_add_near_max_check()
427 * A test that trying to add the 129th memory block.
428 * Expect to trigger memblock_double_array() to double the
429 * memblock.memory.max, find a new valid memory as
430 * memory.regions.
451 * We allocated enough memory by using dummy_physical_memory_init(), and in memblock_add_many_check()
452 * split it into small block. First we split a large enough memory block in memblock_add_many_check()
453 * as the memory region which will be choosed by memblock_double_array(). in memblock_add_many_check()
460 /* This is the base of small memory block. */ in memblock_add_many_check()
463 orig_region = memblock.memory.regions; in memblock_add_many_check()
467 * Add these small block to fulfill the memblock. We keep a in memblock_add_many_check()
468 * gap between the nearby memory to avoid being merged. in memblock_add_many_check()
473 ASSERT_EQ(memblock.memory.cnt, i + 2); in memblock_add_many_check()
474 ASSERT_EQ(memblock.memory.total_size, new_memory_regions_size + in memblock_add_many_check()
480 * update the memory.max. in memblock_add_many_check()
482 ASSERT_EQ(memblock.memory.max, INIT_MEMBLOCK_REGIONS * 2); in memblock_add_many_check()
484 /* memblock_double_array() will reserve the memory it used. Check it. */ in memblock_add_many_check()
493 ASSERT_EQ(memblock.memory.regions[0].base, r.base); in memblock_add_many_check()
494 ASSERT_EQ(memblock.memory.regions[0].size, r.size); in memblock_add_many_check()
496 ASSERT_EQ(memblock.memory.cnt, INIT_MEMBLOCK_REGIONS + 2); in memblock_add_many_check()
497 ASSERT_EQ(memblock.memory.total_size, INIT_MEMBLOCK_REGIONS * size + in memblock_add_many_check()
500 ASSERT_EQ(memblock.memory.max, INIT_MEMBLOCK_REGIONS * 2); in memblock_add_many_check()
505 * The current memory.regions is occupying a range of memory that in memblock_add_many_check()
506 * allocated from dummy_physical_memory_init(). After free the memory, in memblock_add_many_check()
507 * we must not use it. So restore the origin memory region to make sure in memblock_add_many_check()
510 memblock.memory.regions = orig_region; in memblock_add_many_check()
511 memblock.memory.cnt = INIT_MEMBLOCK_REGIONS; in memblock_add_many_check()
541 * A simple test that marks a memory block of a specified base address
542 * and size as reserved and to the collection of reserved memory regions
543 * (memblock.reserved). Expect to create a new entry. The region counter
544 * and total memory size are updated.
562 ASSERT_EQ(rgn->base, r.base); in memblock_reserve_simple_check()
563 ASSERT_EQ(rgn->size, r.size); in memblock_reserve_simple_check()
571 * A test that tries to mark two memory blocks that don't overlap as reserved:
573 * | +--+ +----------------+ |
575 * +--------+--+------+----------------+--+
577 * Expect to add two entries to the collection of reserved memory regions
603 ASSERT_EQ(rgn1->base, r1.base); in memblock_reserve_disjoint_check()
604 ASSERT_EQ(rgn1->size, r1.size); in memblock_reserve_disjoint_check()
606 ASSERT_EQ(rgn2->base, r2.base); in memblock_reserve_disjoint_check()
607 ASSERT_EQ(rgn2->size, r2.size); in memblock_reserve_disjoint_check()
618 * A test that tries to mark two memory blocks r1 and r2 as reserved,
622 * | +--------------+--+--------------+ |
624 * +--+--------------+--+--------------+--+
631 * Expect to merge two entries into one region that starts at r2.base and
633 * reserved memory is updated, and the region counter is not updated.
653 total_size = (r1.base - r2.base) + r1.size; in memblock_reserve_overlap_top_check()
659 ASSERT_EQ(rgn->base, r2.base); in memblock_reserve_overlap_top_check()
660 ASSERT_EQ(rgn->size, total_size); in memblock_reserve_overlap_top_check()
671 * A test that tries to mark two memory blocks r1 and r2 as reserved,
675 * | +--------------+--+--------------+ |
677 * +--+--------------+--+--------------+--+
684 * Expect to merge two entries into one region that starts at r1.base and
686 * reserved memory is updated, and the region counter is not updated.
706 total_size = (r2.base - r1.base) + r2.size; in memblock_reserve_overlap_bottom_check()
712 ASSERT_EQ(rgn->base, r1.base); in memblock_reserve_overlap_bottom_check()
713 ASSERT_EQ(rgn->size, total_size); in memblock_reserve_overlap_bottom_check()
724 * A test that tries to mark two memory blocks r1 and r2 as reserved,
728 * | +-----+--+---------------------------|
730 * +-+-----+--+---------------------------+
737 * Expect to merge two entries into one region that stays the same. The
738 * counter and total size of available memory are not updated.
761 ASSERT_EQ(rgn->base, r1.base); in memblock_reserve_within_check()
762 ASSERT_EQ(rgn->size, r1.size); in memblock_reserve_within_check()
773 * A simple test that tries to reserve the same memory block twice.
774 * Expect the region counter and total size of reserved memory to not
800 * A test that tries to mark two memory blocks that don't overlap as reserved
801 * and then reserve a third memory block in the space between the first two:
803 * | +--------+--------+--------+ |
805 * +--------+--------+--------+--------+--+
807 * Expect to merge the three entries into one reserved region that starts at
840 ASSERT_EQ(rgn->base, r1.base); in memblock_reserve_between_check()
841 ASSERT_EQ(rgn->size, total_size); in memblock_reserve_between_check()
852 * A simple test that tries to reserve a memory block r when r extends past
855 * +--------+
857 * +--------+
858 * | +----+
860 * +----------------------------+----+
862 * Expect to reserve a memory block of size PHYS_ADDR_MAX - r.base. Expect the
863 * total size of reserved memory and the counter to be updated.
873 .base = PHYS_ADDR_MAX - SZ_1M, in memblock_reserve_near_max_check()
879 total_size = PHYS_ADDR_MAX - r.base; in memblock_reserve_near_max_check()
884 ASSERT_EQ(rgn->base, r.base); in memblock_reserve_near_max_check()
885 ASSERT_EQ(rgn->size, total_size); in memblock_reserve_near_max_check()
896 * A test that trying to reserve the 129th memory block.
897 * Expect to trigger memblock_double_array() to double the
898 * memblock.memory.max, find a new valid memory as
917 /* Add a valid memory region used by double_array(). */ in memblock_reserve_many_check()
922 /* Reserve some fakes memory region to fulfill the memblock. */ in memblock_reserve_many_check()
928 /* Keep the gap so these memory region will not be merged. */ in memblock_reserve_many_check()
938 * This is the memory region size used by the doubled reserved.regions, in memblock_reserve_many_check()
939 * and it has been reserved due to it has been used. The size is used to in memblock_reserve_many_check()
945 * The double_array() will find a free memory region as the new in memblock_reserve_many_check()
946 * reserved.regions, and the used memory region will be reserved, so in memblock_reserve_many_check()
972 * The current reserved.regions is occupying a range of memory that in memblock_reserve_many_check()
973 * allocated from dummy_physical_memory_init(). After free the memory, in memblock_reserve_many_check()
974 * we must not use it. So restore the origin memory region to make sure in memblock_reserve_many_check()
987 * A test that trying to reserve the 129th memory block at all locations.
988 * Expect to trigger memblock_double_array() to double the
989 * memblock.memory.max, find a new valid memory as reserved.regions.
992 * +-------+ +-------+ +-------+ +-------+
994 * +-------+-------+-------+-------+-------+ +-------+
995 * |<-32K->| |<-32K->|
998 /* Keep the gap so these memory region will not be merged. */
1012 /* Reserve the 129th memory block for all possible positions*/ in memblock_reserve_all_locations_check()
1017 /* Add a valid memory region used by double_array(). */ in memblock_reserve_all_locations_check()
1025 /* Reserve some fakes memory region to fulfill the memblock. */ in memblock_reserve_all_locations_check()
1043 * This is the memory region size used by the doubled reserved.regions, in memblock_reserve_all_locations_check()
1044 * and it has been reserved due to it has been used. The size is used to in memblock_reserve_all_locations_check()
1050 * The double_array() will find a free memory region as the new in memblock_reserve_all_locations_check()
1051 * reserved.regions, and the used memory region will be reserved, so in memblock_reserve_all_locations_check()
1077 * The current reserved.regions is occupying a range of memory that in memblock_reserve_all_locations_check()
1078 * allocated from dummy_physical_memory_init(). After free the memory, in memblock_reserve_all_locations_check()
1079 * we must not use it. So restore the origin memory region to make sure in memblock_reserve_all_locations_check()
1092 * A test that trying to reserve the 129th memory block at all locations.
1093 * Expect to trigger memblock_double_array() to double the
1094 * memblock.memory.max, find a new valid memory as reserved.regions. And make
1095 * sure it doesn't conflict with the range we want to reserve.
1097 * For example, we have 128 regions in reserved and now want to reserve
1099 * an available range in memory for the new array. We intended to put two
1100 * ranges in memory with one is the exact range of the skipped one. Before
1103 * conflict. The expected new array should be allocated from memory.regions[0].
1106 * memory +-------+ +-------+
1108 * +-------+ ------+-------+-------+-------+
1109 * |<-32K->|<-32K->|<-32K->|
1112 * reserved +-------+ ......... +-------+
1114 * +-------+-------+-------+ +-------+
1115 * |<-32K->|
1121 /* Keep the gap so these memory region will not be merged. */
1135 * +---+ +---+ +---+ in memblock_reserve_many_may_conflict_check()
1137 * +---+ +---+ +---+ in memblock_reserve_many_may_conflict_check()
1139 * Pre-allocate the range for 129 memory block + one range for double in memblock_reserve_many_may_conflict_check()
1148 /* Reserve the 129th memory block for all possible positions*/ in memblock_reserve_many_may_conflict_check()
1154 /* Add a valid memory region used by double_array(). */ in memblock_reserve_many_may_conflict_check()
1157 * Add a memory region which will be reserved as 129th memory in memblock_reserve_many_may_conflict_check()
1158 * region. This is not expected to be used by double_array(). in memblock_reserve_many_may_conflict_check()
1166 /* Reserve some fakes memory region to fulfill the memblock. */ in memblock_reserve_many_may_conflict_check()
1173 ASSERT_EQ(memblock.reserved.cnt, i - 1); in memblock_reserve_many_may_conflict_check()
1174 ASSERT_EQ(memblock.reserved.total_size, (i - 1) * MEM_SIZE); in memblock_reserve_many_may_conflict_check()
1184 * This is the memory region size used by the doubled reserved.regions, in memblock_reserve_many_may_conflict_check()
1185 * and it has been reserved due to it has been used. The size is used to in memblock_reserve_many_may_conflict_check()
1191 * The double_array() will find a free memory region as the new in memblock_reserve_many_may_conflict_check()
1192 * reserved.regions, and the used memory region will be reserved, so in memblock_reserve_many_may_conflict_check()
1203 * with the size of new_reserved_regions_size and the base to be in memblock_reserve_many_may_conflict_check()
1204 * MEMORY_BASE_OFFSET(0, offset) + SZ_32K - new_reserved_regions_size in memblock_reserve_many_may_conflict_check()
1225 * The current reserved.regions is occupying a range of memory that in memblock_reserve_many_may_conflict_check()
1226 * allocated from dummy_physical_memory_init(). After free the memory, in memblock_reserve_many_may_conflict_check()
1227 * we must not use it. So restore the origin memory region to make sure in memblock_reserve_many_may_conflict_check()
1265 * A simple test that tries to remove a region r1 from the array of
1266 * available memory regions. By "removing" a region we mean overwriting it
1267 * with the next region r2 in memblock.memory:
1269 * | ...... +----------------+ |
1271 * +--+----+----------+----------------+--+
1276 * Expect to add two memory blocks r1 and r2 and then remove r1 so that
1284 rgn = &memblock.memory.regions[0]; in memblock_remove_simple_check()
1302 ASSERT_EQ(rgn->base, r2.base); in memblock_remove_simple_check()
1303 ASSERT_EQ(rgn->size, r2.size); in memblock_remove_simple_check()
1305 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_remove_simple_check()
1306 ASSERT_EQ(memblock.memory.total_size, r2.size); in memblock_remove_simple_check()
1314 * A test that tries to remove a region r2 that was not registered as
1315 * available memory (i.e. has no corresponding entry in memblock.memory):
1317 * +----------------+
1319 * +----------------+
1320 * | +----+ |
1322 * +--+----+------------------------------+
1327 * Expect the array, regions counter and total size to not be modified.
1333 rgn = &memblock.memory.regions[0]; in memblock_remove_absent_check()
1350 ASSERT_EQ(rgn->base, r1.base); in memblock_remove_absent_check()
1351 ASSERT_EQ(rgn->size, r1.size); in memblock_remove_absent_check()
1353 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_remove_absent_check()
1354 ASSERT_EQ(memblock.memory.total_size, r1.size); in memblock_remove_absent_check()
1362 * A test that tries to remove a region r2 that overlaps with the
1366 * +-----------------+
1368 * +-----------------+
1369 * | .........+--------+ |
1371 * +-----------------+--------+--------+--+
1378 * available memory pool. The regions counter and total size are updated.
1385 rgn = &memblock.memory.regions[0]; in memblock_remove_overlap_top_check()
1400 total_size = r1_end - r2_end; in memblock_remove_overlap_top_check()
1406 ASSERT_EQ(rgn->base, r1.base + r2.base); in memblock_remove_overlap_top_check()
1407 ASSERT_EQ(rgn->size, total_size); in memblock_remove_overlap_top_check()
1409 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_remove_overlap_top_check()
1410 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_remove_overlap_top_check()
1418 * A test that tries to remove a region r2 that overlaps with the end of
1421 * +--------------------------------+
1423 * +--------------------------------+
1424 * | +---+..... |
1426 * +-+---+----+---------------------------+
1432 * available memory pool. The regions counter and total size are updated.
1439 rgn = &memblock.memory.regions[0]; in memblock_remove_overlap_bottom_check()
1452 total_size = r2.base - r1.base; in memblock_remove_overlap_bottom_check()
1458 ASSERT_EQ(rgn->base, r1.base); in memblock_remove_overlap_bottom_check()
1459 ASSERT_EQ(rgn->size, total_size); in memblock_remove_overlap_bottom_check()
1461 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_remove_overlap_bottom_check()
1462 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_remove_overlap_bottom_check()
1470 * A test that tries to remove a region r2 that is within the range of
1474 * +----+
1476 * +----+
1477 * | +-------------+....+---------------+ |
1479 * +-+-------------+----+---------------+-+
1484 * Expect that the region is split into two - one that ends at r2.base and
1493 rgn1 = &memblock.memory.regions[0]; in memblock_remove_within_check()
1494 rgn2 = &memblock.memory.regions[1]; in memblock_remove_within_check()
1507 r1_size = r2.base - r1.base; in memblock_remove_within_check()
1508 r2_size = (r1.base + r1.size) - (r2.base + r2.size); in memblock_remove_within_check()
1515 ASSERT_EQ(rgn1->base, r1.base); in memblock_remove_within_check()
1516 ASSERT_EQ(rgn1->size, r1_size); in memblock_remove_within_check()
1518 ASSERT_EQ(rgn2->base, r2.base + r2.size); in memblock_remove_within_check()
1519 ASSERT_EQ(rgn2->size, r2_size); in memblock_remove_within_check()
1521 ASSERT_EQ(memblock.memory.cnt, 2); in memblock_remove_within_check()
1522 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_remove_within_check()
1530 * A simple test that tries to remove a region r1 from the array of
1531 * available memory regions when r1 is the only available region.
1532 * Expect to add a memory block r1 and then remove r1 so that a dummy
1540 rgn = &memblock.memory.regions[0]; in memblock_remove_only_region_check()
1553 ASSERT_EQ(rgn->base, 0); in memblock_remove_only_region_check()
1554 ASSERT_EQ(rgn->size, 0); in memblock_remove_only_region_check()
1556 ASSERT_EQ(memblock.memory.cnt, 0); in memblock_remove_only_region_check()
1557 ASSERT_EQ(memblock.memory.total_size, 0); in memblock_remove_only_region_check()
1566 * memory regions when r2 extends past PHYS_ADDR_MAX:
1568 * +--------+
1570 * +--------+
1571 * | +---+....+
1573 * +------------------------+---+----+
1576 * Expect the total size of available memory to be updated and the counter to
1584 rgn = &memblock.memory.regions[0]; in memblock_remove_near_max_check()
1587 .base = PHYS_ADDR_MAX - SZ_2M, in memblock_remove_near_max_check()
1592 .base = PHYS_ADDR_MAX - SZ_1M, in memblock_remove_near_max_check()
1598 total_size = r1.size - (PHYS_ADDR_MAX - r2.base); in memblock_remove_near_max_check()
1604 ASSERT_EQ(rgn->base, r1.base); in memblock_remove_near_max_check()
1605 ASSERT_EQ(rgn->size, total_size); in memblock_remove_near_max_check()
1607 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_remove_near_max_check()
1608 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_remove_near_max_check()
1616 * A test that tries to remove a region r3 that overlaps with two existing
1619 * +----------------+
1621 * +----------------+
1622 * | +----+..... ........+--------+
1624 * +----+----+----+---+-------+--------+-----+
1627 * from the available memory pool. Expect the total size of available memory to
1628 * be updated and the counter to not be updated.
1635 rgn1 = &memblock.memory.regions[0]; in memblock_remove_overlap_two_check()
1636 rgn2 = &memblock.memory.regions[1]; in memblock_remove_overlap_two_check()
1655 new_r1_size = r3.base - r1.base; in memblock_remove_overlap_two_check()
1656 new_r2_size = r2_end - r3_end; in memblock_remove_overlap_two_check()
1664 ASSERT_EQ(rgn1->base, r1.base); in memblock_remove_overlap_two_check()
1665 ASSERT_EQ(rgn1->size, new_r1_size); in memblock_remove_overlap_two_check()
1667 ASSERT_EQ(rgn2->base, r3_end); in memblock_remove_overlap_two_check()
1668 ASSERT_EQ(rgn2->size, new_r2_size); in memblock_remove_overlap_two_check()
1670 ASSERT_EQ(memblock.memory.cnt, 2); in memblock_remove_overlap_two_check()
1671 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_remove_overlap_two_check()
1699 * A simple test that tries to free a memory block r1 that was marked
1703 * | ...... +----+ |
1705 * +--------------+----+-----------+----+-+
1710 * Expect to reserve two memory regions and then erase r1 region with the
1735 ASSERT_EQ(rgn->base, r2.base); in memblock_free_simple_check()
1736 ASSERT_EQ(rgn->size, r2.size); in memblock_free_simple_check()
1747 * A test that tries to free a region r2 that was not marked as reserved
1750 * +----------------+
1752 * +----------------+
1753 * | +----+ |
1755 * +--+----+------------------------------+
1783 ASSERT_EQ(rgn->base, r1.base); in memblock_free_absent_check()
1784 ASSERT_EQ(rgn->size, r1.size); in memblock_free_absent_check()
1795 * A test that tries to free a region r2 that overlaps with the beginning
1798 * +----+
1800 * +----+
1801 * | ...+--------------+ |
1803 * +----+--+--------------+---------------+
1831 total_size = (r1.size + r1.base) - (r2.base + r2.size); in memblock_free_overlap_top_check()
1837 ASSERT_EQ(rgn->base, r2.base + r2.size); in memblock_free_overlap_top_check()
1838 ASSERT_EQ(rgn->size, total_size); in memblock_free_overlap_top_check()
1849 * A test that tries to free a region r2 that overlaps with the end of
1852 * +----------------+
1854 * +----------------+
1855 * | +-----------+..... |
1857 * +----+-----------+----+----------------+
1880 total_size = r2.base - r1.base; in memblock_free_overlap_bottom_check()
1886 ASSERT_EQ(rgn->base, r1.base); in memblock_free_overlap_bottom_check()
1887 ASSERT_EQ(rgn->size, total_size); in memblock_free_overlap_bottom_check()
1898 * A test that tries to free a region r2 that is within the range of the
1902 * +----+
1904 * +----+
1905 * | +------------+....+---------------+
1907 * +----+------------+----+---------------+
1912 * Expect that the region is split into two - one that ends at r2.base and
1935 r1_size = r2.base - r1.base; in memblock_free_within_check()
1936 r2_size = (r1.base + r1.size) - (r2.base + r2.size); in memblock_free_within_check()
1943 ASSERT_EQ(rgn1->base, r1.base); in memblock_free_within_check()
1944 ASSERT_EQ(rgn1->size, r1_size); in memblock_free_within_check()
1946 ASSERT_EQ(rgn2->base, r2.base + r2.size); in memblock_free_within_check()
1947 ASSERT_EQ(rgn2->size, r2_size); in memblock_free_within_check()
1958 * A simple test that tries to free a memory block r1 that was marked
1960 * Expect to reserve a memory block r1 and then free r1 so that r1 is
1981 ASSERT_EQ(rgn->base, 0); in memblock_free_only_region_check()
1982 ASSERT_EQ(rgn->size, 0); in memblock_free_only_region_check()
1995 * +--------+
1997 * +--------+
1998 * | +---+....+
2000 * +------------------------+---+----+
2003 * Expect the total size of reserved memory to be updated and the counter to
2014 .base = PHYS_ADDR_MAX - SZ_2M, in memblock_free_near_max_check()
2019 .base = PHYS_ADDR_MAX - SZ_1M, in memblock_free_near_max_check()
2025 total_size = r1.size - (PHYS_ADDR_MAX - r2.base); in memblock_free_near_max_check()
2031 ASSERT_EQ(rgn->base, r1.base); in memblock_free_near_max_check()
2032 ASSERT_EQ(rgn->size, total_size); in memblock_free_near_max_check()
2043 * A test that tries to free a reserved region r3 that overlaps with two
2046 * +----------------+
2048 * +----------------+
2049 * | +----+..... ........+--------+
2051 * +----+----+----+---+-------+--------+-----+
2054 * from the collection of reserved memory. Expect the total size of reserved
2055 * memory to be updated and the counter to not be updated.
2082 new_r1_size = r3.base - r1.base; in memblock_free_overlap_two_check()
2083 new_r2_size = r2_end - r3_end; in memblock_free_overlap_two_check()
2091 ASSERT_EQ(rgn1->base, r1.base); in memblock_free_overlap_two_check()
2092 ASSERT_EQ(rgn1->size, new_r1_size); in memblock_free_overlap_two_check()
2094 ASSERT_EQ(rgn2->base, r3_end); in memblock_free_overlap_two_check()
2095 ASSERT_EQ(rgn2->size, new_r2_size); in memblock_free_overlap_two_check()
2170 * A test that tries to trim memory when both ends of the memory region are
2171 * aligned. Expect that the memory will not be trimmed. Expect the counter to
2179 rgn = &memblock.memory.regions[0]; in memblock_trim_memory_aligned_check()
2192 ASSERT_EQ(rgn->base, r.base); in memblock_trim_memory_aligned_check()
2193 ASSERT_EQ(rgn->size, r.size); in memblock_trim_memory_aligned_check()
2195 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_trim_memory_aligned_check()
2203 * A test that tries to trim memory when there are two available regions, r1 and
2208 * |--------|
2209 * | +-----------------+ +------+ |
2211 * +--------+-----------------+--------+------+---+
2218 * counter to be updated.
2225 rgn = &memblock.memory.regions[0]; in memblock_trim_memory_too_small_check()
2233 .size = alignment - SZ_2 in memblock_trim_memory_too_small_check()
2243 ASSERT_EQ(rgn->base, r1.base); in memblock_trim_memory_too_small_check()
2244 ASSERT_EQ(rgn->size, r1.size); in memblock_trim_memory_too_small_check()
2246 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_trim_memory_too_small_check()
2254 * A test that tries to trim memory when there are two available regions, r1 and
2261 * | +-----------------+ +---------------+ |
2263 * +--------+-----------------+----------+---------------+---+
2270 * Expect the counter to not be updated.
2279 rgn1 = &memblock.memory.regions[0]; in memblock_trim_memory_unaligned_base_check()
2280 rgn2 = &memblock.memory.regions[1]; in memblock_trim_memory_unaligned_base_check()
2288 .size = alignment * 2 - offset in memblock_trim_memory_unaligned_base_check()
2293 new_r2_base = r2.base + (alignment - offset); in memblock_trim_memory_unaligned_base_check()
2294 new_r2_size = r2.size - (alignment - offset); in memblock_trim_memory_unaligned_base_check()
2301 ASSERT_EQ(rgn1->base, r1.base); in memblock_trim_memory_unaligned_base_check()
2302 ASSERT_EQ(rgn1->size, r1.size); in memblock_trim_memory_unaligned_base_check()
2304 ASSERT_EQ(rgn2->base, new_r2_base); in memblock_trim_memory_unaligned_base_check()
2305 ASSERT_EQ(rgn2->size, new_r2_size); in memblock_trim_memory_unaligned_base_check()
2307 ASSERT_EQ(memblock.memory.cnt, 2); in memblock_trim_memory_unaligned_base_check()
2315 * A test that tries to trim memory when there are two available regions, r1 and
2322 * | +-----------------+ +---------------+ |
2324 * +--------+-----------------+--------+---------------+---+
2331 * Expect the counter to not be updated.
2340 rgn1 = &memblock.memory.regions[0]; in memblock_trim_memory_unaligned_end_check()
2341 rgn2 = &memblock.memory.regions[1]; in memblock_trim_memory_unaligned_end_check()
2349 .size = alignment * 2 - offset in memblock_trim_memory_unaligned_end_check()
2354 new_r2_size = r2.size - (alignment - offset); in memblock_trim_memory_unaligned_end_check()
2361 ASSERT_EQ(rgn1->base, r1.base); in memblock_trim_memory_unaligned_end_check()
2362 ASSERT_EQ(rgn1->size, r1.size); in memblock_trim_memory_unaligned_end_check()
2364 ASSERT_EQ(rgn2->base, r2.base); in memblock_trim_memory_unaligned_end_check()
2365 ASSERT_EQ(rgn2->size, new_r2_size); in memblock_trim_memory_unaligned_end_check()
2367 ASSERT_EQ(memblock.memory.cnt, 2); in memblock_trim_memory_unaligned_end_check()
2403 ASSERT_FALSE(memblock_overlaps_region(&memblock.memory, SZ_1M, SZ_1M)); in memblock_overlaps_region_check()
2404 ASSERT_FALSE(memblock_overlaps_region(&memblock.memory, SZ_2G, SZ_1M)); in memblock_overlaps_region_check()
2407 ASSERT_FALSE(memblock_overlaps_region(&memblock.memory, SZ_1G - SZ_1M, SZ_1M)); in memblock_overlaps_region_check()
2408 ASSERT_FALSE(memblock_overlaps_region(&memblock.memory, SZ_1G + SZ_4M, SZ_1M)); in memblock_overlaps_region_check()
2411 ASSERT_TRUE(memblock_overlaps_region(&memblock.memory, SZ_1G - SZ_1M, SZ_2M)); in memblock_overlaps_region_check()
2412 ASSERT_TRUE(memblock_overlaps_region(&memblock.memory, SZ_1G + SZ_2M, SZ_2M)); in memblock_overlaps_region_check()
2415 ASSERT_TRUE(memblock_overlaps_region(&memblock.memory, SZ_1G, SZ_4M)); in memblock_overlaps_region_check()
2416 ASSERT_TRUE(memblock_overlaps_region(&memblock.memory, SZ_1G - SZ_2M, SZ_8M)); in memblock_overlaps_region_check()
2417 ASSERT_TRUE(memblock_overlaps_region(&memblock.memory, SZ_1G + SZ_1M, SZ_1M)); in memblock_overlaps_region_check()