diff mbox series

[net-next] mm: page_frag: fix a compile error when kernel is not compiled

Message ID 20241116042314.100400-1-yunshenglin0825@gmail.com (mailing list archive)
State New
Headers show
Series [net-next] mm: page_frag: fix a compile error when kernel is not compiled | expand

Commit Message

Yunsheng Lin Nov. 16, 2024, 4:23 a.m. UTC
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 <yunshenglin0825@gmail.com>
---
Mote, page_frag test module is only in the net-next tree for now,
so target the net-next tree.
---
 tools/testing/selftests/mm/Makefile           | 18 ++++++++++++++++++
 tools/testing/selftests/mm/page_frag/Makefile |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

Comments

Yunsheng Lin Nov. 16, 2024, 5:02 a.m. UTC | #1
It seemed that somehow I missed to add the netdev ML:(

On 11/16/2024 12:23 PM, Yunsheng Lin wrote:
> 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 <yunshenglin0825@gmail.com>
> ---
> Mote, page_frag test module is only in the net-next tree for now,
> so target the net-next tree.
> ---
>   tools/testing/selftests/mm/Makefile           | 18 ++++++++++++++++++
>   tools/testing/selftests/mm/page_frag/Makefile |  2 +-
>   2 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
> index acec529baaca..04e04733fc8a 100644
> --- a/tools/testing/selftests/mm/Makefile
> +++ b/tools/testing/selftests/mm/Makefile
> @@ -36,7 +36,16 @@ MAKEFLAGS += --no-builtin-rules
>   CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES)
>   LDLIBS = -lrt -lpthread -lm
>   
> +KDIR ?= /lib/modules/$(shell uname -r)/build
> +ifneq (,$(wildcard $(KDIR)/Module.symvers))
> +ifneq (,$(wildcard $(KDIR)/include/linux/page_frag_cache.h))
>   TEST_GEN_MODS_DIR := page_frag
> +else
> +PAGE_FRAG_WARNING = "missing page_frag_cache.h, please use a newer kernel"
> +endif
> +else
> +PAGE_FRAG_WARNING = "missing Module.symvers, please have the kernel built first"
> +endif
>   
>   TEST_GEN_FILES = cow
>   TEST_GEN_FILES += compaction_test
> @@ -214,3 +223,12 @@ warn_missing_liburing:
>   	echo "Warning: missing liburing support. Some tests will be skipped." ; \
>   	echo
>   endif
> +
> +ifneq ($(PAGE_FRAG_WARNING),)
> +all: warn_missing_page_frag
> +
> +warn_missing_page_frag:
> +	@echo ; \
> +	echo "Warning: $(PAGE_FRAG_WARNING). page_frag test will be skipped." ; \
> +	echo
> +endif
> diff --git a/tools/testing/selftests/mm/page_frag/Makefile b/tools/testing/selftests/mm/page_frag/Makefile
> index 58dda74d50a3..8c8bb39ffa28 100644
> --- a/tools/testing/selftests/mm/page_frag/Makefile
> +++ b/tools/testing/selftests/mm/page_frag/Makefile
> @@ -1,5 +1,5 @@
>   PAGE_FRAG_TEST_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
> -KDIR ?= $(abspath $(PAGE_FRAG_TEST_DIR)/../../../../..)
> +KDIR ?= /lib/modules/$(shell uname -r)/build
>   
>   ifeq ($(V),1)
>   Q =
Mark Brown Nov. 18, 2024, 6:12 p.m. UTC | #2
On Sat, Nov 16, 2024 at 12:23:13PM +0800, Yunsheng Lin wrote:
> 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.

Tested-by: Mark Brown <broonie@kernel.org>

(for the case where we skip the build.)
Jakub Kicinski Nov. 18, 2024, 11:46 p.m. UTC | #3
On Sat, 16 Nov 2024 13:02:38 +0800 Yunsheng Lin wrote:
> It seemed that somehow I missed to add the netdev ML:(

Then repost, please.
diff mbox series

Patch

diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
index acec529baaca..04e04733fc8a 100644
--- a/tools/testing/selftests/mm/Makefile
+++ b/tools/testing/selftests/mm/Makefile
@@ -36,7 +36,16 @@  MAKEFLAGS += --no-builtin-rules
 CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES)
 LDLIBS = -lrt -lpthread -lm
 
+KDIR ?= /lib/modules/$(shell uname -r)/build
+ifneq (,$(wildcard $(KDIR)/Module.symvers))
+ifneq (,$(wildcard $(KDIR)/include/linux/page_frag_cache.h))
 TEST_GEN_MODS_DIR := page_frag
+else
+PAGE_FRAG_WARNING = "missing page_frag_cache.h, please use a newer kernel"
+endif
+else
+PAGE_FRAG_WARNING = "missing Module.symvers, please have the kernel built first"
+endif
 
 TEST_GEN_FILES = cow
 TEST_GEN_FILES += compaction_test
@@ -214,3 +223,12 @@  warn_missing_liburing:
 	echo "Warning: missing liburing support. Some tests will be skipped." ; \
 	echo
 endif
+
+ifneq ($(PAGE_FRAG_WARNING),)
+all: warn_missing_page_frag
+
+warn_missing_page_frag:
+	@echo ; \
+	echo "Warning: $(PAGE_FRAG_WARNING). page_frag test will be skipped." ; \
+	echo
+endif
diff --git a/tools/testing/selftests/mm/page_frag/Makefile b/tools/testing/selftests/mm/page_frag/Makefile
index 58dda74d50a3..8c8bb39ffa28 100644
--- a/tools/testing/selftests/mm/page_frag/Makefile
+++ b/tools/testing/selftests/mm/page_frag/Makefile
@@ -1,5 +1,5 @@ 
 PAGE_FRAG_TEST_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
-KDIR ?= $(abspath $(PAGE_FRAG_TEST_DIR)/../../../../..)
+KDIR ?= /lib/modules/$(shell uname -r)/build
 
 ifeq ($(V),1)
 Q =