/* * contains the fraction of MEM_SIZE contained in each node in basis point * units (one hundredth of 1% or 1/10000)
*/ staticconstunsignedint node_fractions[] = {
2500, /* 1/4 */
625, /* 1/16 */
1250, /* 1/8 */
1250, /* 1/8 */
625, /* 1/16 */
625, /* 1/16 */
2500, /* 1/4 */
625, /* 1/16 */
};
/* * A test that tries to allocate a memory region in a specific NUMA node that * has enough memory to allocate a region of the requested size. * Expect to allocate an aligned region at the end of the requested node.
*/ staticint alloc_exact_nid_top_down_numa_simple_check(void)
{ int nid_req = 3; struct memblock_region *new_rgn = &memblock.reserved.regions[0]; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; void *allocated_ptr = NULL;
phys_addr_t size;
phys_addr_t min_addr;
phys_addr_t max_addr;
/* * A test that tries to allocate a memory region in a specific NUMA node that * is partially reserved but has enough memory for the allocated region: * * | +---------------------------------------+ | * | | requested | | * +-----------+---------------------------------------+----------+ * * | +------------------+ +-----+ | * | | reserved | | new | | * +-----------+------------------+--------------+-----+----------+ * * Expect to allocate an aligned region at the end of the requested node. The * region count and total size get updated.
*/ staticint alloc_exact_nid_top_down_numa_part_reserved_check(void)
{ int nid_req = 4; struct memblock_region *new_rgn = &memblock.reserved.regions[1]; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; void *allocated_ptr = NULL; struct region r1;
phys_addr_t size;
phys_addr_t min_addr;
phys_addr_t max_addr;
/* * A test that tries to allocate a memory region that spans over the min_addr * and max_addr range and overlaps with two different nodes, where the first * node is the requested node: * * min_addr * | max_addr * | | * v v * | +-----------------------+-----------+ | * | | requested | node3 | | * +-----------+-----------------------+-----------+--------------+ * + + * | +-----------+ | * | | rgn | | * +-----------------------+-----------+--------------------------+ * * Expect to drop the lower limit and allocate a memory region that ends at * the end of the requested node.
*/ staticint alloc_exact_nid_top_down_numa_split_range_low_check(void)
{ int nid_req = 2; struct memblock_region *new_rgn = &memblock.reserved.regions[0]; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; void *allocated_ptr = NULL;
phys_addr_t size = SZ_512;
phys_addr_t min_addr;
phys_addr_t max_addr;
phys_addr_t req_node_end;
/* * A test that tries to allocate a memory region that spans over the min_addr * and max_addr range and overlaps with two different nodes, where the requested * node ends before min_addr: * * min_addr * | max_addr * | | * v v * | +---------------+ +-------------+---------+ | * | | requested | | node1 | node2 | | * +----+---------------+--------+-------------+---------+----------+ * + + * | +---------+ | * | | rgn | | * +----------+---------+-------------------------------------------+ * * Expect to drop the lower limit and allocate a memory region that ends at * the end of the requested node.
*/ staticint alloc_exact_nid_top_down_numa_no_overlap_split_check(void)
{ int nid_req = 2; struct memblock_region *new_rgn = &memblock.reserved.regions[0]; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; struct memblock_region *node2 = &memblock.memory.regions[6]; void *allocated_ptr = NULL;
phys_addr_t size;
phys_addr_t min_addr;
phys_addr_t max_addr;
/* * A test that tries to allocate memory within min_addr and max_add range when * the requested node and the range do not overlap, and requested node ends * before min_addr. The range overlaps with multiple nodes along node * boundaries: * * min_addr * | max_addr * | | * v v * |-----------+ +----------+----...----+----------+ | * | requested | | min node | ... | max node | | * +-----------+-----------+----------+----...----+----------+------+ * + + * | +-----+ | * | | rgn | | * +-----+-----+----------------------------------------------------+ * * Expect to drop the lower limit and allocate a memory region that ends at * the end of the requested node.
*/ staticint alloc_exact_nid_top_down_numa_no_overlap_low_check(void)
{ int nid_req = 0; struct memblock_region *new_rgn = &memblock.reserved.regions[0]; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; struct memblock_region *min_node = &memblock.memory.regions[2]; struct memblock_region *max_node = &memblock.memory.regions[5]; void *allocated_ptr = NULL;
phys_addr_t size = SZ_64;
phys_addr_t max_addr;
phys_addr_t min_addr;
/* * A test that tries to allocate a memory region in a specific NUMA node that * has enough memory to allocate a region of the requested size. * Expect to allocate an aligned region at the beginning of the requested node.
*/ staticint alloc_exact_nid_bottom_up_numa_simple_check(void)
{ int nid_req = 3; struct memblock_region *new_rgn = &memblock.reserved.regions[0]; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; void *allocated_ptr = NULL;
phys_addr_t size;
phys_addr_t min_addr;
phys_addr_t max_addr;
/* * A test that tries to allocate a memory region in a specific NUMA node that * is partially reserved but has enough memory for the allocated region: * * | +---------------------------------------+ | * | | requested | | * +-----------+---------------------------------------+---------+ * * | +------------------+-----+ | * | | reserved | new | | * +-----------+------------------+-----+------------------------+ * * Expect to allocate an aligned region in the requested node that merges with * the existing reserved region. The total size gets updated.
*/ staticint alloc_exact_nid_bottom_up_numa_part_reserved_check(void)
{ int nid_req = 4; struct memblock_region *new_rgn = &memblock.reserved.regions[0]; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; void *allocated_ptr = NULL; struct region r1;
phys_addr_t size;
phys_addr_t min_addr;
phys_addr_t max_addr;
phys_addr_t total_size;
/* * A test that tries to allocate a memory region that spans over the min_addr * and max_addr range and overlaps with two different nodes, where the first * node is the requested node: * * min_addr * | max_addr * | | * v v * | +-----------------------+-----------+ | * | | requested | node3 | | * +-----------+-----------------------+-----------+--------------+ * + + * | +-----------+ | * | | rgn | | * +-----------+-----------+--------------------------------------+ * * Expect to drop the lower limit and allocate a memory region at the beginning * of the requested node.
*/ staticint alloc_exact_nid_bottom_up_numa_split_range_low_check(void)
{ int nid_req = 2; struct memblock_region *new_rgn = &memblock.reserved.regions[0]; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; void *allocated_ptr = NULL;
phys_addr_t size = SZ_512;
phys_addr_t min_addr;
phys_addr_t max_addr;
phys_addr_t req_node_end;
/* * A test that tries to allocate a memory region that spans over the min_addr * and max_addr range and overlaps with two different nodes, where the requested * node ends before min_addr: * * min_addr * | max_addr * | | * v v * | +---------------+ +-------------+---------+ | * | | requested | | node1 | node2 | | * +----+---------------+--------+-------------+---------+---------+ * + + * | +---------+ | * | | rgn | | * +----+---------+------------------------------------------------+ * * Expect to drop the lower limit and allocate a memory region that starts at * the beginning of the requested node.
*/ staticint alloc_exact_nid_bottom_up_numa_no_overlap_split_check(void)
{ int nid_req = 2; struct memblock_region *new_rgn = &memblock.reserved.regions[0]; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; struct memblock_region *node2 = &memblock.memory.regions[6]; void *allocated_ptr = NULL;
phys_addr_t size;
phys_addr_t min_addr;
phys_addr_t max_addr;
/* * A test that tries to allocate memory within min_addr and max_add range when * the requested node and the range do not overlap, and requested node ends * before min_addr. The range overlaps with multiple nodes along node * boundaries: * * min_addr * | max_addr * | | * v v * |-----------+ +----------+----...----+----------+ | * | requested | | min node | ... | max node | | * +-----------+-----------+----------+----...----+----------+------+ * + + * |-----+ | * | rgn | | * +-----+----------------------------------------------------------+ * * Expect to drop the lower limit and allocate a memory region that starts at * the beginning of the requested node.
*/ staticint alloc_exact_nid_bottom_up_numa_no_overlap_low_check(void)
{ int nid_req = 0; struct memblock_region *new_rgn = &memblock.reserved.regions[0]; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; struct memblock_region *min_node = &memblock.memory.regions[2]; struct memblock_region *max_node = &memblock.memory.regions[5]; void *allocated_ptr = NULL;
phys_addr_t size = SZ_64;
phys_addr_t max_addr;
phys_addr_t min_addr;
/* * A test that tries to allocate a memory region in a specific NUMA node that * does not have enough memory to allocate a region of the requested size: * * | +-----+ | * | | req | | * +---+-----+----------------------------+ * * +---------+ * | rgn | * +---------+ * * Expect no allocation to happen.
*/ staticint alloc_exact_nid_numa_small_node_generic_check(void)
{ int nid_req = 1; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; void *allocated_ptr = NULL;
phys_addr_t size;
phys_addr_t min_addr;
phys_addr_t max_addr;
/* * A test that tries to allocate a memory region in a specific NUMA node that * is fully reserved: * * | +---------+ | * | |requested| | * +--------------+---------+-------------+ * * | +---------+ | * | | reserved| | * +--------------+---------+-------------+ * * Expect no allocation to happen.
*/ staticint alloc_exact_nid_numa_node_reserved_generic_check(void)
{ int nid_req = 2; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; void *allocated_ptr = NULL;
phys_addr_t size;
phys_addr_t min_addr;
phys_addr_t max_addr;
/* * A test that tries to allocate a memory region in a specific NUMA node that * is partially reserved and does not have enough contiguous memory for the * allocated region: * * | +-----------------------+ | * | | requested | | * +-----------+-----------------------+----+ * * | +----------+ | * | | reserved | | * +-----------------+----------+-----------+ * * Expect no allocation to happen.
*/ staticint alloc_exact_nid_numa_part_reserved_fail_generic_check(void)
{ int nid_req = 4; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; void *allocated_ptr = NULL; struct region r1;
phys_addr_t size;
phys_addr_t min_addr;
phys_addr_t max_addr;
/* * A test that tries to allocate a memory region that spans over the min_addr * and max_addr range and overlaps with two different nodes, where the second * node is the requested node: * * min_addr * | max_addr * | | * v v * | +--------------------------+---------+ | * | | first node |requested| | * +------+--------------------------+---------+----------------+ * * Expect no allocation to happen.
*/ staticint alloc_exact_nid_numa_split_range_high_generic_check(void)
{ int nid_req = 3; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; void *allocated_ptr = NULL;
phys_addr_t size = SZ_512;
phys_addr_t min_addr;
phys_addr_t max_addr;
/* * A test that tries to allocate memory within min_addr and max_add range when * the requested node and the range do not overlap, and requested node starts * after max_addr. The range overlaps with multiple nodes along node * boundaries: * * min_addr * | max_addr * | | * v v * | +----------+----...----+----------+ +-----------+ | * | | min node | ... | max node | | requested | | * +-----+----------+----...----+----------+--------+-----------+---+ * * Expect no allocation to happen.
*/ staticint alloc_exact_nid_numa_no_overlap_high_generic_check(void)
{ int nid_req = 7; struct memblock_region *min_node = &memblock.memory.regions[2]; struct memblock_region *max_node = &memblock.memory.regions[5]; void *allocated_ptr = NULL;
phys_addr_t size = SZ_64;
phys_addr_t max_addr;
phys_addr_t min_addr;
/* * A test that tries to allocate a memory region in a specific NUMA node that * does not have enough memory to allocate a region of the requested size. * Additionally, none of the nodes have enough memory to allocate the region: * * +-----------------------------------+ * | new | * +-----------------------------------+ * |-------+-------+-------+-------+-------+-------+-------+-------| * | node0 | node1 | node2 | node3 | node4 | node5 | node6 | node7 | * +-------+-------+-------+-------+-------+-------+-------+-------+ * * Expect no allocation to happen.
*/ staticint alloc_exact_nid_numa_large_region_generic_check(void)
{ int nid_req = 3; void *allocated_ptr = NULL;
phys_addr_t size = MEM_SIZE / SZ_2;
phys_addr_t min_addr;
phys_addr_t max_addr;
/* * A test that tries to allocate memory within min_addr and max_addr range when * there are two reserved regions at the borders. The requested node starts at * min_addr and ends at max_addr and is the same size as the region to be * allocated: * * min_addr * | max_addr * | | * v v * | +-----------+-----------------------+-----------------------| * | | node5 | requested | node7 | * +------+-----------+-----------------------+-----------------------+ * + + * | +----+-----------------------+----+ | * | | r2 | new | r1 | | * +-------------+----+-----------------------+----+------------------+ * * Expect to merge all of the regions into one. The region counter and total * size fields get updated.
*/ staticint alloc_exact_nid_numa_reserved_full_merge_generic_check(void)
{ int nid_req = 6; int nid_next = nid_req + 1; struct memblock_region *new_rgn = &memblock.reserved.regions[0]; struct memblock_region *req_node = &memblock.memory.regions[nid_req]; struct memblock_region *next_node = &memblock.memory.regions[nid_next]; void *allocated_ptr = NULL; struct region r1, r2;
phys_addr_t size = req_node->size;
phys_addr_t total_size;
phys_addr_t max_addr;
phys_addr_t min_addr;
/* * A test that tries to allocate memory within min_addr and max_add range, * where the total range can fit the region, but it is split between two nodes * and everything else is reserved. Additionally, nid is set to NUMA_NO_NODE * instead of requesting a specific node: * * +-----------+ * | new | * +-----------+ * | +---------------------+-----------| * | | prev node | next node | * +------+---------------------+-----------+ * + + * |----------------------+ +-----| * | r1 | | r2 | * +----------------------+-----------+-----+ * ^ ^ * | | * | max_addr * | * min_addr * * Expect no allocation to happen.
*/ staticint alloc_exact_nid_numa_split_all_reserved_generic_check(void)
{ void *allocated_ptr = NULL; struct memblock_region *next_node = &memblock.memory.regions[7]; struct region r1, r2;
phys_addr_t size = SZ_256;
phys_addr_t max_addr;
phys_addr_t min_addr;
/* Test case wrappers for NUMA tests */ staticint alloc_exact_nid_numa_simple_check(void)
{
test_print("\tRunning %s...\n", __func__);
memblock_set_bottom_up(false);
alloc_exact_nid_top_down_numa_simple_check();
memblock_set_bottom_up(true);
alloc_exact_nid_bottom_up_numa_simple_check();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.