Skip to content

Commit 9588076

Browse files
0verflowmerppt
authored andcommitted
tools/testing/memblock: fix stale NUMA reservation tests
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>
1 parent 3a3fc1d commit 9588076

4 files changed

Lines changed: 9 additions & 12 deletions

File tree

tools/testing/memblock/README

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ called at the beginning of each test.
104104
Known issues
105105
============
106106

107-
1. Requesting a specific NUMA node via memblock_alloc_node() does not work as
108-
intended. Once the fix is in place, tests for this function can be added.
109-
110-
2. Tests for memblock_alloc_low() can't be easily implemented. The function uses
107+
1. Tests for memblock_alloc_low() can't be easily implemented. The function uses
111108
ARCH_LOW_ADDRESS_LIMIT marco, which can't be changed to point at the low
112109
memory of the memory_block.
113110

tools/testing/memblock/TODO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TODO
22
=====
33

4-
1. Add tests for memblock_alloc_node() to check if the correct NUMA node is set
5-
for the new region
4+
1. Add tests for memblock_alloc_low() once the simulator can model
5+
ARCH_LOW_ADDRESS_LIMIT against the low memory in memory_block

tools/testing/memblock/tests/alloc_exact_nid_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static int alloc_exact_nid_bottom_up_numa_part_reserved_check(void)
368368
max_addr = memblock_end_of_DRAM();
369369
total_size = size + r1.size;
370370

371-
memblock_reserve(r1.base, r1.size);
371+
__memblock_reserve(r1.base, r1.size, nid_req, MEMBLOCK_RSRV_KERN);
372372
allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
373373
min_addr, max_addr,
374374
nid_req);
@@ -861,8 +861,8 @@ static int alloc_exact_nid_numa_reserved_full_merge_generic_check(void)
861861
min_addr = r2.base + r2.size;
862862
max_addr = r1.base;
863863

864-
memblock_reserve(r1.base, r1.size);
865-
memblock_reserve(r2.base, r2.size);
864+
__memblock_reserve(r1.base, r1.size, nid_req, MEMBLOCK_RSRV_KERN);
865+
__memblock_reserve(r2.base, r2.size, nid_req, MEMBLOCK_RSRV_KERN);
866866

867867
allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
868868
min_addr, max_addr,

tools/testing/memblock/tests/alloc_nid_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,7 +1965,7 @@ static int alloc_nid_bottom_up_numa_part_reserved_check(void)
19651965
max_addr = memblock_end_of_DRAM();
19661966
total_size = size + r1.size;
19671967

1968-
memblock_reserve(r1.base, r1.size);
1968+
__memblock_reserve(r1.base, r1.size, nid_req, MEMBLOCK_RSRV_KERN);
19691969
allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
19701970
min_addr, max_addr, nid_req);
19711971

@@ -2412,8 +2412,8 @@ static int alloc_nid_numa_reserved_full_merge_generic_check(void)
24122412
min_addr = r2.base + r2.size;
24132413
max_addr = r1.base;
24142414

2415-
memblock_reserve(r1.base, r1.size);
2416-
memblock_reserve(r2.base, r2.size);
2415+
__memblock_reserve(r1.base, r1.size, nid_req, MEMBLOCK_RSRV_KERN);
2416+
__memblock_reserve(r2.base, r2.size, nid_req, MEMBLOCK_RSRV_KERN);
24172417

24182418
allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
24192419
min_addr, max_addr, nid_req);

0 commit comments

Comments
 (0)