Skip to contentSkip to conversation

2.5.25 remove unnecessary recompiles when changing EXTRAVERSION

PATCH In review Keith Owens 2 participants 2 messages Jul 6, 2002 – Jul 22, 2002

Subsystems (11)
SCSI USB Sound Block layer +7 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.5.25 remove unnecessary recompiles when changing EXTRAVERSION

include/linux/version.h contains both the numeric part of the kernel version and the full uts_release string. version.h is included almost everywhere, either on its own or via module.h. module.h and modutils only require the numeric kernel version, the use of UTS_RELEASE is incorrect and causes significant recompiles when EXTRAVERSION changes.

This patch moves UTS_RELEASE into its own header which is explicitly included in only the files that really use UTS_RELEASE. module.h uses a new field (KERNEL_VERSION_STRING) which has been added to version.h. With this patch, a change to EXTRAVERSION no longer recompiles 95% of your kernel.

The only significant changes are to module.h and Makefile. The rest of the patch is adding #include <linux/uts_release.h> in those files that use UTS_RELEASE. I suspect some of those files really only need KERNEL_VERSION_STRING but that has been left as an exercise for the file owners. Some of those files may no longer required version.h, again that has been left for the file owners.

Do not backport this change to 2.[024]. Their builds have incomplete dependency trees, some changes to the top level Makefile only work as a lucky side effect of the extra recompiles.

 include/linux/module.h                          |    2 +-
 Makefile                                        |   13 +++++++++----
 arch/alpha/boot/bootp.c                         |    1 +
 arch/alpha/boot/main.c                          |    1 +
 arch/i386/boot/setup.S                          |    1 +
 arch/ppc/kernel/btext.c                         |    1 +
 arch/ppc/platforms/chrp_setup.c                 |    1 +
 arch/ppc64/kernel/chrp_setup.c                  |    1 +
 arch/x86_64/boot/setup.S                        |    1 +
 drivers/block/floppy.c                          |    1 +
 drivers/cdrom/aztcd.c                           |    1 +
 drivers/cdrom/mcdx.c                            |    1 +
 drivers/char/ftape/compressor/zftape-compress.c |    1 +
 drivers/char/ftape/lowlevel/ftape-init.c        |    1 +
 drivers/char/ftape/zftape/zftape-init.c         |    1 +
 drivers/scsi/aic7xxx_old.c                      |    1 +
 drivers/scsi/megaraid.c                         |    1 +
 drivers/usb/core/hcd.c                          |    1 +
 include/asm-alpha/linux_logo.h                  |    1 +
 include/asm-arm/linux_logo.h                    |    1 +
 include/asm-i386/linux_logo.h                   |    1 +
 include/asm-ia64/linux_logo.h                   |    1 +
 include/asm-m68k/linux_logo.h                   |    1 +
 include/asm-mips/linux_logo_dec.h               |    1 +
 include/asm-mips/linux_logo_sgi.h               |    1 +
 include/asm-mips64/linux_logo.h                 |    1 +
 include/asm-parisc/linux_logo.h                 |    1 +
 include/asm-ppc/linux_logo.h                    |    1 +
 include/asm-ppc64/linux_logo.h                  |    1 +
 include/asm-sh/linux_logo.h                     |    1 +
 include/asm-sparc/linux_logo.h                  |    1 +
 include/asm-sparc64/linux_logo.h                |    1 +
 include/asm-x86_64/linux_logo.h                 |    1 +
 init/version.c                                  |    1 +
 sound/core/info.c                               |    1 +
 35 files changed, 43 insertions, 5 deletions
include/linux/module.h +1 -1
diff 25.1/include/linux/module.h
@@ -285,7 +285,7 @@ extern struct module __this_module;
 
 #include <linux/version.h>
 static const char __module_kernel_version[] __attribute__((section(".modinfo"))) =
-"kernel_version=" UTS_RELEASE;
+"kernel_version=" KERNEL_VERSION_STRING;
 #ifdef CONFIG_MODVERSIONS
 static const char __module_using_checksums[] __attribute__((section(".modinfo"))) =
 "using_checksums=1";
