Skip to contentSkip to conversation

linux: simplify requesting kernel modules (branch yem/needs-modules)

PATCH New Yann E. MORIN 2 participants 9 messages Dec 10, 2015 – Dec 29, 2015

lore
Share & tools
lore
#0 lore raw

cover linux: simplify requesting kernel modules (branch yem/needs-modules)

Hello All!

This series is a proposal to make it easier and mor esimple for packages to request that the Linux kernel be built with support for loadable modules.

This work was prompted by a comment from Thomas on IRC, who did not like much that packages had to write things like:

ifeq ($(BR2_PACKAGE_FOO),y)
LINUX_NEEDS_MODULES = y
endif

The LINUX_NEEDS_MODULES variable was introduced as a pure make variable, because we needed it to implement the kernel-module infra. So, we just turned to using it even from packages that do not use that infra.

However, that's indeed quite cumbersome that packages do have to write this code in their .mk files, when we already have the logic in two places:

- in the Config.in, since that's handled natively by Kconfig,
- in the generic package infra, in which we already have that condition to add packages to the list.

So, this series introduce BR2_LINUX_NEEDS_MODULES, the Kconfig counter-part of LINUX_NEEDS_MODULES. LINUX_NEEDS_MODULES still gets set by the kernel-module infra when the package is enabled, but is also set when BR2_LINUX_NEEDS_MODULES is.

Regards,
Yann E. MORIN.

The following changes since commit e85a0bb03face4963b1e93b83cdb01066d68b79b:

package/lttng-tools: fix static build (2015-12-09 23:39:11 +0100)

are available in the git repository at:

git://git.busybox.net/~ymorin/git/buildroot yem/needs-modules

for you to fetch changes up to 94c80013dc21effd198e7fe4b21ddf5f1d41e8fe:

package/xtables-addons: require kernel modules from Kconfig (2015-12-10 18:37:00 +0100)

----------------------------------------------------------------
Yann E. MORIN (7):
linux: add blind kconfig option to require kernel modules package/linux-fusion: require kernel modules from Kconfig package/nvidia-driver: require kernel modules from Kconfig package/racehound: require kernel modules from Kconfig package/rtai: require kernel modules from Kconfig package/ti-gfx: require kernel modules from Kconfig package/xtables-addons: require kernel modules from Kconfig

 linux/Config.in                          | 6 ++++++
 linux/linux.mk                           | 3 +++
 package/linux-fusion/Config.in           | 3 ++-
 package/linux-fusion/linux-fusion.mk     | 6 ------
 package/nvidia-driver/Config.in          | 1 +
 package/nvidia-driver/nvidia-driver.mk   | 4 ----
 package/racehound/Config.in              | 3 ++-
 package/racehound/racehound.mk           | 6 ------
 package/rtai/Config.in                   | 1 +
 package/rtai/rtai.mk                     | 6 ------
 package/ti-gfx/Config.in                 | 3 ++-
 package/ti-gfx/ti-gfx.mk                 | 6 ------
 package/xtables-addons/Config.in         | 1 +
 package/xtables-addons/xtables-addons.mk | 6 ------
 14 files changed, 18 insertions(+), 37 deletions(-)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH 1/7 linux: add blind kconfig option to require kernel modules

Currently, packages that need the kernel to have support for laodable modules have two ways to require it:

- either the use the kernel-module infra, which does it automatically,

- or they do not use it, and they need to requrie it manually, by setting the corresponding Makefile variable; however, they must only set it when they are actually enabled, which makes for a slightly cumbersome and ugly code, like:

ifeq ($(BR2_PACKAGE_FOO),y)
LINUX_NEEDS_MODULES = y
endif

Introduce a nw blind Kconfig option that packages can select to signify they need kernel modules. That Kconfig option is then used to set the Makefile variable.

It makes it cleaner:

