Skip to content

Commit 96ed62e

Browse files
Yunsheng LinPaolo Abeni
authored andcommitted
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: 7fef0de ("mm: page_frag: add a test module for page_frag") Fixes: 65941f1 ("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>
1 parent a202e60 commit 96ed62e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

tools/testing/selftests/mm/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,16 @@ MAKEFLAGS += --no-builtin-rules
3636
CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES)
3737
LDLIBS = -lrt -lpthread -lm
3838

39+
KDIR ?= /lib/modules/$(shell uname -r)/build
40+
ifneq (,$(wildcard $(KDIR)/Module.symvers))
41+
ifneq (,$(wildcard $(KDIR)/include/linux/page_frag_cache.h))
3942
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
4049

4150
TEST_GEN_FILES = cow
4251
TEST_GEN_FILES += compaction_test
@@ -214,3 +223,12 @@ warn_missing_liburing:
214223
echo "Warning: missing liburing support. Some tests will be skipped." ; \
215224
echo
216225
endif
226+
227+
ifneq ($(PAGE_FRAG_WARNING),)
228+
all: warn_missing_page_frag
229+
230+
warn_missing_page_frag:
231+
@echo ; \
232+
echo "Warning: $(PAGE_FRAG_WARNING). page_frag test will be skipped." ; \
233+
echo
234+
endif

tools/testing/selftests/mm/page_frag/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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
33

44
ifeq ($(V),1)
55
Q =

0 commit comments

Comments
 (0)