]> www.infradead.org Git - users/hch/misc.git/commitdiff
x86: don't re-generate cpufeaturemasks.h so eagerly
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 31 Mar 2025 21:19:55 +0000 (14:19 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 31 Mar 2025 21:19:55 +0000 (14:19 -0700)
It turns out the code to generate the x86 cpufeaturemasks.h header was
way too aggressive, and would re-generate it whenever the timestamp on
the kernel config file changed.

Now, the regular 'make *config' tools are fairly careful to not rewrite
the kernel config file unless the contents change, but other usecases
aren't that careful.

Michael Kelley reports that 'make-kpkg' ends up doing "make syncconfig"
multiple times in prepping to build, and will modify the config file in
the process (and then modify it back, but by then the timestamps have
changed).

Jakub Kicinski reports that the netdev CI does something similar in how
it generates the config file in multiple steps.

In both cases, the config file timestamp updates then cause the
cpufeaturemasks.h file to be regenerated, and that in turn then causes
lots of unnecessary rebuilds due to all the normal dependencies.

Fix it by using our 'filechk' infrastructure in the Makefile to generate
the header file.  That will only write a new version of the file if the
contents of the file have actually changed.

Fixes: 841326332bcb ("x86/cpufeatures: Generate the <asm/cpufeaturemasks.h> header based on build config")
Reported-by: Michael Kelley <mhklinux@outlook.com>
Reported-by: Jakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/all/SN6PR02MB415756D1829740F6E8AC11D1D4D82@SN6PR02MB4157.namprd02.prod.outlook.com/
Link: https://lore.kernel.org/all/20250328162311.08134fa6@kernel.org/
Cc: Peter Anvin <hpa@zytor.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/x86/Makefile

index 0fc7e8fd1a2e7d4745d45fbbc147ac012a7700bc..27efe2dc2aa8702fce40b4cfcceaa7c559ea0ae8 100644 (file)
@@ -277,12 +277,11 @@ cpufeaturemasks.hdr := arch/x86/include/generated/asm/cpufeaturemasks.h
 cpufeaturemasks.awk := $(srctree)/arch/x86/tools/cpufeaturemasks.awk
 cpufeatures_hdr := $(srctree)/arch/x86/include/asm/cpufeatures.h
 targets += $(cpufeaturemasks.hdr)
-quiet_cmd_gen_featuremasks = GEN     $@
-      cmd_gen_featuremasks = $(AWK) -f $(cpufeaturemasks.awk) $(cpufeatures_hdr) $(KCONFIG_CONFIG) > $@
+      filechk_gen_featuremasks = $(AWK) -f $(cpufeaturemasks.awk) $(cpufeatures_hdr) $(KCONFIG_CONFIG)
 
 $(cpufeaturemasks.hdr): $(cpufeaturemasks.awk) $(cpufeatures_hdr) $(KCONFIG_CONFIG) FORCE
        $(shell mkdir -p $(dir $@))
-       $(call if_changed,gen_featuremasks)
+       $(call filechk,gen_featuremasks)
 archprepare: $(cpufeaturemasks.hdr)
 
 ###