- code is simpler (one Kconfig line instead of a Makefile if-block,

- this is handled at the Kconfig level, which is where we usually handle such dependencies.

Packages will be updated in follow-up commits.

---
 linux/Config.in | 6 ++++++
 linux/linux.mk  | 3 +++
 2 files changed, 9 insertions(+)
linux/Config.in +6 -0
index dfb9453..55c548f 100644
@@ -8,6 +8,12 @@ config BR2_LINUX_KERNEL
 
 if BR2_LINUX_KERNEL
 
+# Packages that need to have a kernel with support for loadable modules,
+# but do not use the kernel-modules infrastructure, should select that
+# option.
+config BR2_LINUX_NEEDS_MODULES
+	bool
+
 #
 # Version selection. We provide the choice between:
 #
linux/linux.mk +3 -0
index 9507837..ea07efc 100644
@@ -178,6 +178,9 @@ LINUX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_LINUX_KERNEL_CONFIG_FRAGMENT_
 LINUX_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
 LINUX_KCONFIG_OPTS = $(LINUX_MAKE_FLAGS)
 
+# If no package has yet set it, set it from the Kconfig option
+LINUX_NEEDS_MODULES ?= $(BR2_LINUX_NEEDS_MODULES)
+
 define LINUX_KCONFIG_FIXUP_CMDS
 	$(if $(LINUX_NEEDS_MODULES),
 		$(call KCONFIG_ENABLE_OPT,CONFIG_MODULES,$(@D)/.config))
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/7 package/linux-fusion: require kernel modules from Kconfig

In reply to Yann E. MORIN

And reorder 'depends' after 'bool'.

Cc Thomas Petazzoni <[email protected]>
---
 package/linux-fusion/Config.in       | 3 ++-
 package/linux-fusion/linux-fusion.mk | 6 ------
 2 files changed, 2 insertions(+), 7 deletions(-)
package/linux-fusion/Config.in +2 -1
index cdc1dd2..ed8bd6a 100644
@@ -2,8 +2,9 @@ comment "linux-fusion needs a Linux kernel to be built"
 	depends on !BR2_LINUX_KERNEL
 
 config BR2_PACKAGE_LINUX_FUSION
-	depends on BR2_LINUX_KERNEL
 	bool "linux-fusion communication layer for DirectFB multi"
+	depends on BR2_LINUX_KERNEL
+	select BR2_LINUX_NEEDS_MODULES # not using kernel-module infra
 	help
 	  DirectFB Communication Layer allowing multiple DirectFB
 	  applications to run concurrently
package/linux-fusion/linux-fusion.mk +0 -6
index ba4bb31..35ed28e 100644
@@ -12,12 +12,6 @@ LINUX_FUSION_DEPENDENCIES = linux
 LINUX_FUSION_LICENSE = GPLv2+
 LINUX_FUSION_LICENSE_FILES = debian/copyright
 
-# We're building a kernel module without using the kernel-module infra,
-# so we need to tell we want module support in the kernel
-ifeq ($(BR2_PACKAGE_LINUX_FUSION),y)
-LINUX_NEEDS_MODULES = y
-endif
-
 LINUX_FUSION_ETC_DIR = $(TARGET_DIR)/etc/udev/rules.d
 
 LINUX_FUSION_MAKE_OPTS = \
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/7 package/nvidia-driver: require kernel modules from Kconfig

In reply to Yann E. MORIN
Cc Thomas Petazzoni <[email protected]>
---
 package/nvidia-driver/Config.in        | 1 +
 package/nvidia-driver/nvidia-driver.mk | 4 ----
 2 files changed, 1 insertion(+), 4 deletions(-)
package/nvidia-driver/Config.in +1 -0
index b50e2c3..30763c5 100644
@@ -76,6 +76,7 @@ comment "nvidia kernel module needs a kernel to be built"
 config BR2_PACKAGE_NVIDIA_DRIVER_MODULE
 	bool "nvidia kernel module"
 	depends on BR2_LINUX_KERNEL
+	select BR2_LINUX_NEEDS_MODULES # not using kernel-module infra
 	help
 	  Build the nvidia.ko kernel module.
 
package/nvidia-driver/nvidia-driver.mk +0 -4
index 4bcb65e..71babfb 100644
@@ -91,10 +91,6 @@ ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_MODULE),y)
 
 NVIDIA_DRIVER_DEPENDENCIES += linux
 
-# We're building a kernel module without using the kernel-module infra,
-# so we need to tell we want module support in the kernel
-LINUX_NEEDS_MODULES = y
-
 # NVidia uses the legacy naming scheme for the x86 architecture, when i386
 # and x86_64 were still considered two separate architectures in the Linux
 # kernel.
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/7 package/racehound: require kernel modules from Kconfig

