diff mbox series

[5/8] kbuild: reduce the number of mkdir calls during modules_install

Message ID 20230823115048.823011-5-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series [1/8] kbuild: do not run depmod for 'make modules_sign' | expand

Commit Message

Masahiro Yamada Aug. 23, 2023, 11:50 a.m. UTC
Calling 'mkdir' for every module results in redundant syscalls.

Use $(sort ...) to drop the duplicated directories.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.modinst | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Nicolas Schier Aug. 23, 2023, 8:22 p.m. UTC | #1
On Wed, Aug 23, 2023 at 08:50:45PM +0900 Masahiro Yamada wrote:
> Calling 'mkdir' for every module results in redundant syscalls.
> 
> Use $(sort ...) to drop the duplicated directories.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  scripts/Makefile.modinst | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
> index 7a64ece9b826..5d687a453d90 100644
> --- a/scripts/Makefile.modinst
> +++ b/scripts/Makefile.modinst
> @@ -9,6 +9,13 @@ __modinst:
>  include include/config/auto.conf
>  include $(srctree)/scripts/Kbuild.include
>  
> +install-y :=
> +
> +PHONY += prepare
> +
> +prepare:
> +	$(Q)mkdir -p $(sort $(dir $(install-y)))
> +
>  modules := $(call read-file, $(MODORDER))
>  
>  ifeq ($(KBUILD_EXTMOD),)
> @@ -27,6 +34,7 @@ suffix-$(CONFIG_MODULE_COMPRESS_XZ)	:= .xz
>  suffix-$(CONFIG_MODULE_COMPRESS_ZSTD)	:= .zst
>  
>  modules := $(patsubst $(extmod_prefix)%.o, $(dst)/%.ko$(suffix-y), $(modules))
> +install-y += $(modules)
>  
>  __modinst: $(modules)
>  	@:
> @@ -35,7 +43,7 @@ __modinst: $(modules)
>  # Installation
>  #
>  quiet_cmd_install = INSTALL $@
> -      cmd_install = mkdir -p $(dir $@); cp $< $@
> +      cmd_install = cp $< $@
>  
>  # Strip
>  #
> @@ -95,6 +103,8 @@ depmod: $(modules)
>  quiet_cmd_depmod = DEPMOD  $(MODLIB)
>        cmd_depmod = $(srctree)/scripts/depmod.sh $(KERNELRELEASE)
>  
> +$(install-y): prepare
> +
>  else
>  
>  $(dst)/%.ko: FORCE
> -- 
> 2.39.2

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
diff mbox series

Patch

diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 7a64ece9b826..5d687a453d90 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -9,6 +9,13 @@  __modinst:
 include include/config/auto.conf
 include $(srctree)/scripts/Kbuild.include
 
+install-y :=
+
+PHONY += prepare
+
+prepare:
+	$(Q)mkdir -p $(sort $(dir $(install-y)))
+
 modules := $(call read-file, $(MODORDER))
 
 ifeq ($(KBUILD_EXTMOD),)
@@ -27,6 +34,7 @@  suffix-$(CONFIG_MODULE_COMPRESS_XZ)	:= .xz
 suffix-$(CONFIG_MODULE_COMPRESS_ZSTD)	:= .zst
 
 modules := $(patsubst $(extmod_prefix)%.o, $(dst)/%.ko$(suffix-y), $(modules))
+install-y += $(modules)
 
 __modinst: $(modules)
 	@:
@@ -35,7 +43,7 @@  __modinst: $(modules)
 # Installation
 #
 quiet_cmd_install = INSTALL $@
-      cmd_install = mkdir -p $(dir $@); cp $< $@
+      cmd_install = cp $< $@
 
 # Strip
 #
@@ -95,6 +103,8 @@  depmod: $(modules)
 quiet_cmd_depmod = DEPMOD  $(MODLIB)
       cmd_depmod = $(srctree)/scripts/depmod.sh $(KERNELRELEASE)
 
+$(install-y): prepare
+
 else
 
 $(dst)/%.ko: FORCE