]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tools/testing/memblock: fix stale NUMA reservation tests
authorPriyanshu Kumar <priyanshukumarpu@gmail.com>
Wed, 15 Apr 2026 12:27:31 +0000 (12:27 +0000)
committerMike Rapoport (Microsoft) <rppt@kernel.org>
Tue, 2 Jun 2026 05:34:03 +0000 (08:34 +0300)
memblock allocations now reserve memory with MEMBLOCK_RSRV_KERN and,
on NUMA configurations, record the requested node on the reserved
region. Several memblock simulator NUMA tests still expected merges
that only worked before those reservation semantics changed, so the
suite aborted even though the allocator behavior was correct.

Update the NUMA merge expectations in the memblock_alloc_try_nid()
and memblock_alloc_exact_nid_raw() tests to match the current reserved
region metadata rules. For cases that should still merge, create the
pre-existing reservation with matching nid and MEMBLOCK_RSRV_KERN
metadata. Also strengthen the memblock_alloc_node() coverage by
checking the newly created reserved region directly instead of
re-reading the source memory node descriptor.

Finally, drop the stale README/TODO notes that still claimed
memblock_alloc_node() could not be tested.

The memblock simulator passes again with NUMA enabled after these
updates.

Signed-off-by: Priyanshu Kumar <priyanshukumarpu@gmail.com>
Link: https://patch.msgid.link/20260415122731.1768912-1-priyanshukumarpu@gmail.com
[rppt: dropped unrelated changes]
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
tools/testing/memblock/README
tools/testing/memblock/TODO
tools/testing/memblock/tests/alloc_exact_nid_api.c
tools/testing/memblock/tests/alloc_nid_api.c

index 7ca437d818067af9bcdb5760110175a8ae2d8f35..b435f48d8a7003fd28a1f8ef96cfea515cff22d9 100644 (file)
@@ -104,10 +104,7 @@ called at the beginning of each test.
 Known issues
 ============
 
-1. Requesting a specific NUMA node via memblock_alloc_node() does not work as
-   intended. Once the fix is in place, tests for this function can be added.
-
-2. Tests for memblock_alloc_low() can't be easily implemented. The function uses
+1. Tests for memblock_alloc_low() can't be easily implemented. The function uses
    ARCH_LOW_ADDRESS_LIMIT marco, which can't be changed to point at the low
    memory of the memory_block.
 
index e306c90c535fbade803832b20d1769eba23ea837..c13ad0dae776357e9c0fd48f44a08b6507c18181 100644 (file)
@@ -1,5 +1,5 @@
 TODO
 =====
 
-1. Add tests for memblock_alloc_node() to check if the correct NUMA node is set
-   for the new region
+1. Add tests for memblock_alloc_low() once the simulator can model
+   ARCH_LOW_ADDRESS_LIMIT against the low memory in memory_block
index 6e14447da6e1c38e08c15683f76b432cfd5f209a..0c46c73b5e0419dfac7516acbc1002f13caae930 100644 (file)
@@ -368,7 +368,7 @@ static int alloc_exact_nid_bottom_up_numa_part_reserved_check(void)
        max_addr = memblock_end_of_DRAM();
        total_size = size + r1.size;
 
-       memblock_reserve(r1.base, r1.size);
+       __memblock_reserve(r1.base, r1.size, nid_req, MEMBLOCK_RSRV_KERN);
        allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
                                                     min_addr, max_addr,
                                                     nid_req);
@@ -861,8 +861,8 @@ static int alloc_exact_nid_numa_reserved_full_merge_generic_check(void)
        min_addr = r2.base + r2.size;
        max_addr = r1.base;
 
-       memblock_reserve(r1.base, r1.size);
-       memblock_reserve(r2.base, r2.size);
+       __memblock_reserve(r1.base, r1.size, nid_req, MEMBLOCK_RSRV_KERN);
+       __memblock_reserve(r2.base, r2.size, nid_req, MEMBLOCK_RSRV_KERN);
 
        allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
                                                     min_addr, max_addr,
index 562e4701b0e0265ce169deb0e426e6dabab84420..c049235321594f427b6b46fa7a354fbf8b84052c 100644 (file)
@@ -1965,7 +1965,7 @@ static int alloc_nid_bottom_up_numa_part_reserved_check(void)
        max_addr = memblock_end_of_DRAM();
        total_size = size + r1.size;
 
-       memblock_reserve(r1.base, r1.size);
+       __memblock_reserve(r1.base, r1.size, nid_req, MEMBLOCK_RSRV_KERN);
        allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
                                               min_addr, max_addr, nid_req);
 
@@ -2412,8 +2412,8 @@ static int alloc_nid_numa_reserved_full_merge_generic_check(void)
        min_addr = r2.base + r2.size;
        max_addr = r1.base;
 
-       memblock_reserve(r1.base, r1.size);
-       memblock_reserve(r2.base, r2.size);
+       __memblock_reserve(r1.base, r1.size, nid_req, MEMBLOCK_RSRV_KERN);
+       __memblock_reserve(r2.base, r2.size, nid_req, MEMBLOCK_RSRV_KERN);
 
        allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
                                               min_addr, max_addr, nid_req);