public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: collect shorthands into scripts/Kbuild.include
@ 2014-11-26 10:31 Masahiro Yamada
  2014-11-26 13:55 ` Michal Marek
  0 siblings, 1 reply; 2+ messages in thread
From: Masahiro Yamada @ 2014-11-26 10:31 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Masahiro Yamada, Michal Marek, Sam Ravnborg, H. Peter Anvin,
	Andi Kleen, linux-kernel

The shorthand "clean" is defined in both the top Makefile and
scripts/Makefile.clean.  Likewise, the "hdr-inst" is defined in
both the top Makefile and scripts/Makefile.headersinst.

To reduce code duplication, this commit collects them into
scripts/Kbuild.include like the "build" and "modbuiltin" shorthands.
It requires scripts/Makefile.clean to include scripts/Kbuild.include,
but its impact on the performance of "make clean" should be
negligible.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

Marek, please decide if this patch should be applied or not.

I am not so sure if 10% of performance regression is acceptable.
I do not mind at all if this patch is rejected.

Before this commit, on my box,

$ time make clean

real	0m2.916s
user	0m1.040s
sys	0m2.005s

After,

real	0m3.221s
user	0m1.109s
sys	0m2.271s


 Makefile                     |  7 -------
 scripts/Kbuild.include       | 12 ++++++++++++
 scripts/Makefile.clean       |  5 +----
 scripts/Makefile.headersinst |  1 -
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index 2fd5c4e..257e08c 100644
--- a/Makefile
+++ b/Makefile
@@ -1036,8 +1036,6 @@ firmware_install: FORCE
 #Default location for installed headers
 export INSTALL_HDR_PATH = $(objtree)/usr
 
-hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
-
 # If we do an all arch process set dst to asm-$(hdr-arch)
 hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
 
@@ -1581,11 +1579,6 @@ ifneq ($(cmd_files),)
   include $(cmd_files)
 endif
 
-# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
-# Usage:
-# $(Q)$(MAKE) $(clean)=dir
-clean := -f $(srctree)/scripts/Makefile.clean obj
-
 endif	# skip-makefile
 
 PHONY += FORCE
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 65e7b08..0f90981 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -179,6 +179,18 @@ build := -f $(srctree)/scripts/Makefile.build obj
 # $(Q)$(MAKE) $(modbuiltin)=dir
 modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj
 
+###
+# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=
+# Usage:
+# $(Q)$(MAKE) $(clean)=dir
+clean := -f $(srctree)/scripts/Makefile.clean obj
+
+###
+# Shorthand for $(Q)$(MAKE) -rR -f scripts/Makefile.headersinst obj=
+# Usage:
+# $(Q)$(MAKE) $(hdr-inst)=dir
+hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
+
 # Prefix -I with $(srctree) if it is not an absolute path.
 # skip if -I has no parameter
 addtree = $(if $(patsubst -I%,%,$(1)), \
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index b1c668d..0aa91a0 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -7,10 +7,7 @@ src := $(obj)
 PHONY := __clean
 __clean:
 
-# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
-# Usage:
-# $(Q)$(MAKE) $(clean)=dir
-clean := -f $(srctree)/scripts/Makefile.clean obj
+include scripts/Kbuild.include
 
 # The filename Kbuild has precedence over Makefile
 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 8ccf830..1106d6c 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -122,7 +122,6 @@ $(check-file): scripts/headers_check.pl $(output-files) FORCE
 endif
 
 # Recursion
-hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
 .PHONY: $(subdirs)
 $(subdirs):
 	$(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
-- 
1.9.1


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

* Re: [PATCH] kbuild: collect shorthands into scripts/Kbuild.include
  2014-11-26 10:31 [PATCH] kbuild: collect shorthands into scripts/Kbuild.include Masahiro Yamada
@ 2014-11-26 13:55 ` Michal Marek
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Marek @ 2014-11-26 13:55 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Sam Ravnborg, H. Peter Anvin, Andi Kleen,
	linux-kernel

On Wed, Nov 26, 2014 at 07:31:13PM +0900, Masahiro Yamada wrote:
> The shorthand "clean" is defined in both the top Makefile and
> scripts/Makefile.clean.  Likewise, the "hdr-inst" is defined in
> both the top Makefile and scripts/Makefile.headersinst.
> 
> To reduce code duplication, this commit collects them into
> scripts/Kbuild.include like the "build" and "modbuiltin" shorthands.
> It requires scripts/Makefile.clean to include scripts/Kbuild.include,
> but its impact on the performance of "make clean" should be
> negligible.
> 
> Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
> ---
> 
> Marek, please decide if this patch should be applied or not.
> 
> I am not so sure if 10% of performance regression is acceptable.
> I do not mind at all if this patch is rejected.
> 
> Before this commit, on my box,
> 
> $ time make clean
> 
> real	0m2.916s
> user	0m1.040s
> sys	0m2.005s
> 
> After,
> 
> real	0m3.221s
> user	0m1.109s
> sys	0m2.271s

0.3s is even less than my guess. And as I said, you can run make clean
in parallel, so I'm not thrilled. Applied to kbuild.git#kbuild.

Thanks,
Michal

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

end of thread, other threads:[~2014-11-26 13:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-26 10:31 [PATCH] kbuild: collect shorthands into scripts/Kbuild.include Masahiro Yamada
2014-11-26 13:55 ` Michal Marek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox