2002-07-06 11:51:42

by Keith Owens

[permalink] [raw]
Subject: [patch] 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

diff 25.1/include/linux/module.h
--- 25.1/include/linux/module.h
+++ 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";
diff 25.1/Makefile
--- 25.1/Makefile
+++ 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 \
diff 25.1/arch/alpha/boot/bootp.c
--- 25.1/arch/alpha/boot/bootp.c
+++ 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>
diff 25.1/arch/alpha/boot/main.c
--- 25.1/arch/alpha/boot/main.c
+++ 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>
diff 25.1/arch/i386/boot/setup.S
--- 25.1/arch/i386/boot/setup.S
+++ 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>
diff 25.1/arch/ppc/kernel/btext.c
--- 25.1/arch/ppc/kernel/btext.c
+++ 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>
diff 25.1/arch/ppc/platforms/chrp_setup.c
--- 25.1/arch/ppc/platforms/chrp_setup.c
+++ 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>
diff 25.1/arch/ppc64/kernel/chrp_setup.c
--- 25.1/arch/ppc64/kernel/chrp_setup.c
+++ 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>
diff 25.1/arch/x86_64/boot/setup.S
--- 25.1/arch/x86_64/boot/setup.S
+++ 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>
diff 25.1/drivers/block/floppy.c
--- 25.1/drivers/block/floppy.c
+++ 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
diff 25.1/drivers/cdrom/aztcd.c
--- 25.1/drivers/cdrom/aztcd.c
+++ 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))
diff 25.1/drivers/cdrom/mcdx.c
--- 25.1/drivers/cdrom/mcdx.c
+++ 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>
diff 25.1/drivers/char/ftape/compressor/zftape-compress.c
--- 25.1/drivers/char/ftape/compressor/zftape-compress.c
+++ 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>

diff 25.1/drivers/char/ftape/lowlevel/ftape-init.c
--- 25.1/drivers/char/ftape/lowlevel/ftape-init.c
+++ 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>
diff 25.1/drivers/char/ftape/zftape/zftape-init.c
--- 25.1/drivers/char/ftape/zftape/zftape-init.c
+++ 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>
diff 25.1/drivers/scsi/aic7xxx_old.c
--- 25.1/drivers/scsi/aic7xxx_old.c
+++ 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>
diff 25.1/drivers/scsi/megaraid.c
--- 25.1/drivers/scsi/megaraid.c
+++ 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>
diff 25.1/drivers/usb/core/hcd.c
--- 25.1/drivers/usb/core/hcd.c
+++ 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>
diff 25.1/include/asm-alpha/linux_logo.h
--- 25.1/include/asm-alpha/linux_logo.h
+++ 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

diff 25.1/include/asm-arm/linux_logo.h
--- 25.1/include/asm-arm/linux_logo.h
+++ 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

diff 25.1/include/asm-i386/linux_logo.h
--- 25.1/include/asm-i386/linux_logo.h
+++ 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

diff 25.1/include/asm-ia64/linux_logo.h
--- 25.1/include/asm-ia64/linux_logo.h
+++ 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

diff 25.1/include/asm-m68k/linux_logo.h
--- 25.1/include/asm-m68k/linux_logo.h
+++ 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

diff 25.1/include/asm-mips/linux_logo_dec.h
--- 25.1/include/asm-mips/linux_logo_dec.h
+++ 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
diff 25.1/include/asm-mips/linux_logo_sgi.h
--- 25.1/include/asm-mips/linux_logo_sgi.h
+++ 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
diff 25.1/include/asm-mips64/linux_logo.h
--- 25.1/include/asm-mips64/linux_logo.h
+++ 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

diff 25.1/include/asm-parisc/linux_logo.h
--- 25.1/include/asm-parisc/linux_logo.h
+++ 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

diff 25.1/include/asm-ppc/linux_logo.h
--- 25.1/include/asm-ppc/linux_logo.h
+++ 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

diff 25.1/include/asm-ppc64/linux_logo.h
--- 25.1/include/asm-ppc64/linux_logo.h
+++ 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

diff 25.1/include/asm-sh/linux_logo.h
--- 25.1/include/asm-sh/linux_logo.h
+++ 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

diff 25.1/include/asm-sparc/linux_logo.h
--- 25.1/include/asm-sparc/linux_logo.h
+++ 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

diff 25.1/include/asm-sparc64/linux_logo.h
--- 25.1/include/asm-sparc64/linux_logo.h
+++ 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

diff 25.1/include/asm-x86_64/linux_logo.h
--- 25.1/include/asm-x86_64/linux_logo.h
+++ 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 */

diff 25.1/init/version.c
--- 25.1/init/version.c
+++ 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)
diff 25.1/sound/core/info.c
--- 25.1/sound/core/info.c
+++ 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>


2002-07-07 01:52:17

by Keith Owens

[permalink] [raw]
Subject: Re: [patch] 2.5.25 remove unnecessary recompiles when changing EXTRAVERSION

On Sat, 06 Jul 2002 16:47:21 -0400,
Albert Cranford <[email protected]> wrote:
>What do the changes to Makefile-2.5 look like for
>Kbuild-3.1 ?

This has had two minutes of testing. Apply after core-21, it should
auto detect if the uts_release patch has been applied or not. This
will be included in kbuild 2.5 once the uts_release.h patch is included
in 2.5.x, I am holding off in case the uts_release patch has to change.

Index: 18.99/Makefile-2.5
--- 18.99/Makefile-2.5 Fri, 05 Jul 2002 17:16:39 +1000 kaos (linux-2.4/E/d/40_Makefile-2 1.32.2.27.1.8 644)
+++ 18.99(w)/Makefile-2.5 Sun, 07 Jul 2002 11:52:02 +1000 kaos (linux-2.4/E/d/40_Makefile-2 1.32.2.27.1.8 644)
@@ -588,13 +588,24 @@ endif

export KERNELRELEASE VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION USERVERSION

+# This code has to work on kernels with and without a separate uts_release.h.
+# If module.h still uses UTS_RELEASE then then assume that version.h must
+# include uts_release.h.
+
+ifneq ($(shell grep UTS_RELEASE $(KBUILD_SRCTREE_000)include/linux/module.h),)
+ include_uts_release := \#include <linux/uts_release.h>
+else
+ include_uts_release := /* uts_release.h is now handled separately */
+endif
+
$(KBUILD_OBJTREE)include/linux/version.h: $(KBUILD_OBJTREE)A_version FORCE_BUILD
@cd $(KBUILD_OBJTREE)
ifeq ($(KBUILD_WRITABLE),y)
@mkdir -p $(KBUILD_OBJTREE)include/linux
- @(echo \#include \<linux/uts_release.h\> && \
+ @(echo '$(include_uts_release)' && \
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(a,b,c) (((a) << 16) + ((b) << 8) + (c))' && \
+ echo '#define KERNEL_VERSION_STRING "$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)"' \
) > $(KBUILD_OBJTREE).tmp_version.h && \
(cmp -s $(KBUILD_OBJTREE).tmp_version.h $@ || mv -f $(KBUILD_OBJTREE).tmp_version.h $@)
endif

2002-07-22 00:17:27

by Kai Germaschewski

[permalink] [raw]
Subject: Re: [patch] 2.5.25 remove unnecessary recompiles when changing EXTRAVERSION

On Sat, 6 Jul 2002, Keith Owens wrote:

> 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.

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