mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
Add tests for memblock_alloc_node()
This test is aimed at verifying the memblock_alloc_node() to work as expected, so setting the correct NUMA node for the new allocated region. The memblock_alloc_node() is called directly without using any stub. The core check is between the requested NUMA node and the `nid` field inside the memblock_region structure. These two are supposed to be equal for the test to succeed. Signed-off-by: Claudio Migliorelli <claudio.migliorelli@mail.polimi.it> Link: https://lore.kernel.org/r/ea5e938e-6b74-b188-af59-4b94b18bc0@mail.polimi.it Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
This commit is contained in:
parent
44c026a73b
commit
b842f4f558
1 changed files with 40 additions and 0 deletions
|
@ -2494,6 +2494,35 @@ static int alloc_nid_numa_split_all_reserved_generic_check(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A simple test that tries to allocate a memory region through the
|
||||||
|
* memblock_alloc_node() on a NUMA node with id `nid`. Expected to have the
|
||||||
|
* correct NUMA node set for the new region.
|
||||||
|
*/
|
||||||
|
static int alloc_node_on_correct_nid(void)
|
||||||
|
{
|
||||||
|
int nid_req = 2;
|
||||||
|
void *allocated_ptr = NULL;
|
||||||
|
#ifdef CONFIG_NUMA
|
||||||
|
struct memblock_region *req_node = &memblock.memory.regions[nid_req];
|
||||||
|
#endif
|
||||||
|
phys_addr_t size = SZ_512;
|
||||||
|
|
||||||
|
PREFIX_PUSH();
|
||||||
|
setup_numa_memblock(node_fractions);
|
||||||
|
|
||||||
|
allocated_ptr = memblock_alloc_node(size, SMP_CACHE_BYTES, nid_req);
|
||||||
|
|
||||||
|
ASSERT_NE(allocated_ptr, NULL);
|
||||||
|
#ifdef CONFIG_NUMA
|
||||||
|
ASSERT_EQ(nid_req, req_node->nid);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
test_pass_pop();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Test case wrappers for NUMA tests */
|
/* Test case wrappers for NUMA tests */
|
||||||
static int alloc_nid_numa_simple_check(void)
|
static int alloc_nid_numa_simple_check(void)
|
||||||
{
|
{
|
||||||
|
@ -2632,6 +2661,15 @@ static int alloc_nid_numa_split_all_reserved_check(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int alloc_node_numa_on_correct_nid(void)
|
||||||
|
{
|
||||||
|
test_print("\tRunning %s...\n", __func__);
|
||||||
|
run_top_down(alloc_node_on_correct_nid);
|
||||||
|
run_bottom_up(alloc_node_on_correct_nid);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int __memblock_alloc_nid_numa_checks(void)
|
int __memblock_alloc_nid_numa_checks(void)
|
||||||
{
|
{
|
||||||
test_print("Running %s NUMA tests...\n",
|
test_print("Running %s NUMA tests...\n",
|
||||||
|
@ -2652,6 +2690,8 @@ int __memblock_alloc_nid_numa_checks(void)
|
||||||
alloc_nid_numa_reserved_full_merge_check();
|
alloc_nid_numa_reserved_full_merge_check();
|
||||||
alloc_nid_numa_split_all_reserved_check();
|
alloc_nid_numa_split_all_reserved_check();
|
||||||
|
|
||||||
|
alloc_node_numa_on_correct_nid();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue