Lines Matching +full:memory +full:- +full:region

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.
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()
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
66 * to higher addresses, so the new region will be the first entry in
67 * memory.reserved array. The previously reserved region does not get modified.
68 * Region counter and total size get updated.
72 /* After allocation, this will point to the "old" region */ in alloc_top_down_disjoint_check()
75 struct region r1; 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()
114 * A test that tries to allocate memory when there is enough space at the end
117 * | +--------+--------------|
119 * +--------------+--------+--------------+
121 * Expect a merge of both regions. Only the region size gets updated.
128 * The first region ends at the aligned address to test region merging 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()
156 * A test that tries to allocate memory when there is not enough space at the
159 * | +-----------+------+ |
161 * +------------+-----------+------+-----+
163 * Expect a merge of both regions. Both the base address and size of the region
169 struct region r1; in alloc_top_down_after_check()
178 * The first region starts at the aligned address to test region merging 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()
204 * A test that tries to allocate memory when there are two reserved regions with
205 * a gap too small to fit the new region:
207 * | +--------+----------+ +------|
209 * +-------+--------+----------+---+------+
211 * Expect to allocate a region before the one that starts at the lower address,
212 * and merge them into one. The region counter and total size fields get
218 struct region r1, r2; 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()
254 * A test that tries to allocate memory when there are two reserved regions with
255 * a gap big enough to accommodate the new region:
257 * | +--------+--------+--------+ |
259 * +-----+--------+--------+--------+-----+
262 * array. The region counter and total size fields get updated.
267 struct region r1, r2; 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()
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,
371 * with not enough space left for the new region:
373 * +-------+
375 * +-------+
376 * |-----------------------------+ |
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 * |---------------------------+---------|
409 * +---------------------------+---------+
411 * Expect to allocate memory and merge all the regions. The total size field
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()
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).
460 ASSERT_EQ(rgn->size, 0); in alloc_no_memory_generic_check()
461 ASSERT_EQ(rgn->base, 0); in alloc_no_memory_generic_check()
470 * A test that tries to allocate a region that is larger than the total size of
471 * available memory (memblock.memory):
473 * +-----------------------------------+
475 * +-----------------------------------+
478 * +---------------------------------+
493 ASSERT_EQ(rgn->size, 0); in alloc_too_large_generic_check()
494 ASSERT_EQ(rgn->base, 0); in alloc_too_large_generic_check()
503 * A simple test that tries to allocate a small memory region.
504 * Expect to allocate an aligned region at the beginning of the available
505 * memory.
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()
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
546 * modified. Region counter and total size get updated.
552 struct region r1; 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()
591 * A test that tries to allocate memory when there is enough space at
594 * |------------------+--------+ |
596 * +------------------+--------+---------+
598 * Expect a merge of both regions. Only the region size gets updated.
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()
630 * A test that tries to allocate memory when there is not enough space at
633 * | +--------+--------------+ |
635 * +----+--------+--------------+---------+
637 * Expect a merge of both regions. Only the region size gets updated.
642 struct region r1; in alloc_bottom_up_after_check()
651 * The first region starts at the aligned address to test region merging 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()
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
679 * small to fit the new region:
681 * |------------+ +--------+--------+ |
683 * +------------+-----+--------+--------+--+
685 * Expect to allocate after the second region, which starts at the higher
686 * address, and merge them into one. The region counter and total size fields
692 struct region r1, r2; 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()