In reply to Yann E. MORIN

And reorder 'select' after 'depends'

Cc Thomas Petazzoni <[email protected]>
---
 package/racehound/Config.in    | 3 ++-
 package/racehound/racehound.mk | 6 ------
 2 files changed, 2 insertions(+), 7 deletions(-)
package/racehound/Config.in +2 -1
index b9c4f36..9f1011b 100644
@@ -1,6 +1,5 @@
 config BR2_PACKAGE_RACEHOUND
 	bool "racehound"
-	select BR2_PACKAGE_ELFUTILS
 	depends on BR2_LINUX_KERNEL
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_14
 	depends on BR2_INSTALL_LIBSTDCPP
@@ -9,6 +8,8 @@ config BR2_PACKAGE_RACEHOUND
 	depends on BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC # elfutils
 	# only x86/x86_64 supported
 	depends on BR2_i386 || BR2_x86_64
+	select BR2_PACKAGE_ELFUTILS
+	select BR2_LINUX_NEEDS_MODULES # not using kernel-module infra
 	help
 	  RaceHound can be used to detect data races in the Linux
 	  kernel on x86.
package/racehound/racehound.mk +0 -6
index 66f3ebe..7d8d1e3 100644
@@ -12,12 +12,6 @@ RACEHOUND_SUPPORTS_IN_SOURCE_BUILD = NO
 
 RACEHOUND_DEPENDENCIES = elfutils linux
 
-# We're building a kernel module without using the kernel-module infra,
-# so we need to tell we want module support in the kernel
-ifeq ($(BR2_PACKAGE_RACEHOUND),y)
-LINUX_NEEDS_MODULES = y
-endif
-
 # override auto detection (uses host parameters, not cross compile
 # ready)
 RACEHOUND_CONF_OPTS += \
Signature · 1 line
1.9.1
#5 lore raw

PATCH 5/7 package/rtai: require kernel modules from Kconfig

In reply to Yann E. MORIN
Cc Thomas Petazzoni <[email protected]>
---
 package/rtai/Config.in | 1 +
 package/rtai/rtai.mk   | 6 ------
 2 files changed, 1 insertion(+), 6 deletions(-)
package/rtai/Config.in +1 -0
index ecbff38..14b1854 100644
@@ -1,6 +1,7 @@
 config BR2_PACKAGE_RTAI
 	bool "rtai"
 	depends on BR2_LINUX_KERNEL_EXT_RTAI
+	select BR2_LINUX_NEEDS_MODULES # not using kernel-module infra
 	help
 	  RTAI - the RealTime Application Interface for Linux.
 
package/rtai/rtai.mk +0 -6
index 6e803a6..dfd8e0c 100644
@@ -18,12 +18,6 @@ RTAI_POST_INSTALL_STAGING_HOOKS += RTAI_POST_PATCH_FIXUP
 
 RTAI_DEPENDENCIES = linux
 
-# We're building a kernel module without using the kernel-module infra,
-# so we need to tell we want module support in the kernel
-ifeq ($(BR2_PACKAGE_RTAI),y)
-LINUX_NEEDS_MODULES = y
-endif
-
 RTAI_CONF_OPTS = \
 	--includedir=/usr/include/rtai \
 	--with-linux-dir=$(LINUX_DIR) 	\
Signature · 1 line
1.9.1
#6 lore raw

PATCH 6/7 package/ti-gfx: require kernel modules from Kconfig

In reply to Yann E. MORIN

And reorder 'depends' before 'select'.

Cc Thomas Petazzoni <[email protected]>
---
 package/ti-gfx/Config.in | 3 ++-
 package/ti-gfx/ti-gfx.mk | 6 ------
 2 files changed, 2 insertions(+), 7 deletions(-)
package/ti-gfx/Config.in +2 -1
index 4ee8622..de4e9cb 100644
@@ -1,10 +1,11 @@
 config BR2_PACKAGE_TI_GFX
 	bool "ti-gfx"
