Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: page_frag: fix a compile error when kernel is not compiled

page_frag test module is an out of tree module, but built
using KDIR as the main kernel tree, the mm test suite is
just getting skipped if newly added page_frag test module
fails to compile due to kernel not yet compiled.

Fix the above problem by ensuring both kernel is built first
and a newer kernel which has page_frag_cache.h is used.

CC: Andrew Morton <akpm@linux-foundation.org>
CC: Alexander Duyck <alexanderduyck@fb.com>
CC: Linux-MM <linux-mm@kvack.org>
Fixes: 7fef0dec415c ("mm: page_frag: add a test module for page_frag")
Fixes: 65941f10caf2 ("mm: move the page fragment allocator from page_alloc into its own file")
Reported-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Tested-by: Mark Brown <broonie@kernel.org>
Link: https://patch.msgid.link/20241119033012.257525-1-linyunsheng@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Yunsheng Lin and committed by
Paolo Abeni
96ed62ea a202e601

+19 -1
+18
tools/testing/selftests/mm/Makefile
··· 36 36 CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES) 37 37 LDLIBS = -lrt -lpthread -lm 38 38 39 + KDIR ?= /lib/modules/$(shell uname -r)/build 40 + ifneq (,$(wildcard $(KDIR)/Module.symvers)) 41 + ifneq (,$(wildcard $(KDIR)/include/linux/page_frag_cache.h)) 39 42 TEST_GEN_MODS_DIR := page_frag 43 + else 44 + PAGE_FRAG_WARNING = "missing page_frag_cache.h, please use a newer kernel" 45 + endif 46 + else 47 + PAGE_FRAG_WARNING = "missing Module.symvers, please have the kernel built first" 48 + endif 40 49 41 50 TEST_GEN_FILES = cow 42 51 TEST_GEN_FILES += compaction_test ··· 221 212 warn_missing_liburing: 222 213 @echo ; \ 223 214 echo "Warning: missing liburing support. Some tests will be skipped." ; \ 215 + echo 216 + endif 217 + 218 + ifneq ($(PAGE_FRAG_WARNING),) 219 + all: warn_missing_page_frag 220 + 221 + warn_missing_page_frag: 222 + @echo ; \ 223 + echo "Warning: $(PAGE_FRAG_WARNING). page_frag test will be skipped." ; \ 224 224 echo 225 225 endif
+1 -1
tools/testing/selftests/mm/page_frag/Makefile
··· 1 1 PAGE_FRAG_TEST_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) 2 - KDIR ?= $(abspath $(PAGE_FRAG_TEST_DIR)/../../../../..) 2 + KDIR ?= /lib/modules/$(shell uname -r)/build 3 3 4 4 ifeq ($(V),1) 5 5 Q =