All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v5 0/2] make: Add kernel modules targets, FORCE_MODULES=1
@ 2025-08-15  8:19 Petr Vorel
  2025-08-15  8:19 ` [LTP] [PATCH v5 1/2] Makefile: Add kernel modules related make targets Petr Vorel
  2025-08-15  8:19 ` [LTP] [PATCH v5 2/2] modules.mk: Add FORCE_MODULES=1 to fail on error Petr Vorel
  0 siblings, 2 replies; 6+ messages in thread
From: Petr Vorel @ 2025-08-15  8:19 UTC (permalink / raw)
  To: ltp; +Cc: Ricardo B . Marlière

Changes v4->v5:
Properly handle exit on error (Li).

Link to v4:
https://patchwork.ozlabs.org/project/ltp/list/?series=468222&state=*

Link to v3:
https://patchwork.ozlabs.org/project/ltp/list/?series=468187&state=*

Link to v2:
https://patchwork.ozlabs.org/project/ltp/patch/20250801100935.974351-1-pvorel@suse.cz/

Link to v1:
https://patchwork.ozlabs.org/project/ltp/patch/20250801094205.965645-1-pvorel@suse.cz/

Petr Vorel (2):
  Makefile: Add kernel modules related make targets
  modules.mk: Add FORCE_MODULES=1 to fail on error

 INSTALL              | 16 ++++++++++++++++
 Makefile             | 21 +++++++++++++++++++++
 include/mk/module.mk | 24 +++++++++++++++++++++++-
 3 files changed, 60 insertions(+), 1 deletion(-)

-- 
2.50.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH v5 1/2] Makefile: Add kernel modules related make targets
  2025-08-15  8:19 [LTP] [PATCH v5 0/2] make: Add kernel modules targets, FORCE_MODULES=1 Petr Vorel
@ 2025-08-15  8:19 ` Petr Vorel
  2025-08-15  8:19 ` [LTP] [PATCH v5 2/2] modules.mk: Add FORCE_MODULES=1 to fail on error Petr Vorel
  1 sibling, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2025-08-15  8:19 UTC (permalink / raw)
  To: ltp; +Cc: Ricardo B . Marlière

LTP contains few kernel modules and tests which are using them.  These
require to be built with the same kernel headers as the running kernel
(SUT). Sometimes the best way to achieve this is to compile them on the
SUT.

Add 'modules', 'modules-clean' and 'modules-install' make targets to
make it easier to build them.

Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 INSTALL  | 10 ++++++++++
 Makefile | 21 +++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/INSTALL b/INSTALL
index cbe27f32ea..10c19d4105 100644
--- a/INSTALL
+++ b/INSTALL
@@ -165,6 +165,16 @@ PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig CFLAGS=-m32 LDFLAGS=-m32 ./c
 * Arch Linux
 PKG_CONFIG_LIBDIR=/usr/lib32/pkgconfig CFLAGS=-m32 LDFLAGS=-m32 ./configure
 
+Kernel modules
+--------------
+
+LTP contains few kernel modules and tests which are using them.
+These require to be built with the same kernel headers as the running kernel (SUT).
+Sometimes the best way to achieve this is to compile them on the SUT.
+
+'modules', 'modules-clean' and 'modules-install' make targets are shortcuts
+to build just these modules and tests.
+
 Android Users
 -------------
 
diff --git a/Makefile b/Makefile
index eab40da8a6..b2cc77463c 100644
--- a/Makefile
+++ b/Makefile
@@ -212,6 +212,27 @@ endif
 test-metadata: metadata-all
 	$(MAKE) -C $(abs_srcdir)/metadata test
 
+MODULE_DIRS :=  $(shell \
+	dirname $$(grep -l 'include.*module\.mk' $$(find testcases/ -type f -name 'Makefile')))
+
+
+.PHONY: modules modules-clean modules-install
+modules:
+	@$(foreach dir,$(MODULE_DIRS),\
+		echo "Build $(dir)";\
+		$(MAKE) -C $(abs_srcdir)/$(dir) || exit $$?; \
+)
+modules-clean:
+	@$(foreach dir,$(MODULE_DIRS),\
+		echo "Build $(dir)";\
+		$(MAKE) -C $(abs_srcdir)/$(dir) clean || exit $$?; \
+)
+modules-install: modules
+	@$(foreach dir,$(MODULE_DIRS),\
+		echo "Build $(dir)";\
+		$(MAKE) -C $(abs_srcdir)/$(dir) install || exit $$?; \
+)
+
 ## Help
 .PHONY: help
 help:
-- 
2.50.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH v5 2/2] modules.mk: Add FORCE_MODULES=1 to fail on error
  2025-08-15  8:19 [LTP] [PATCH v5 0/2] make: Add kernel modules targets, FORCE_MODULES=1 Petr Vorel
  2025-08-15  8:19 ` [LTP] [PATCH v5 1/2] Makefile: Add kernel modules related make targets Petr Vorel
@ 2025-08-15  8:19 ` Petr Vorel
  2025-08-15  9:24   ` Li Wang via ltp
  2025-08-15 14:12   ` Cyril Hrubis
  1 sibling, 2 replies; 6+ messages in thread
From: Petr Vorel @ 2025-08-15  8:19 UTC (permalink / raw)
  To: ltp; +Cc: Ricardo B . Marlière

Kernel modules deliberately not fail on error due kABI
(Linux Kernel Driver Interface) not being stable [1].

But that also silently hides modules not being build due change
(LTP module needs to be updated) or distro bug.

Introduce FORCE_MODULES=1 variable for make to force fail on error.
This can happen if
* package for building kernel modules is not installed
* LTP kernel module error mentioned above

$ make modules FORCE_MODULES=1
Build testcases/kernel/syscalls/finit_module
 Check that package for building kernel modules for 6.6.15-amd64 is installed and try again.
 * openSUSE/SLES: kernel-default-devel
 * Fedora/RHEL: kernel-devel/kernel-headers
 * Debian/Ubuntu: linux-kbuild
 You can build anyway by omitting FORCE_MODULES=1.  Stop.
...

NOTE: previously added 'modules' make target keeps trying to build all
modules (don't stop on first error).

[1] https://docs.kernel.org/process/stable-api-nonsense.html

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 INSTALL              |  6 ++++++
 include/mk/module.mk | 24 +++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/INSTALL b/INSTALL
index 10c19d4105..7c25c23347 100644
--- a/INSTALL
+++ b/INSTALL
@@ -172,9 +172,15 @@ LTP contains few kernel modules and tests which are using them.
 These require to be built with the same kernel headers as the running kernel (SUT).
 Sometimes the best way to achieve this is to compile them on the SUT.
 
+Due Linux Kernel Driver Interface unstability [1], error during building kernel
+modules does not break the build. Make errors fatal can be done by FORCE_MODULES=1
+make variable.
+
 'modules', 'modules-clean' and 'modules-install' make targets are shortcuts
 to build just these modules and tests.
 
+[1] https://docs.kernel.org/process/stable-api-nonsense.html)
+
 Android Users
 -------------
 
diff --git a/include/mk/module.mk b/include/mk/module.mk
index c3cbf9c21f..3e97f01289 100644
--- a/include/mk/module.mk
+++ b/include/mk/module.mk
@@ -1,14 +1,22 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
-# Copyright (c) Linux Test Project, 2014-2021
+# Copyright (c) Linux Test Project, 2014-2025
 # Author: Alexey Kodanev <alexey.kodanev@oracle.com>
 #
 # Include it to build kernel modules.
 # REQ_VERSION_MAJOR and REQ_VERSION_PATCH must be defined beforehand.
+#
+# FORCE_MODULES=1: Forcing to fail on error or missing kernel headers (e.g. for CI)).
 
 $(if $(REQ_VERSION_MAJOR),,$(error You must define REQ_VERSION_MAJOR))
 $(if $(REQ_VERSION_PATCH),,$(error You must define REQ_VERSION_PATCH))
 
+define newline
+
+
+endef
+n := $(newline)
+
 ifeq ($(WITH_MODULES),no)
 SKIP := 1
 else
@@ -22,8 +30,18 @@ SKIP ?= $(shell \
 endif
 endif
 
+$(info skip: $(SKIP), FORCE_MODULES: $(FORCE_MODULES))
 ifneq ($(SKIP),0)
 MAKE_TARGETS := $(filter-out %.ko, $(MAKE_TARGETS))
+ifeq ($(FORCE_MODULES),1)
+$(error Kernel modules not built!$(n)\
+Check that package for building kernel modules for $(LINUX_VERSION)\
+is installed and try again.$(n)\
+* openSUSE/SLES: kernel-default-devel$(n)\
+* Fedora/RHEL: kernel-devel/kernel-headers$(n)\
+* Debian/Ubuntu: linux-kbuild$(n)\
+You can build anyway by omitting FORCE_MODULES=1)
+endif
 endif
 
 ifneq ($(filter install clean,$(MAKECMDGOALS)),)
@@ -45,6 +63,10 @@ MODULE_SOURCES := $(patsubst %.ko,%.c,$(filter %.ko, $(MAKE_TARGETS)))
 
 .dep_modules: $(MODULE_SOURCES)
 	@echo "Building modules: $(MODULE_SOURCES)"
+ifneq ($(FORCE_MODULES),1)
 	-$(MAKE) -C $(LINUX_DIR) M=$(abs_srcdir)
+else
+	$(MAKE) -C $(LINUX_DIR) M=$(abs_srcdir)
+endif
 	rm -rf *.mod.c *.o *.ko.unsigned modules.order .tmp* .*.ko .*.cmd Module.symvers
 	@touch .dep_modules
-- 
2.50.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH v5 2/2] modules.mk: Add FORCE_MODULES=1 to fail on error
  2025-08-15  8:19 ` [LTP] [PATCH v5 2/2] modules.mk: Add FORCE_MODULES=1 to fail on error Petr Vorel
@ 2025-08-15  9:24   ` Li Wang via ltp
  2025-08-15 14:12   ` Cyril Hrubis
  1 sibling, 0 replies; 6+ messages in thread
From: Li Wang via ltp @ 2025-08-15  9:24 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Ricardo B . Marlière, ltp

On Fri, Aug 15, 2025 at 4:20 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Kernel modules deliberately not fail on error due kABI
> (Linux Kernel Driver Interface) not being stable [1].
>
> But that also silently hides modules not being build due change
> (LTP module needs to be updated) or distro bug.
>
> Introduce FORCE_MODULES=1 variable for make to force fail on error.
> This can happen if
> * package for building kernel modules is not installed
> * LTP kernel module error mentioned above
>
> $ make modules FORCE_MODULES=1
> Build testcases/kernel/syscalls/finit_module
>  Check that package for building kernel modules for 6.6.15-amd64 is installed and try again.
>  * openSUSE/SLES: kernel-default-devel
>  * Fedora/RHEL: kernel-devel/kernel-headers
>  * Debian/Ubuntu: linux-kbuild
>  You can build anyway by omitting FORCE_MODULES=1.  Stop.
> ...
>
> NOTE: previously added 'modules' make target keeps trying to build all
> modules (don't stop on first error).
>
> [1] https://docs.kernel.org/process/stable-api-nonsense.html
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>

Reviewed-by: Li Wang <liwang@redhat.com>


-- 
Regards,
Li Wang


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH v5 2/2] modules.mk: Add FORCE_MODULES=1 to fail on error
  2025-08-15  8:19 ` [LTP] [PATCH v5 2/2] modules.mk: Add FORCE_MODULES=1 to fail on error Petr Vorel
  2025-08-15  9:24   ` Li Wang via ltp
@ 2025-08-15 14:12   ` Cyril Hrubis
  2025-08-15 15:07     ` Petr Vorel
  1 sibling, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2025-08-15 14:12 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Ricardo B . Marlière, ltp

Hi!
> diff --git a/INSTALL b/INSTALL
> index 10c19d4105..7c25c23347 100644
> --- a/INSTALL
> +++ b/INSTALL
> @@ -172,9 +172,15 @@ LTP contains few kernel modules and tests which are using them.
>  These require to be built with the same kernel headers as the running kernel (SUT).
>  Sometimes the best way to achieve this is to compile them on the SUT.
>  
> +Due Linux Kernel Driver Interface unstability [1], error during building kernel
> +modules does not break the build. Make errors fatal can be done by FORCE_MODULES=1
> +make variable.
> +
>  'modules', 'modules-clean' and 'modules-install' make targets are shortcuts
>  to build just these modules and tests.
>  
> +[1] https://docs.kernel.org/process/stable-api-nonsense.html)
                                                               ^
						Stray ) ?


Otherwise:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH v5 2/2] modules.mk: Add FORCE_MODULES=1 to fail on error
  2025-08-15 14:12   ` Cyril Hrubis
@ 2025-08-15 15:07     ` Petr Vorel
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2025-08-15 15:07 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Ricardo B . Marlière, ltp

Hi Cyril, Li,

> Hi!
> > diff --git a/INSTALL b/INSTALL
> > index 10c19d4105..7c25c23347 100644
> > --- a/INSTALL
> > +++ b/INSTALL
> > @@ -172,9 +172,15 @@ LTP contains few kernel modules and tests which are using them.
> >  These require to be built with the same kernel headers as the running kernel (SUT).
> >  Sometimes the best way to achieve this is to compile them on the SUT.

> > +Due Linux Kernel Driver Interface unstability [1], error during building kernel
> > +modules does not break the build. Make errors fatal can be done by FORCE_MODULES=1
> > +make variable.
> > +
> >  'modules', 'modules-clean' and 'modules-install' make targets are shortcuts
> >  to build just these modules and tests.

> > +[1] https://docs.kernel.org/process/stable-api-nonsense.html)
>                                                                ^
> 						Stray ) ?

+1, fixed and merged.

Thank you both for a review.

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-15 15:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-15  8:19 [LTP] [PATCH v5 0/2] make: Add kernel modules targets, FORCE_MODULES=1 Petr Vorel
2025-08-15  8:19 ` [LTP] [PATCH v5 1/2] Makefile: Add kernel modules related make targets Petr Vorel
2025-08-15  8:19 ` [LTP] [PATCH v5 2/2] modules.mk: Add FORCE_MODULES=1 to fail on error Petr Vorel
2025-08-15  9:24   ` Li Wang via ltp
2025-08-15 14:12   ` Cyril Hrubis
2025-08-15 15:07     ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.