mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 01:54:09 +08:00
8f98435d67
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 <karolinadrobnik@gmail.com> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> Link: https://lore.kernel.org/r/d6c282e0f9f62c15bf74c216214604764232d637.1646055639.git.karolinadrobnik@gmail.com
56 lines
1.7 KiB
Makefile
56 lines
1.7 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
# Memblock simulator requires AddressSanitizer (libasan) and liburcu development
|
|
# packages installed
|
|
CFLAGS += -I. -I../../include -Wall -O2 -fsanitize=address \
|
|
-fsanitize=undefined -D CONFIG_PHYS_ADDR_T_64BIT
|
|
LDFLAGS += -fsanitize=address -fsanitize=undefined
|
|
TARGETS = main
|
|
TEST_OFILES = tests/alloc_nid_api.o tests/alloc_helpers_api.o tests/alloc_api.o \
|
|
tests/basic_api.o tests/common.o
|
|
DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o
|
|
OFILES = main.o $(DEP_OFILES) $(TEST_OFILES)
|
|
EXTR_SRC = ../../../mm/memblock.c
|
|
|
|
ifeq ($(BUILD), 32)
|
|
CFLAGS += -m32
|
|
LDFLAGS += -m32
|
|
endif
|
|
|
|
# Process user parameters
|
|
include scripts/Makefile.include
|
|
|
|
main: $(OFILES)
|
|
|
|
$(OFILES): include
|
|
|
|
include: ../../../include/linux/memblock.h ../../include/linux/*.h \
|
|
../../include/asm/*.h
|
|
|
|
@mkdir -p linux
|
|
test -L linux/memblock.h || ln -s ../../../../include/linux/memblock.h linux/memblock.h
|
|
test -L asm/cmpxchg.h || ln -s ../../../arch/x86/include/asm/cmpxchg.h asm/cmpxchg.h
|
|
|
|
memblock.c: $(EXTR_SRC)
|
|
test -L memblock.c || ln -s $(EXTR_SRC) memblock.c
|
|
|
|
clean:
|
|
$(RM) $(TARGETS) $(OFILES) linux/memblock.h memblock.c asm/cmpxchg.h
|
|
|
|
help:
|
|
@echo 'Memblock simulator'
|
|
@echo ''
|
|
@echo 'Available targets:'
|
|
@echo ' main - Build the memblock simulator'
|
|
@echo ' clean - Remove generated files and symlinks in the directory'
|
|
@echo ''
|
|
@echo 'Configuration:'
|
|
@echo ' make NUMA=1 - simulate enabled NUMA'
|
|
@echo ' make MOVABLE_NODE=1 - override `movable_node_is_enabled`'
|
|
@echo ' definition to simulate movable NUMA nodes'
|
|
@echo ' make 32BIT_PHYS_ADDR_T=1 - Use 32 bit physical addresses'
|
|
|
|
vpath %.c ../../lib
|
|
|
|
.PHONY: clean include help
|