+	depends on BR2_LINUX_KERNEL && BR2_TOOLCHAIN_USES_GLIBC && BR2_arm
 	select BR2_PACKAGE_HAS_LIBEGL
 	select BR2_PACKAGE_HAS_LIBGLES
 	select BR2_PACKAGE_HAS_POWERVR
 	select BR2_PACKAGE_FBSET if !BR2_PACKAGE_BUSYBOX # Runtime dependency only
-	depends on BR2_LINUX_KERNEL && BR2_TOOLCHAIN_USES_GLIBC && BR2_arm
+	select BR2_LINUX_NEEDS_MODULES # not using kernel-module infra
 	help
 	  Graphics libraries for TI boards.
 
package/ti-gfx/ti-gfx.mk +0 -6
index d23985f..47eb474 100644
@@ -22,12 +22,6 @@ TI_GFX_INSTALL_STAGING = YES
 
 TI_GFX_DEPENDENCIES = linux
 
-# We're building a kernel module without using the kernel-module infra,
-# so we need to tell we want module support in the kernel
-ifeq ($(BR2_PACKAGE_TI_GFX),y)
-LINUX_NEEDS_MODULES = y
-endif
-
 TI_GFX_PROVIDES = libegl libgles powervr
 
 ifeq ($(BR2_PACKAGE_TI_GFX_ES3),y)
Signature · 1 line
1.9.1
#7 lore raw

PATCH 7/7 package/xtables-addons: require kernel modules from Kconfig

In reply to Yann E. MORIN
Cc Thomas Petazzoni <[email protected]>
---
 package/xtables-addons/Config.in         | 1 +
 package/xtables-addons/xtables-addons.mk | 6 ------
 2 files changed, 1 insertion(+), 6 deletions(-)
package/xtables-addons/Config.in +1 -0
index a687618..4538519 100644
@@ -10,6 +10,7 @@ config BR2_PACKAGE_XTABLES_ADDONS
 	depends on BR2_TOOLCHAIN_HAS_THREADS
 	depends on !BR2_STATIC_LIBS # extensions are .so
 	select BR2_PACKAGE_IPTABLES
+	select BR2_LINUX_NEEDS_MODULES # not using kernel-module infra
 	help
 	  Xtables-addons is the successor to patch-o-matic(-ng).
 	  Likewise, it contains extensions that were not, or are not yet,
package/xtables-addons/xtables-addons.mk +0 -6
index 66e7386..b4e5992 100644
@@ -16,12 +16,6 @@ XTABLES_ADDONS_CONF_OPTS = \
 	--with-xtables="$(STAGING_DIR)/usr" \
 	--with-xtlibdir="/usr/lib/xtables"
 
-# We're building a kernel module without using the kernel-module infra,
-# so we need to tell we want module support in the kernel
-ifeq ($(BR2_PACKAGE_XTABLES_ADDONS),y)
-LINUX_NEEDS_MODULES = y
-endif
-
 # geoip helpers need perl with modules and unzip so disable
 define XTABLES_DISABLE_GEOIP_HELPERS
 	$(SED) 's/ geoip//' $(@D)/Makefile.in
Signature · 1 line
1.9.1
#8 lore raw

cover linux: simplify requesting kernel modules (branch yem/needs-modules)

In reply to Yann E. MORIN
Quoted 22 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Hello All!
This series is a proposal to make it easier and mor esimple for packages to request that the Linux kernel be built with support for loadable modules.

This work was prompted by a comment from Thomas on IRC, who did not like much that packages had to write things like:

ifeq ($(BR2_PACKAGE_FOO),y)
LINUX_NEEDS_MODULES = y
endif

The LINUX_NEEDS_MODULES variable was introduced as a pure make variable, because we needed it to implement the kernel-module infra. So, we just turned to using it even from packages that do not use that infra.

However, that's indeed quite cumbersome that packages do have to write this code in their .mk files, when we already have the logic in two places:

Quoted 8 lines

- in the Config.in, since that's handled natively by Kconfig,
- in the generic package infra, in which we already have that condition to add packages to the list.

So, this series introduce BR2_LINUX_NEEDS_MODULES, the Kconfig counter-part of LINUX_NEEDS_MODULES. LINUX_NEEDS_MODULES still gets set by the kernel-module infra when the package is enabled, but is also set when BR2_LINUX_NEEDS_MODULES is.

Committed series, thanks.

Signature · 1 line
Bye, Peter Korsgaard