* [PATCH] Kbuild: Update config_data.gz only if KCONFIG_CONFIG materially changed
@ 2021-04-01 22:44 Elliot Berman
2021-04-03 5:11 ` Masahiro Yamada
0 siblings, 1 reply; 3+ messages in thread
From: Elliot Berman @ 2021-04-01 22:44 UTC (permalink / raw)
To: Masahiro Yamada, Michal Marek
Cc: Elliot Berman, linux-kbuild, linux-kernel, Matthias Maennich,
Trilok Soni
If you update the timestamp of KCONFIG_CONFIG without actually changing
anything, config_data.gz is re-generated and causes vmlinux to re-link.
When Link Time Optimization is enabled, unnecessary re-linking of
vmlinux is highly desirable since it adds several minutes to build time.
Avoid touching config_data.gz by using filechk to compare the existing
config_data.gz and update only if it changed.
The .config can be touched, for instance, by a build script which
installs the default defconfig and then applies a defconfig fragment on
top.
For a simple example on my x86 machine, I modified x86 default defconfig to set
CONFIG_IKCONFIG=y and run:
make -j50 defconfig tiny.config vmlinux
make -j50 defconfig tiny.config vmlinux
With this patch, vmlinux is not re-built as a result of config_data.gz
change.
Signed-off-by: Elliot Berman <eberman@codeaurora.org>
---
kernel/Makefile | 2 +-
scripts/Makefile.lib | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/Makefile b/kernel/Makefile
index 320f1f3..bd4e558 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -140,7 +140,7 @@ $(obj)/configs.o: $(obj)/config_data.gz
targets += config_data.gz
$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
- $(call if_changed,gzip)
+ $(call filechk,gzip)
$(obj)/kheaders.o: $(obj)/kheaders_data.tar.xz
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a4fbaf8..81d3ec1 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -282,6 +282,8 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
quiet_cmd_gzip = GZIP $@
cmd_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > $@
+filechk_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9
+
# DTC
# ---------------------------------------------------------------------------
DTC ?= $(objtree)/scripts/dtc/dtc
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Kbuild: Update config_data.gz only if KCONFIG_CONFIG materially changed
2021-04-01 22:44 [PATCH] Kbuild: Update config_data.gz only if KCONFIG_CONFIG materially changed Elliot Berman
@ 2021-04-03 5:11 ` Masahiro Yamada
2021-04-05 4:23 ` Elliot Berman
0 siblings, 1 reply; 3+ messages in thread
From: Masahiro Yamada @ 2021-04-03 5:11 UTC (permalink / raw)
To: Elliot Berman
Cc: Michal Marek, Linux Kbuild mailing list,
Linux Kernel Mailing List, Matthias Maennich, Trilok Soni
On Fri, Apr 2, 2021 at 7:45 AM Elliot Berman <eberman@codeaurora.org> wrote:
>
> If you update the timestamp of KCONFIG_CONFIG without actually changing
> anything, config_data.gz is re-generated and causes vmlinux to re-link.
> When Link Time Optimization is enabled, unnecessary re-linking of
> vmlinux is highly desirable since it adds several minutes to build time.
>
> Avoid touching config_data.gz by using filechk to compare the existing
> config_data.gz and update only if it changed.
>
> The .config can be touched, for instance, by a build script which
> installs the default defconfig and then applies a defconfig fragment on
> top.
>
> For a simple example on my x86 machine, I modified x86 default defconfig to set
> CONFIG_IKCONFIG=y and run:
> make -j50 defconfig tiny.config vmlinux
> make -j50 defconfig tiny.config vmlinux
> With this patch, vmlinux is not re-built as a result of config_data.gz
> change.
>
> Signed-off-by: Elliot Berman <eberman@codeaurora.org>
> ---
> kernel/Makefile | 2 +-
> scripts/Makefile.lib | 2 ++
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/Makefile b/kernel/Makefile
> index 320f1f3..bd4e558 100644
> --- a/kernel/Makefile
> +++ b/kernel/Makefile
> @@ -140,7 +140,7 @@ $(obj)/configs.o: $(obj)/config_data.gz
>
> targets += config_data.gz
> $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
> - $(call if_changed,gzip)
> + $(call filechk,gzip)
I do not think this is the right approach
because gzip is executed every time, even
if the time stamp is not changed.
>
> $(obj)/kheaders.o: $(obj)/kheaders_data.tar.xz
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index a4fbaf8..81d3ec1 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -282,6 +282,8 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
> quiet_cmd_gzip = GZIP $@
> cmd_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > $@
>
> +filechk_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9
> +
> # DTC
> # ---------------------------------------------------------------------------
> DTC ?= $(objtree)/scripts/dtc/dtc
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Kbuild: Update config_data.gz only if KCONFIG_CONFIG materially changed
2021-04-03 5:11 ` Masahiro Yamada
@ 2021-04-05 4:23 ` Elliot Berman
0 siblings, 0 replies; 3+ messages in thread
From: Elliot Berman @ 2021-04-05 4:23 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Michal Marek, Linux Kbuild mailing list,
Linux Kernel Mailing List, Matthias Maennich, Trilok Soni
On 4/2/2021 10:11 PM, Masahiro Yamada wrote:
> On Fri, Apr 2, 2021 at 7:45 AM Elliot Berman <eberman@codeaurora.org> wrote:
>>
>> If you update the timestamp of KCONFIG_CONFIG without actually changing
>> anything, config_data.gz is re-generated and causes vmlinux to re-link.
>> When Link Time Optimization is enabled, unnecessary re-linking of
>> vmlinux is highly desirable since it adds several minutes to build time.
>>
>> Avoid touching config_data.gz by using filechk to compare the existing
>> config_data.gz and update only if it changed.
>>
>> The .config can be touched, for instance, by a build script which
>> installs the default defconfig and then applies a defconfig fragment on
>> top.
>>
>> For a simple example on my x86 machine, I modified x86 default defconfig to set
>> CONFIG_IKCONFIG=y and run:
>> make -j50 defconfig tiny.config vmlinux
>> make -j50 defconfig tiny.config vmlinux
>> With this patch, vmlinux is not re-built as a result of config_data.gz
>> change.
>>
>> Signed-off-by: Elliot Berman <eberman@codeaurora.org>
>> ---
>> kernel/Makefile | 2 +-
>> scripts/Makefile.lib | 2 ++
>> 2 files changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/Makefile b/kernel/Makefile
>> index 320f1f3..bd4e558 100644
>> --- a/kernel/Makefile
>> +++ b/kernel/Makefile
>> @@ -140,7 +140,7 @@ $(obj)/configs.o: $(obj)/config_data.gz
>>
>> targets += config_data.gz
>> $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
>> - $(call if_changed,gzip)
>> + $(call filechk,gzip)
>
>
> I do not think this is the right approach
> because gzip is executed every time, even
> if the time stamp is not changed.
>
Since .config is relatively small, gzip was quickly producing the same
binary in multiple runs on my host. I thought about following
gen_ikheaders.sh approach of comparing the md5sum, but I felt it was
more complex than using filechk and re-compressing every time. I'll send
a v2 tomorrow which follows gen_ikheaders.sh approach.
>
>>
>> $(obj)/kheaders.o: $(obj)/kheaders_data.tar.xz
>>
>> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
>> index a4fbaf8..81d3ec1 100644
>> --- a/scripts/Makefile.lib
>> +++ b/scripts/Makefile.lib
>> @@ -282,6 +282,8 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
>> quiet_cmd_gzip = GZIP $@
>> cmd_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > $@
>>
>> +filechk_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9
>> +
>> # DTC
>> # ---------------------------------------------------------------------------
>> DTC ?= $(objtree)/scripts/dtc/dtc
>> --
>> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
>> a Linux Foundation Collaborative Project
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-05 4:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01 22:44 [PATCH] Kbuild: Update config_data.gz only if KCONFIG_CONFIG materially changed Elliot Berman
2021-04-03 5:11 ` Masahiro Yamada
2021-04-05 4:23 ` Elliot Berman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).