Lines Matching +full:reserved +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, 1); 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()
22 ASSERT_NE(memblock.reserved.regions, NULL); in memblock_initialization_check()
23 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_initialization_check()
24 ASSERT_EQ(memblock.memory.max, EXPECTED_MEMBLOCK_REGIONS); in memblock_initialization_check()
25 ASSERT_EQ(strcmp(memblock.reserved.name, "reserved"), 0); 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 * +--------+--------+--------+--------+--+
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 * +----+----+----+------------+----------+
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 * +--+--+------+----------+--------------+
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 * +---+-------+--+-----------------------+
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 * +--------+--------+--------+--------+--+
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.
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()
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()
485 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_add_many_check()
486 ASSERT_EQ(memblock.reserved.total_size, new_memory_regions_size); 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.
550 rgn = &memblock.reserved.regions[0]; in memblock_reserve_simple_check()
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
578 * (memblock.reserved). The total size and region counter for
579 * memblock.reserved are updated.
585 rgn1 = &memblock.reserved.regions[0]; in memblock_reserve_disjoint_check()
586 rgn2 = &memblock.reserved.regions[1]; in memblock_reserve_disjoint_check()
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()
609 ASSERT_EQ(memblock.reserved.cnt, 2); in memblock_reserve_disjoint_check()
610 ASSERT_EQ(memblock.reserved.total_size, r1.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 * +--+--------------+--+--------------+--+
633 * reserved memory is updated, and the region counter is not updated.
640 rgn = &memblock.reserved.regions[0]; in memblock_reserve_overlap_top_check()
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()
662 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_reserve_overlap_top_check()
663 ASSERT_EQ(memblock.reserved.total_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 * +--+--------------+--+--------------+--+
686 * reserved memory is updated, and the region counter is not updated.
693 rgn = &memblock.reserved.regions[0]; in memblock_reserve_overlap_bottom_check()
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()
715 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_reserve_overlap_bottom_check()
716 ASSERT_EQ(memblock.reserved.total_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 * +-+-----+--+---------------------------+
738 * counter and total size of available memory are not updated.
744 rgn = &memblock.reserved.regions[0]; in memblock_reserve_within_check()
761 ASSERT_EQ(rgn->base, r1.base); in memblock_reserve_within_check()
762 ASSERT_EQ(rgn->size, r1.size); in memblock_reserve_within_check()
764 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_reserve_within_check()
765 ASSERT_EQ(memblock.reserved.total_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
791 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_reserve_twice_check()
792 ASSERT_EQ(memblock.reserved.total_size, r.size); in memblock_reserve_twice_check()
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
809 * total for memblock.reserved are updated.
816 rgn = &memblock.reserved.regions[0]; in memblock_reserve_between_check()
840 ASSERT_EQ(rgn->base, r1.base); in memblock_reserve_between_check()
841 ASSERT_EQ(rgn->size, total_size); in memblock_reserve_between_check()
843 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_reserve_between_check()
844 ASSERT_EQ(memblock.reserved.total_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.
870 rgn = &memblock.reserved.regions[0]; in memblock_reserve_near_max_check()
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()
887 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_reserve_near_max_check()
888 ASSERT_EQ(memblock.reserved.total_size, total_size); in memblock_reserve_near_max_check()
896 * A test that trying to reserve the 129th memory block.
898 * memblock.memory.max, find a new valid memory as
899 * reserved.regions.
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()
925 ASSERT_EQ(memblock.reserved.cnt, i + 1); in memblock_reserve_many_check()
926 ASSERT_EQ(memblock.reserved.total_size, (i + 1) * MEM_SIZE); in memblock_reserve_many_check()
928 /* Keep the gap so these memory region will not be merged. */ in memblock_reserve_many_check()
932 orig_region = memblock.reserved.regions; 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()
940 * calculate the total_size that the memblock.reserved have now. 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()
947 * there will be one more region exist in the reserved memblock. And the in memblock_reserve_many_check()
948 * one more reserved region's size is new_reserved_regions_size. in memblock_reserve_many_check()
950 ASSERT_EQ(memblock.reserved.cnt, INIT_MEMBLOCK_REGIONS + 2); in memblock_reserve_many_check()
951 ASSERT_EQ(memblock.reserved.total_size, (INIT_MEMBLOCK_REGIONS + 1) * MEM_SIZE + in memblock_reserve_many_check()
953 ASSERT_EQ(memblock.reserved.max, INIT_MEMBLOCK_REGIONS * 2); in memblock_reserve_many_check()
960 ASSERT_EQ(memblock.reserved.regions[0].base, r.base); in memblock_reserve_many_check()
961 ASSERT_EQ(memblock.reserved.regions[0].size, r.size); in memblock_reserve_many_check()
963 ASSERT_EQ(memblock.reserved.cnt, INIT_MEMBLOCK_REGIONS + 3); in memblock_reserve_many_check()
964 ASSERT_EQ(memblock.reserved.total_size, (INIT_MEMBLOCK_REGIONS + 1) * MEM_SIZE + in memblock_reserve_many_check()
967 ASSERT_EQ(memblock.reserved.max, INIT_MEMBLOCK_REGIONS * 2); 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()
977 memblock.reserved.regions = orig_region; in memblock_reserve_many_check()
978 memblock.reserved.cnt = INIT_MEMBLOCK_RESERVED_REGIONS; in memblock_reserve_many_check()
1008 * available memory regions. By "removing" a region we mean overwriting it
1009 * with the next region r2 in memblock.memory:
1011 * | ...... +----------------+ |
1013 * +--+----+----------+----------------+--+
1018 * Expect to add two memory blocks r1 and r2 and then remove r1 so that
1026 rgn = &memblock.memory.regions[0]; in memblock_remove_simple_check()
1044 ASSERT_EQ(rgn->base, r2.base); in memblock_remove_simple_check()
1045 ASSERT_EQ(rgn->size, r2.size); in memblock_remove_simple_check()
1047 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_remove_simple_check()
1048 ASSERT_EQ(memblock.memory.total_size, r2.size); in memblock_remove_simple_check()
1057 * available memory (i.e. has no corresponding entry in memblock.memory):
1059 * +----------------+
1061 * +----------------+
1062 * | +----+ |
1064 * +--+----+------------------------------+
1075 rgn = &memblock.memory.regions[0]; in memblock_remove_absent_check()
1092 ASSERT_EQ(rgn->base, r1.base); in memblock_remove_absent_check()
1093 ASSERT_EQ(rgn->size, r1.size); in memblock_remove_absent_check()
1095 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_remove_absent_check()
1096 ASSERT_EQ(memblock.memory.total_size, r1.size); in memblock_remove_absent_check()
1108 * +-----------------+
1110 * +-----------------+
1111 * | .........+--------+ |
1113 * +-----------------+--------+--------+--+
1120 * available memory pool. The regions counter and total size are updated.
1127 rgn = &memblock.memory.regions[0]; in memblock_remove_overlap_top_check()
1142 total_size = r1_end - r2_end; in memblock_remove_overlap_top_check()
1148 ASSERT_EQ(rgn->base, r1.base + r2.base); in memblock_remove_overlap_top_check()
1149 ASSERT_EQ(rgn->size, total_size); in memblock_remove_overlap_top_check()
1151 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_remove_overlap_top_check()
1152 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_remove_overlap_top_check()
1163 * +--------------------------------+
1165 * +--------------------------------+
1166 * | +---+..... |
1168 * +-+---+----+---------------------------+
1174 * available memory pool. The regions counter and total size are updated.
1181 rgn = &memblock.memory.regions[0]; in memblock_remove_overlap_bottom_check()
1194 total_size = r2.base - r1.base; in memblock_remove_overlap_bottom_check()
1200 ASSERT_EQ(rgn->base, r1.base); in memblock_remove_overlap_bottom_check()
1201 ASSERT_EQ(rgn->size, total_size); in memblock_remove_overlap_bottom_check()
1203 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_remove_overlap_bottom_check()
1204 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_remove_overlap_bottom_check()
1216 * +----+
1218 * +----+
1219 * | +-------------+....+---------------+ |
1221 * +-+-------------+----+---------------+-+
1226 * Expect that the region is split into two - one that ends at r2.base and
1235 rgn1 = &memblock.memory.regions[0]; in memblock_remove_within_check()
1236 rgn2 = &memblock.memory.regions[1]; in memblock_remove_within_check()
1249 r1_size = r2.base - r1.base; in memblock_remove_within_check()
1250 r2_size = (r1.base + r1.size) - (r2.base + r2.size); in memblock_remove_within_check()
1257 ASSERT_EQ(rgn1->base, r1.base); in memblock_remove_within_check()
1258 ASSERT_EQ(rgn1->size, r1_size); in memblock_remove_within_check()
1260 ASSERT_EQ(rgn2->base, r2.base + r2.size); in memblock_remove_within_check()
1261 ASSERT_EQ(rgn2->size, r2_size); in memblock_remove_within_check()
1263 ASSERT_EQ(memblock.memory.cnt, 2); in memblock_remove_within_check()
1264 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_remove_within_check()
1273 * available memory regions when r1 is the only available region.
1274 * Expect to add a memory block r1 and then remove r1 so that a dummy
1282 rgn = &memblock.memory.regions[0]; in memblock_remove_only_region_check()
1295 ASSERT_EQ(rgn->base, 0); in memblock_remove_only_region_check()
1296 ASSERT_EQ(rgn->size, 0); in memblock_remove_only_region_check()
1298 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_remove_only_region_check()
1299 ASSERT_EQ(memblock.memory.total_size, 0); in memblock_remove_only_region_check()
1308 * memory regions when r2 extends past PHYS_ADDR_MAX:
1310 * +--------+
1312 * +--------+
1313 * | +---+....+
1315 * +------------------------+---+----+
1318 * Expect the total size of available memory to be updated and the counter to
1326 rgn = &memblock.memory.regions[0]; in memblock_remove_near_max_check()
1329 .base = PHYS_ADDR_MAX - SZ_2M, in memblock_remove_near_max_check()
1334 .base = PHYS_ADDR_MAX - SZ_1M, in memblock_remove_near_max_check()
1340 total_size = r1.size - (PHYS_ADDR_MAX - r2.base); in memblock_remove_near_max_check()
1346 ASSERT_EQ(rgn->base, r1.base); in memblock_remove_near_max_check()
1347 ASSERT_EQ(rgn->size, total_size); in memblock_remove_near_max_check()
1349 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_remove_near_max_check()
1350 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_remove_near_max_check()
1361 * +----------------+
1363 * +----------------+
1364 * | +----+..... ........+--------+
1366 * +----+----+----+---+-------+--------+-----+
1369 * from the available memory pool. Expect the total size of available memory to
1377 rgn1 = &memblock.memory.regions[0]; in memblock_remove_overlap_two_check()
1378 rgn2 = &memblock.memory.regions[1]; in memblock_remove_overlap_two_check()
1397 new_r1_size = r3.base - r1.base; in memblock_remove_overlap_two_check()
1398 new_r2_size = r2_end - r3_end; in memblock_remove_overlap_two_check()
1406 ASSERT_EQ(rgn1->base, r1.base); in memblock_remove_overlap_two_check()
1407 ASSERT_EQ(rgn1->size, new_r1_size); in memblock_remove_overlap_two_check()
1409 ASSERT_EQ(rgn2->base, r3_end); in memblock_remove_overlap_two_check()
1410 ASSERT_EQ(rgn2->size, new_r2_size); in memblock_remove_overlap_two_check()
1412 ASSERT_EQ(memblock.memory.cnt, 2); in memblock_remove_overlap_two_check()
1413 ASSERT_EQ(memblock.memory.total_size, total_size); in memblock_remove_overlap_two_check()
1441 * A simple test that tries to free a memory block r1 that was marked
1442 * earlier as reserved. By "freeing" a region we mean overwriting it with
1443 * the next entry r2 in memblock.reserved:
1445 * | ...... +----+ |
1447 * +--------------+----+-----------+----+-+
1452 * Expect to reserve two memory regions and then erase r1 region with the
1459 rgn = &memblock.reserved.regions[0]; in memblock_free_simple_check()
1477 ASSERT_EQ(rgn->base, r2.base); in memblock_free_simple_check()
1478 ASSERT_EQ(rgn->size, r2.size); in memblock_free_simple_check()
1480 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_free_simple_check()
1481 ASSERT_EQ(memblock.reserved.total_size, r2.size); in memblock_free_simple_check()
1489 * A test that tries to free a region r2 that was not marked as reserved
1490 * (i.e. has no corresponding entry in memblock.reserved):
1492 * +----------------+
1494 * +----------------+
1495 * | +----+ |
1497 * +--+----+------------------------------+
1508 rgn = &memblock.reserved.regions[0]; in memblock_free_absent_check()
1525 ASSERT_EQ(rgn->base, r1.base); in memblock_free_absent_check()
1526 ASSERT_EQ(rgn->size, r1.size); in memblock_free_absent_check()
1528 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_free_absent_check()
1529 ASSERT_EQ(memblock.reserved.total_size, r1.size); in memblock_free_absent_check()
1540 * +----+
1542 * +----+
1543 * | ...+--------------+ |
1545 * +----+--+--------------+---------------+
1560 rgn = &memblock.reserved.regions[0]; in memblock_free_overlap_top_check()
1573 total_size = (r1.size + r1.base) - (r2.base + r2.size); in memblock_free_overlap_top_check()
1579 ASSERT_EQ(rgn->base, r2.base + r2.size); in memblock_free_overlap_top_check()
1580 ASSERT_EQ(rgn->size, total_size); in memblock_free_overlap_top_check()
1582 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_free_overlap_top_check()
1583 ASSERT_EQ(memblock.reserved.total_size, total_size); in memblock_free_overlap_top_check()
1594 * +----------------+
1596 * +----------------+
1597 * | +-----------+..... |
1599 * +----+-----------+----+----------------+
1609 rgn = &memblock.reserved.regions[0]; in memblock_free_overlap_bottom_check()
1622 total_size = r2.base - r1.base; in memblock_free_overlap_bottom_check()
1628 ASSERT_EQ(rgn->base, r1.base); in memblock_free_overlap_bottom_check()
1629 ASSERT_EQ(rgn->size, total_size); in memblock_free_overlap_bottom_check()
1631 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_free_overlap_bottom_check()
1632 ASSERT_EQ(memblock.reserved.total_size, total_size); in memblock_free_overlap_bottom_check()
1644 * +----+
1646 * +----+
1647 * | +------------+....+---------------+
1649 * +----+------------+----+---------------+
1654 * Expect that the region is split into two - one that ends at r2.base and
1663 rgn1 = &memblock.reserved.regions[0]; in memblock_free_within_check()
1664 rgn2 = &memblock.reserved.regions[1]; in memblock_free_within_check()
1677 r1_size = r2.base - r1.base; in memblock_free_within_check()
1678 r2_size = (r1.base + r1.size) - (r2.base + r2.size); in memblock_free_within_check()
1685 ASSERT_EQ(rgn1->base, r1.base); in memblock_free_within_check()
1686 ASSERT_EQ(rgn1->size, r1_size); in memblock_free_within_check()
1688 ASSERT_EQ(rgn2->base, r2.base + r2.size); in memblock_free_within_check()
1689 ASSERT_EQ(rgn2->size, r2_size); in memblock_free_within_check()
1691 ASSERT_EQ(memblock.reserved.cnt, 2); in memblock_free_within_check()
1692 ASSERT_EQ(memblock.reserved.total_size, total_size); in memblock_free_within_check()
1700 * A simple test that tries to free a memory block r1 that was marked
1701 * earlier as reserved when r1 is the only available region.
1702 * Expect to reserve a memory block r1 and then free r1 so that r1 is
1710 rgn = &memblock.reserved.regions[0]; in memblock_free_only_region_check()
1723 ASSERT_EQ(rgn->base, 0); in memblock_free_only_region_check()
1724 ASSERT_EQ(rgn->size, 0); in memblock_free_only_region_check()
1726 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_free_only_region_check()
1727 ASSERT_EQ(memblock.reserved.total_size, 0); in memblock_free_only_region_check()
1737 * +--------+
1739 * +--------+
1740 * | +---+....+
1742 * +------------------------+---+----+
1745 * Expect the total size of reserved memory to be updated and the counter to
1753 rgn = &memblock.reserved.regions[0]; in memblock_free_near_max_check()
1756 .base = PHYS_ADDR_MAX - SZ_2M, in memblock_free_near_max_check()
1761 .base = PHYS_ADDR_MAX - SZ_1M, in memblock_free_near_max_check()
1767 total_size = r1.size - (PHYS_ADDR_MAX - r2.base); in memblock_free_near_max_check()
1773 ASSERT_EQ(rgn->base, r1.base); in memblock_free_near_max_check()
1774 ASSERT_EQ(rgn->size, total_size); in memblock_free_near_max_check()
1776 ASSERT_EQ(memblock.reserved.cnt, 1); in memblock_free_near_max_check()
1777 ASSERT_EQ(memblock.reserved.total_size, total_size); in memblock_free_near_max_check()
1785 * A test that tries to free a reserved region r3 that overlaps with two
1786 * existing reserved regions r1 and r2:
1788 * +----------------+
1790 * +----------------+
1791 * | +----+..... ........+--------+
1793 * +----+----+----+---+-------+--------+-----+
1796 * from the collection of reserved memory. Expect the total size of reserved
1797 * memory to be updated and the counter to not be updated.
1804 rgn1 = &memblock.reserved.regions[0]; in memblock_free_overlap_two_check()
1805 rgn2 = &memblock.reserved.regions[1]; in memblock_free_overlap_two_check()
1824 new_r1_size = r3.base - r1.base; in memblock_free_overlap_two_check()
1825 new_r2_size = r2_end - r3_end; in memblock_free_overlap_two_check()
1833 ASSERT_EQ(rgn1->base, r1.base); in memblock_free_overlap_two_check()
1834 ASSERT_EQ(rgn1->size, new_r1_size); in memblock_free_overlap_two_check()
1836 ASSERT_EQ(rgn2->base, r3_end); in memblock_free_overlap_two_check()
1837 ASSERT_EQ(rgn2->size, new_r2_size); in memblock_free_overlap_two_check()
1839 ASSERT_EQ(memblock.reserved.cnt, 2); in memblock_free_overlap_two_check()
1840 ASSERT_EQ(memblock.reserved.total_size, total_size); in memblock_free_overlap_two_check()
1912 * A test that tries to trim memory when both ends of the memory region are
1913 * aligned. Expect that the memory will not be trimmed. Expect the counter to
1921 rgn = &memblock.memory.regions[0]; in memblock_trim_memory_aligned_check()
1934 ASSERT_EQ(rgn->base, r.base); in memblock_trim_memory_aligned_check()
1935 ASSERT_EQ(rgn->size, r.size); in memblock_trim_memory_aligned_check()
1937 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_trim_memory_aligned_check()
1945 * A test that tries to trim memory when there are two available regions, r1 and
1950 * |--------|
1951 * | +-----------------+ +------+ |
1953 * +--------+-----------------+--------+------+---+
1967 rgn = &memblock.memory.regions[0]; in memblock_trim_memory_too_small_check()
1975 .size = alignment - SZ_2 in memblock_trim_memory_too_small_check()
1985 ASSERT_EQ(rgn->base, r1.base); in memblock_trim_memory_too_small_check()
1986 ASSERT_EQ(rgn->size, r1.size); in memblock_trim_memory_too_small_check()
1988 ASSERT_EQ(memblock.memory.cnt, 1); in memblock_trim_memory_too_small_check()
1996 * A test that tries to trim memory when there are two available regions, r1 and
2003 * | +-----------------+ +---------------+ |
2005 * +--------+-----------------+----------+---------------+---+
2021 rgn1 = &memblock.memory.regions[0]; in memblock_trim_memory_unaligned_base_check()
2022 rgn2 = &memblock.memory.regions[1]; in memblock_trim_memory_unaligned_base_check()
2030 .size = alignment * 2 - offset in memblock_trim_memory_unaligned_base_check()
2035 new_r2_base = r2.base + (alignment - offset); in memblock_trim_memory_unaligned_base_check()
2036 new_r2_size = r2.size - (alignment - offset); in memblock_trim_memory_unaligned_base_check()
2043 ASSERT_EQ(rgn1->base, r1.base); in memblock_trim_memory_unaligned_base_check()
2044 ASSERT_EQ(rgn1->size, r1.size); in memblock_trim_memory_unaligned_base_check()
2046 ASSERT_EQ(rgn2->base, new_r2_base); in memblock_trim_memory_unaligned_base_check()
2047 ASSERT_EQ(rgn2->size, new_r2_size); in memblock_trim_memory_unaligned_base_check()
2049 ASSERT_EQ(memblock.memory.cnt, 2); in memblock_trim_memory_unaligned_base_check()
2057 * A test that tries to trim memory when there are two available regions, r1 and
2064 * | +-----------------+ +---------------+ |
2066 * +--------+-----------------+--------+---------------+---+
2082 rgn1 = &memblock.memory.regions[0]; in memblock_trim_memory_unaligned_end_check()
2083 rgn2 = &memblock.memory.regions[1]; in memblock_trim_memory_unaligned_end_check()
2091 .size = alignment * 2 - offset in memblock_trim_memory_unaligned_end_check()
2096 new_r2_size = r2.size - (alignment - offset); in memblock_trim_memory_unaligned_end_check()
2103 ASSERT_EQ(rgn1->base, r1.base); in memblock_trim_memory_unaligned_end_check()
2104 ASSERT_EQ(rgn1->size, r1.size); in memblock_trim_memory_unaligned_end_check()
2106 ASSERT_EQ(rgn2->base, r2.base); in memblock_trim_memory_unaligned_end_check()
2107 ASSERT_EQ(rgn2->size, new_r2_size); in memblock_trim_memory_unaligned_end_check()
2109 ASSERT_EQ(memblock.memory.cnt, 2); in memblock_trim_memory_unaligned_end_check()