Makefile +9 -4
diff 25.1/Makefile
@@ -344,15 +344,20 @@ include/linux/autoconf.h: .config
 
 uts_len := 64
 
-include/linux/version.h: Makefile
+include/linux/uts_release.h: Makefile
+	@echo -n '  Generating $@'
 	@if expr length "$(KERNELRELEASE)" \> $(uts_len) >/dev/null ; then \
 	  echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
 	  exit 1; \
 	fi;
+	@(echo \#define UTS_RELEASE \"$(KERNELRELEASE)\";) > [email protected]
+	@$(update-if-changed)
+
+include/linux/version.h: Makefile include/linux/uts_release.h
 	@echo -n '  Generating $@'
-	@(echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
-	  echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
+	@(echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
 	 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \
+	 echo '#define KERNEL_VERSION_STRING "$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)"'; \
 	) > [email protected]
 	@$(update-if-changed)
 
@@ -611,7 +616,7 @@ CLEAN_FILES += \
 
 # 	files removed with 'make mrproper'
 MRPROPER_FILES += \
-	include/linux/autoconf.h include/linux/version.h \
+	include/linux/autoconf.h include/linux/version.h include/linux/uts_release.h \
 	drivers/net/hamradio/soundmodem/sm_tbl_{afsk1200,afsk2666,fsk9600}.h \
 	drivers/net/hamradio/soundmodem/sm_tbl_{hapn4800,psk4800}.h \
 	drivers/net/hamradio/soundmodem/sm_tbl_{afsk2400_7,afsk2400_8}.h \
arch/alpha/boot/bootp.c +1 -0
diff 25.1/arch/alpha/boot/bootp.c
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/mm.h>
 
 #include <asm/system.h>
arch/alpha/boot/main.c +1 -0
diff 25.1/arch/alpha/boot/main.c
@@ -8,6 +8,7 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/mm.h>
 
 #include <asm/system.h>
arch/i386/boot/setup.S +1 -0
diff 25.1/arch/i386/boot/setup.S
@@ -50,6 +50,7 @@
 #include <linux/config.h>
 #include <asm/segment.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/compile.h>
 #include <asm/boot.h>
 #include <asm/e820.h>
arch/ppc/kernel/btext.c +1 -0
diff 25.1/arch/ppc/kernel/btext.c
@@ -11,6 +11,7 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #include <asm/sections.h>
 #include <asm/bootx.h>
arch/ppc/platforms/chrp_setup.c +1 -0
diff 25.1/arch/ppc/platforms/chrp_setup.c
@@ -31,6 +31,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/adb.h>
 #include <linux/module.h>
 #include <linux/delay.h>
arch/ppc64/kernel/chrp_setup.c +1 -0
diff 25.1/arch/ppc64/kernel/chrp_setup.c
@@ -37,6 +37,7 @@
 #include <linux/console.h>
 #include <linux/pci.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/adb.h>
 #include <linux/module.h>
 #include <linux/delay.h>
arch/x86_64/boot/setup.S +1 -0
diff 25.1/arch/x86_64/boot/setup.S
@@ -47,6 +47,7 @@
 #include <linux/config.h>
 #include <asm/segment.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/compile.h>
 #include <asm/boot.h>
 #include <asm/e820.h>
drivers/block/floppy.c +1 -0
diff 25.1/drivers/block/floppy.c
@@ -153,6 +153,7 @@ static int print_unex=1;
 #include <linux/tqueue.h>
 #define FDPATCHES
 #include <linux/fdreg.h>
+#include <linux/uts_release.h>
 
 /*
  * 1998/1/21 -- Richard Gooch <[email protected]> -- devfs support
drivers/cdrom/aztcd.c +1 -0
diff 25.1/drivers/cdrom/aztcd.c
@@ -166,6 +166,7 @@
 */
 
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #define MAJOR_NR AZTECH_CDROM_MAJOR
 #define DEVICE_NR(device) (minor(device))
drivers/cdrom/mcdx.c +1 -0
diff 25.1/drivers/cdrom/mcdx.c
@@ -57,6 +57,7 @@ static const char *mcdx_c_version
 #endif
 
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/module.h>
 
 #include <linux/errno.h>
drivers/char/ftape/compressor/zftape-compress.c +1 -0
diff 25.1/drivers/char/ftape/compressor/zftape-compress.c
@@ -34,6 +34,7 @@
 #include <linux/errno.h>
 #include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/uts_release.h>
 
 #include <linux/zftape.h>
 
drivers/char/ftape/lowlevel/ftape-init.c +1 -0
diff 25.1/drivers/char/ftape/lowlevel/ftape-init.c
@@ -24,6 +24,7 @@
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/kernel.h>
drivers/char/ftape/zftape/zftape-init.c +1 -0
diff 25.1/drivers/char/ftape/zftape/zftape-init.c
@@ -24,6 +24,7 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/fs.h>
 #include <linux/kernel.h>
 #include <linux/signal.h>
drivers/scsi/aic7xxx_old.c +1 -0
diff 25.1/drivers/scsi/aic7xxx_old.c
@@ -225,6 +225,7 @@
 #include <asm/irq.h>
 #include <asm/byteorder.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
drivers/scsi/megaraid.c +1 -0
diff 25.1/drivers/scsi/megaraid.c
@@ -479,6 +479,7 @@
 
 #include <linux/config.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/errno.h>
drivers/usb/core/hcd.c +1 -0
diff 25.1/drivers/usb/core/hcd.c
@@ -25,6 +25,7 @@
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/completion.h>
include/asm-alpha/linux_logo.h +1 -0
diff 25.1/include/asm-alpha/linux_logo.h
@@ -20,6 +20,7 @@
  
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #define linux_logo_banner "Linux/AXP version " UTS_RELEASE
 
include/asm-arm/linux_logo.h +1 -0
diff 25.1/include/asm-arm/linux_logo.h
@@ -12,6 +12,7 @@
 
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #define linux_logo_banner "ARM Linux version " UTS_RELEASE
 
include/asm-i386/linux_logo.h +1 -0
diff 25.1/include/asm-i386/linux_logo.h
@@ -20,6 +20,7 @@
  
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #define linux_logo_banner "Linux/ia32 version " UTS_RELEASE
 
include/asm-ia64/linux_logo.h +1 -0
diff 25.1/include/asm-ia64/linux_logo.h
@@ -21,6 +21,7 @@
  
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #define linux_logo_banner "Linux/ia64 version " UTS_RELEASE
 
include/asm-m68k/linux_logo.h +1 -0
diff 25.1/include/asm-m68k/linux_logo.h
@@ -21,6 +21,7 @@
 #include <linux/config.h>
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #define linux_logo_banner "Linux/m68k version " UTS_RELEASE
 
include/asm-mips/linux_logo_dec.h +1 -0
diff 25.1/include/asm-mips/linux_logo_dec.h
@@ -11,6 +11,7 @@
  
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/config.h>
 
 #define linux_logo_banner "Linux/MIPSel version " UTS_RELEASE
include/asm-mips/linux_logo_sgi.h +1 -0
diff 25.1/include/asm-mips/linux_logo_sgi.h
@@ -11,6 +11,7 @@
  
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 #include <linux/config.h>
 
 #define linux_logo_banner "Linux/MIPS version " UTS_RELEASE
include/asm-mips64/linux_logo.h +1 -0
diff 25.1/include/asm-mips64/linux_logo.h
@@ -20,6 +20,7 @@
  
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #define linux_logo_banner "Linux/MIPS64 version " UTS_RELEASE
 
include/asm-parisc/linux_logo.h +1 -0
diff 25.1/include/asm-parisc/linux_logo.h
@@ -20,6 +20,7 @@
  
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #define linux_logo_banner "Linux/PA-RISC version " UTS_RELEASE
 
include/asm-ppc/linux_logo.h +1 -0
diff 25.1/include/asm-ppc/linux_logo.h
@@ -16,6 +16,7 @@
 #ifdef __KERNEL__
  
 #include <linux/init.h>
+#include <linux/uts_release.h>
 
 #define linux_logo_banner "Linux/PPC version " UTS_RELEASE
 
include/asm-ppc64/linux_logo.h +1 -0
diff 25.1/include/asm-ppc64/linux_logo.h
@@ -17,6 +17,7 @@
  */
  
 #include <linux/init.h>
+#include <linux/uts_release.h>
 
 #define linux_logo_banner "Linux/PPC-64 version " UTS_RELEASE
 
include/asm-sh/linux_logo.h +1 -0
diff 25.1/include/asm-sh/linux_logo.h
@@ -21,6 +21,7 @@
 
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #define linux_logo_banner "Linux/SuperH version " UTS_RELEASE
 
include/asm-sparc/linux_logo.h +1 -0
diff 25.1/include/asm-sparc/linux_logo.h
@@ -20,6 +20,7 @@
  
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #define linux_logo_banner "Linux/SPARC version " UTS_RELEASE
 
include/asm-sparc64/linux_logo.h +1 -0
diff 25.1/include/asm-sparc64/linux_logo.h
@@ -20,6 +20,7 @@
  
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #define linux_logo_banner "Linux/UltraSPARC version " UTS_RELEASE
 
include/asm-x86_64/linux_logo.h +1 -0
diff 25.1/include/asm-x86_64/linux_logo.h
@@ -20,6 +20,7 @@
  
 #include <linux/init.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 /* We should create logo of penguin with a big hammer (-: --pavel */
 
init/version.c +1 -0
diff 25.1/init/version.c
@@ -10,6 +10,7 @@
 #include <linux/uts.h>
 #include <linux/utsname.h>
 #include <linux/version.h>
+#include <linux/uts_release.h>
 
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
sound/core/info.c +1 -0
diff 25.1/sound/core/info.c
@@ -29,6 +29,7 @@
 #include <sound/minors.h>
 #include <sound/info.h>
 #include <sound/version.h>
+#include <linux/uts_release.h>
 #include <linux/proc_fs.h>
 #ifdef CONFIG_DEVFS_FS
 #include <linux/devfs_fs_kernel.h>
#1 lore raw
Quoted 12 lines · Keith Owens

include/linux/version.h contains both the numeric part of the kernel version and the full uts_release string. version.h is included almost everywhere, either on its own or via module.h. module.h and modutils only require the numeric kernel version, the use of UTS_RELEASE is incorrect and causes significant recompiles when EXTRAVERSION changes.

This patch moves UTS_RELEASE into its own header which is explicitly included in only the files that really use UTS_RELEASE. module.h uses a new field (KERNEL_VERSION_STRING) which has been added to version.h. With this patch, a change to EXTRAVERSION no longer recompiles 95% of your kernel.

Quoted 6 lines

The only significant changes are to module.h and Makefile. The rest of the patch is adding #include <linux/uts_release.h> in those files that use UTS_RELEASE. I suspect some of those files really only need KERNEL_VERSION_STRING but that has been left as an exercise for the file owners. Some of those files may no longer required version.h, again that has been left for the file owners.

When I looked at the same thing, I gave up when I realized that the EXTRAVERSION part is actually used in module.h, thereby affecting most files in the tree.

Now, you get around this by only including the numeric part of the kernel version in the module. That's of course a possibility, but I'd think people should be aware that this actually a major change.

(I just looked at modutils-2.4.15, don't know if sth changed in the latest version)

a) This change breaks compatibility to current modutils. A module compiled for 2.5.30-pre5 will contain only "2.5.30" as its version after your patch, thus current modutils will refuse to insert it into "2.5.30-pre5". (unless using insmod -f)
This is of course easily fixed by having a new version of modutils only compare the numeric part.

But then we have
b) modutils will not complain when insmod'ing a module compiled for 2.5.30-preX into 2.5.30-final (or any 2.5.30-, for that matter). If that happens, it of course means the user fscked up. However, I think the trend is to make things rather more fool-proof than less so, so I'm not convinced that we're on the right track with this change.

Of course, on the other hand the patch means that when going from -pre<N> to -pre<N+1> modules won't be recompiled just for the heck of updating the version string, but only if something else changed.

(We don't have -pre's in 2.5, so think 2.6, or inserting modules from -djX into a vanilla kernel or so)

As I'd guess this issue is somewhat controversial, I'd like to gather opinions on whether it should be done or not.

--Kai