Skip to content

Commit 8f98435

Browse files
drobnikrppt
authored andcommitted
memblock tests: Add memblock_alloc_try_nid tests for top down
Add tests for memblock_alloc_try_nid for top down allocation direction. As the definition of this function is pretty close to the core memblock_alloc_range_nid, the test cases implemented here cover most of the code paths related to the memory allocations. The tested scenarios are: - Region can be allocated within the requested range (both with aligned and misaligned boundaries) - Region can be allocated between two already existing entries - Not enough space between already reserved regions - Memory range is too narrow but memory can be allocated before the maximum address - Edge cases: + Minimum address is below memblock_start_of_DRAM() + Maximum address is above memblock_end_of_DRAM() Add checks for both allocation directions: - Region starts at the min_addr and ends at max_addr - Maximum address is too close to the beginning of the available memory - Memory at the range boundaries is reserved but there is enough space to allocate a new region Signed-off-by: Karolina Drobnik <[email protected]> Signed-off-by: Mike Rapoport <[email protected]> Link: https://lore.kernel.org/r/d6c282e0f9f62c15bf74c216214604764232d637.1646055639.git.karolinadrobnik@gmail.com
1 parent 0ac0663 commit 8f98435

File tree

4 files changed

+692
-2
lines changed

4 files changed

+692
-2
lines changed

tools/testing/memblock/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ CFLAGS += -I. -I../../include -Wall -O2 -fsanitize=address \
66
-fsanitize=undefined -D CONFIG_PHYS_ADDR_T_64BIT
77
LDFLAGS += -fsanitize=address -fsanitize=undefined
88
TARGETS = main
9-
TEST_OFILES = tests/alloc_helpers_api.o tests/alloc_api.o tests/basic_api.o \
10-
tests/common.o
9+
TEST_OFILES = tests/alloc_nid_api.o tests/alloc_helpers_api.o tests/alloc_api.o \
10+
tests/basic_api.o tests/common.o
1111
DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o
1212
OFILES = main.o $(DEP_OFILES) $(TEST_OFILES)
1313
EXTR_SRC = ../../../mm/memblock.c

tools/testing/memblock/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
#include "tests/basic_api.h"
33
#include "tests/alloc_api.h"
44
#include "tests/alloc_helpers_api.h"
5+
#include "tests/alloc_nid_api.h"
56

67
int main(int argc, char **argv)
78
{
89
memblock_basic_checks();
910
memblock_alloc_checks();
1011
memblock_alloc_helpers_checks();
12+
memblock_alloc_nid_checks();
1113

1214
return 0;
1315
}

0 commit comments

Comments
 (0)