Skip to contentSkip to conversation

init: bzip2 or lzma -compressed kernels and initrds

PATCH In review Alain Knaff 3 participants 25 messages Sep 9, 2008 – Oct 13, 2008

Subsystems (5)
x86 VFS Block layer Kbuild +1 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 init: bzip2 or lzma -compressed kernels and initrds

From: Alain Knaff <[email protected]>

This is an updated version of my bzip2/lzma patch

It is based on an idea by Christian Ludwig, includes support for compressing the kernel with bzip2 or lzma rather than gzip. Both compressors give smaller sizes than gzip. Lzma's decompresses faster than bzip2.

It also supports ramdisks and initramfs' compressed using these two compressors.

The functionality has been successfully used for a couple of years by the udpcast project

This version applies to "tip" kernel 2.6.27-rc5

Changes since last version (update2):

- Removed NEW_CODE #ifdef : non-Intel architectures will be patched eventually anyways
- Replaced IN_MEMORY #ifdefs by (less efficient) runtime checks

---

arch/x86/boot/compressed/head_32.S +1 -3
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/arch/x86/boot/compressed/head_32.S linux.trees.git.udpcast/arch/x86/boot/compressed/head_32.S
@@ -143,7 +143,7 @@ relocated:
 	pushl %eax	# input_len
 	leal input_data(%ebx), %eax
 	pushl %eax	# input_data
-	leal boot_heap(%ebx), %eax
+	leal _end(%ebx), %eax
 	pushl %eax	# heap area
 	pushl %esi	# real mode pointer
 	call decompress_kernel
@@ -184,8 +184,6 @@ relocated:
 .bss
 /* Stack and heap for uncompression */
 .balign 4
-boot_heap:
-	.fill BOOT_HEAP_SIZE, 1, 0
 boot_stack:
 	.fill BOOT_STACK_SIZE, 1, 0
 boot_stack_end:
arch/x86/boot/compressed/head_64.S +1 -3
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/arch/x86/boot/compressed/head_64.S linux.trees.git.udpcast/arch/x86/boot/compressed/head_64.S
@@ -287,7 +287,7 @@ relocated:
  */
 	pushq	%rsi			# Save the real mode argument
 	movq	%rsi, %rdi		# real mode address
-	leaq	boot_heap(%rip), %rsi	# malloc area for uncompression
+	leaq	_end(%rip), %rsi	# malloc area for uncompression
 	leaq	input_data(%rip), %rdx  # input_data
 	movl	input_len(%rip), %eax
 	movq	%rax, %rcx		# input_len
@@ -316,8 +316,6 @@ gdt_end:
 .bss
 /* Stack and heap for uncompression */
 .balign 4
-boot_heap:
-	.fill BOOT_HEAP_SIZE, 1, 0
 boot_stack:
 	.fill BOOT_STACK_SIZE, 1, 0
 boot_stack_end:
arch/x86/boot/compressed/Makefile +18 -2
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/arch/x86/boot/compressed/Makefile linux.trees.git.udpcast/arch/x86/boot/compressed/Makefile
@@ -4,7 +4,7 @@
 # create a compressed vmlinux image from the original vmlinux
 #
 
-targets := vmlinux vmlinux.bin vmlinux.bin.gz head_$(BITS).o misc.o piggy.o
+targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma head_$(BITS).o misc.o piggy.o
 
 KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
 KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
@@ -47,18 +47,34 @@ ifeq ($(CONFIG_X86_32),y)
 ifdef CONFIG_RELOCATABLE
 $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin.all FORCE
 	$(call if_changed,gzip)
+$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin.all FORCE
+	$(call if_changed,bzip2)
+$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin.all FORCE
+	$(call if_changed,lzma)
 else
 $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
 	$(call if_changed,gzip)
+$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
+	$(call if_changed,bzip2)
+$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
+	$(call if_changed,lzma)
 endif
 LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T
 
 else
 $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
 	$(call if_changed,gzip)
+$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
+	$(call if_changed,bzip2)
+$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
+	$(call if_changed,lzma)
 
 LDFLAGS_piggy.o := -r --format binary --oformat elf64-x86-64 -T
 endif
 
-$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
+suffix_$(CONFIG_KERNEL_GZIP)  = gz
+suffix_$(CONFIG_KERNEL_BZIP2) = bz2
+suffix_$(CONFIG_KERNEL_LZMA)  = lzma
+
+$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix_y) FORCE
 	$(call if_changed,ld)
arch/x86/boot/compressed/misc.c +36 -89

191 lines not on this page · raw message

Binary files linux.trees.git/arch/x86/vdso/vdso32-int80.so.dbg and linux.trees.git.udpcast/arch/x86/vdso/vdso32-int80.so.dbg differ Binary files linux.trees.git/arch/x86/vdso/vdso32-sysenter.so.dbg and linux.trees.git.udpcast/arch/x86/vdso/vdso32-sysenter.so.dbg differ

drivers/block/Kconfig +24 -0
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/drivers/block/Kconfig linux.trees.git.udpcast/drivers/block/Kconfig
@@ -357,6 +357,30 @@ config BLK_DEV_XIP
 	  will prevent RAM block device backing store memory from being
 	  allocated from highmem (only a problem for highmem systems).
 
+config RD_BZIP2
+	bool "Initial ramdisk compressed using bzip2"
+	default n
+	depends on BLK_DEV_INITRD=y
+	help
+	  Support loading of a bzip2 encoded initial ramdisk or cpio buffer
+	  If unsure, say N.
+
+config RD_LZMA
+	bool "Initial ramdisk compressed using lzma"
+	default n
+	depends on BLK_DEV_INITRD=y
+	help
+	  Support loading of a lzma encoded initial ramdisk or cpio buffer
+	  If unsure, say N.
+
+config RD_GZIP
+	bool "Initial ramdisk compressed using gzip"
+	default y
+	depends on BLK_DEV_INITRD=y
+	help
+	  Support loading of a gzip encoded initial ramdisk or cpio buffer.
+	  If unsure, say Y.
+
 config CDROM_PKTCDVD
 	tristate "Packet writing on CD/DVD media"
 	depends on !UML
include/asm-x86/boot.h +11 -1
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/include/asm-x86/boot.h linux.trees.git.udpcast/include/asm-x86/boot.h
@@ -17,11 +17,21 @@
 				+ (CONFIG_PHYSICAL_ALIGN - 1)) \
 				& ~(CONFIG_PHYSICAL_ALIGN - 1))
 
+#if (defined CONFIG_KERNEL_BZIP2)
+#define BOOT_HEAP_SIZE             0x400000
+#else
+
 #ifdef CONFIG_X86_64
 #define BOOT_HEAP_SIZE	0x7000
-#define BOOT_STACK_SIZE	0x4000
 #else
 #define BOOT_HEAP_SIZE	0x4000
+#endif
+
+#endif
+
+#ifdef CONFIG_X86_64
+#define BOOT_STACK_SIZE	0x4000
+#else
 #define BOOT_STACK_SIZE	0x1000
 #endif
 
include/linux/decompress_bunzip2.h +9 -0
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/include/linux/decompress_bunzip2.h linux.trees.git.udpcast/include/linux/decompress_bunzip2.h
@@ -0,0 +1,9 @@
+#ifndef DECOMPRESS_BUNZIP2_H
+#define DECOMPRESS_BUNZIP2_H
+
+int bunzip2(char *inbuf, int len,
+	    int(*fill)(void*, unsigned int),
+	    int(*flush)(void*, unsigned int),
+	    unsigned char *output,
+	    int *pos);
+#endif
include/linux/decompress_generic.h +29 -0
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/include/linux/decompress_generic.h linux.trees.git.udpcast/include/linux/decompress_generic.h
@@ -0,0 +1,29 @@
+#ifndef DECOMPRESS_GENERIC_H
+#define DECOMPRESS_GENERIC_H
+
+/* Minimal chunksize to be read.
+ *Bzip2 prefers at least 4096
+ *Lzma prefers 0x10000 */
+#define COMPR_IOBUF_SIZE	4096
+
+typedef int (*uncompress_fn) (char *inbuf, int len,
+			      int(*fill)(void*, unsigned int),
+			      int(*writebb)(void*, unsigned int),
+			      unsigned char *output,
+			      int *posp);
+
+/* inbuf   - input buffer
+ *len     - len of pre-read data in inbuf
+ *fill    - function to fill inbuf if empty
+ *writebb - function to write out outbug
+ *posp    - if non-null, input position (number of bytes read) will be
+ *	  returned here
+ *
+ *If len != 0, the inbuf is initialized (with as much data), and fill
+ *should not be called
+ *If len = 0, the inbuf is allocated, but empty. Its size is IOBUF_SIZE
+ *fill should be called (repeatedly...) to read data, at most IOBUF_SIZE
+ */
+
+
+#endif
include/linux/decompress_unlzma.h +12 -0
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/include/linux/decompress_unlzma.h linux.trees.git.udpcast/include/linux/decompress_unlzma.h
@@ -0,0 +1,12 @@
+#ifndef DECOMPRESS_UNLZMA_H
+#define DECOMPRESS_UNLZMA_H
+
+
+int unlzma(char *, int,
+	   int(*fill)(void*, unsigned int),
+	   int(*flush)(void*, unsigned int),
+	   unsigned char *output,
+	   int *
+	);
+
+#endif
include/linux/inflate.h +12 -0
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/include/linux/inflate.h linux.trees.git.udpcast/include/linux/inflate.h
@@ -0,0 +1,12 @@
+#ifndef INFLATE_H
+#define INFLATE_H
+
+/* Other housekeeping constants */
+#define INBUFSIZ 4096
+
+int gunzip(char *inbuf, int len,
+	   int(*fill)(void*, unsigned int),
+	   int(*flush)(void*, unsigned int),
+	   unsigned char *output,
+	   int *pos);
+#endif
init/do_mounts_rd.c +84 -128

287 lines not on this page · raw message

init/initramfs.c +48 -78

162 lines not on this page · raw message

init/Kconfig +50 -0

56 lines not on this page · raw message

lib/boot_mm.c +43 -0

43 lines not on this page · raw message

lib/decompress_bunzip2.c +763 -0

763 lines not on this page · raw message

lib/decompress_unlzma.c +680 -0

680 lines not on this page · raw message

lib/inflate.c +210 -90

482 lines not on this page · raw message

lib/Makefile +4 -0
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/lib/Makefile linux.trees.git.udpcast/lib/Makefile
@@ -57,6 +57,10 @@ obj-$(CONFIG_CRC7)	+= crc7.o
 obj-$(CONFIG_LIBCRC32C)	+= libcrc32c.o
 obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o
 
+obj-$(CONFIG_RD_GZIP)	+= inflate.o
+obj-$(CONFIG_RD_BZIP2)	+= decompress_bunzip2.o
+obj-$(CONFIG_RD_LZMA)	+= decompress_unlzma.o
+
 obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
 obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
 obj-$(CONFIG_REED_SOLOMON) += reed_solomon/
scripts/bin_size +10 -0
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/scripts/bin_size linux.trees.git.udpcast/scripts/bin_size
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ $# = 0 ] ; then
+   echo Usage: $0 file
+fi
+
+size_dec=`stat -c "%s" $1`
+size_hex_echo_string=`printf "%08x" $size_dec |
+     sed 's/\(..\)\(..\)\(..\)\(..\)/\\\\x\4\\\\x\3\\\\x\2\\\\x\1/g'`
+/bin/echo -ne $size_hex_echo_string
scripts/Makefile.lib +14 -0
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/scripts/Makefile.lib linux.trees.git.udpcast/scripts/Makefile.lib
@@ -174,3 +174,17 @@ quiet_cmd_gzip = GZIP    $@
 cmd_gzip = gzip -f -9 < $< > $@
 
 
+# Bzip2
+# ---------------------------------------------------------------------------
+
+# Bzip2 does not include size in file... so we have to fake that
+size_append=scripts/bin_size
+
+quiet_cmd_bzip2 = BZIP2    $@
+cmd_bzip2 = (bzip2 -9 < $< ; $(size_append) $<) > $@
+
+# Lzma
+# ---------------------------------------------------------------------------
+
+quiet_cmd_lzma = LZMA    $@
+cmd_lzma = (lzma -9 -c $<  ; $(size_append) $<) >$@
usr/initramfs_data.S +2 -2
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/usr/initramfs_data.S linux.trees.git.udpcast/usr/initramfs_data.S
@@ -8,7 +8,7 @@
 
 
   ld -m elf_i386  --format binary --oformat elf32-i386 -r \
-  -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o
+  -T initramfs_data.scr initramfs_data.cpio -o initramfs_data.o
    ld -m elf_i386  -r -o built-in.o initramfs_data.o
 
   initramfs_data.scr looks like this:
@@ -26,5 +26,5 @@ SECTIONS
 */
 
 .section .init.ramfs,"a"
-.incbin "usr/initramfs_data.cpio.gz"
+.incbin "usr/initramfs_data.cpio"
 
usr/Makefile +7 -7
diff -uNrp -X linux.trees.git.udpcast/Documentation/dontdiff linux.trees.git/usr/Makefile linux.trees.git.udpcast/usr/Makefile
@@ -12,7 +12,7 @@ obj-$(CONFIG_BLK_DEV_INITRD) := initramf
 # initramfs_data.o contains the initramfs_data.cpio.gz image.
 # The image is included using .incbin, a dependency which is not
 # tracked automatically.
-$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio.gz FORCE
+$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio FORCE
 
 #####
 # Generate the initramfs cpio archive
@@ -29,24 +29,24 @@ ramfs-args  := \
 # in initramfs and to detect if any files are added/removed.
 # Removed files are identified by directory timestamp being updated
 # The dependency list is generated by gen_initramfs.sh -l
-ifneq ($(wildcard $(obj)/.initramfs_data.cpio.gz.d),)
-	include $(obj)/.initramfs_data.cpio.gz.d
+ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
+	include $(obj)/.initramfs_data.cpio.d
 endif
 
 quiet_cmd_initfs = GEN     $@
       cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
 
-targets := initramfs_data.cpio.gz
+targets := initramfs_data.cpio
 # do not try to update files included in initramfs
 $(deps_initramfs): ;
 
 $(deps_initramfs): klibcdirs
-# We rebuild initramfs_data.cpio.gz if:
+# We rebuild initramfs_data.cpio if:
 # 1) Any included file is newer then initramfs_data.cpio.gz
 # 2) There are changes in which files are included (added or deleted)
 # 3) If gen_init_cpio are newer than initramfs_data.cpio.gz
 # 4) arguments to gen_initramfs.sh changes
-$(obj)/initramfs_data.cpio.gz: $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
-	$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.gz.d
+$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
+	$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
 	$(call if_changed,initfs)
 
#1 lore raw
Quoted 17 lines · Alain Knaff

From: Alain Knaff <[email protected]>

This is an updated version of my bzip2/lzma patch

It is based on an idea by Christian Ludwig, includes support for compressing the kernel with bzip2 or lzma rather than gzip. Both compressors give smaller sizes than gzip. Lzma's decompresses faster than bzip2.

It also supports ramdisks and initramfs' compressed using these two compressors.

The functionality has been successfully used for a couple of years by the udpcast project

This version applies to "tip" kernel 2.6.27-rc5

Quoted 7 lines

Changes since last version (update2):

- Removed NEW_CODE #ifdef : non-Intel architectures will be patched eventually anyways
- Replaced IN_MEMORY #ifdefs by (less efficient) runtime checks

Looks a lot better now. See the following, though:

arch/x86/boot/compressed/misc.c line 120

Quoted 3 lines
arch/x86/boot/compressed/misc.c +1 -1
-#define OF(args)	args
 #define STATIC		static
+#define NEW_CODE

Should be deleted, right?

arch/x86/boot/compressed/misc.c static void parse_elf(void *output) · line 309

Quoted 4 lines
arch/x86/boot/compressed/misc.c +1 -1
-	phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
+	phdrs = (void *) malloc(sizeof(*phdrs) * ehdr.e_phnum);
 	if (!phdrs)

malloc() returns a void pointer already...

Quoted 8 lines
init/do_mounts_rd.c +8 -0
+
+#ifdef CONFIG_RD_BZIP2
+	/*
+	 * If it matches the bzip magic numbers, return -1
+	 */
+	if (buf[0] == 0x42 && (buf[1] == 0x5a)) {
+		printk(KERN_NOTICE
+		       "RAMDISK: Bzipped image found at block %d\n",

init/do_mounts_rd.c identify_ramdisk_image(int fd, int start · line 129

Quoted 10 lines
init/do_mounts_rd.c +7 -0
+		       start_block);
+		*uncompressor = bunzip2;
 		nblocks = 0;
 		goto done;
 	}
+#endif
+
+#ifdef CONFIG_RD_LZMA
+	/*
+	 * If it matches the bzip magic numbers, return -1
                             ^^^^
                             ????
Quoted 5 lines
(quoted diff) +5 -0
+	 */
+	if (buf[0] == 0x5d && (buf[1] == 0x00)) {
+		printk(KERN_NOTICE
+		       "RAMDISK: Lzma image found at block %d\n",
+		       start_block);

Review

Quoted 10 lines
(quoted diff) +5 -1
 
 
 
-#define OF(args)  args
+#ifdef CONFIG_RD_BZIP2
+#include <linux/decompress_bunzip2.h>
+#endif
+#ifdef CONFIG_RD_LZMA
+#include <linux/decompress_unlzma.h>
 #endif

There is no reason to include header files conditionally.

It might be worthwhile to create a proper subdirectory rather than using an underscored namespace (also, in general, dashes are preferred in filenames.)

lib/decompress_unlzma.c line 101

Quoted 7 lines
lib/decompress_unlzma.c +7 -0
+#ifndef always_inline
+#  if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+#    define always_inline __attribute__((always_inline)) inline
+#  else
+#    define always_inline inline
+#  endif
+#endif

Any reason to not just use <linux/compiler.h> here?

lib/decompress_unlzma.c line 107

Quoted 5 lines
lib/decompress_unlzma.c +5 -0
+#ifdef CONFIG_FEATURE_LZMA_FAST
+#  define speed_inline always_inline
+#else
+#  define speed_inline
+#endif

Should this be always_inline or just plain inline?

-hpa

#2 lore raw
Quoted 1 line · H. Peter Anvin

Looks a lot better now. See the following, though:

Thanks :)

Quoted 6 lines

arch/x86/boot/compressed/misc.c line 120

Quoted 4 lines
arch/x86/boot/compressed/misc.c +1 -1
-#define OF(args)    args
 #define STATIC        static
+#define NEW_CODE

Should be deleted, right?

Is already deleted in update4, posted yesterday.

Quoted 5 lines

arch/x86/boot/compressed/misc.c static void parse_elf(void *output) · line 309

Quoted 3 lines
arch/x86/boot/compressed/misc.c +1 -1
-    phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
+    phdrs = (void *) malloc(sizeof(*phdrs) * ehdr.e_phnum);
     if (!phdrs)

malloc() returns a void pointer already...

ok, I'll consider this for update5

Quoted 12 lines
Quoted 12 lines
init/do_mounts_rd.c +10 -0
+
+#ifdef CONFIG_RD_BZIP2
+    /*
+     * If it matches the bzip magic numbers, return -1
+     */
+    if (buf[0] == 0x42 && (buf[1] == 0x5a)) {
+        printk(KERN_NOTICE
+               "RAMDISK: Bzipped image found at block %d\n",
+               start_block);
+        *uncompressor = bunzip2;
         nblocks = 0;
         goto done;
Quoted 13 lines

init/do_mounts_rd.c identify_ramdisk_image(int fd, int start · line 129

Quoted 6 lines
     }
init/do_mounts_rd.c +5 -0
+#endif
+
+#ifdef CONFIG_RD_LZMA
+    /*
+     * If it matches the bzip magic numbers, return -1
                             ^^^^
                             ????
Quoted 5 lines
init/do_mounts_rd.c +5 -0
+     */
+    if (buf[0] == 0x5d && (buf[1] == 0x00)) {
+        printk(KERN_NOTICE
+               "RAMDISK: Lzma image found at block %d\n",
+               start_block);

noted, will be fixed in update5

Quoted 10 lines

init/initramfs.c static void __init flush_buffer(char *bu · line 365

Quoted 7 lines
init/initramfs.c +5 -1
-#define OF(args)  args
+#ifdef CONFIG_RD_BZIP2
+#include <linux/decompress_bunzip2.h>
+#endif
+#ifdef CONFIG_RD_LZMA
+#include <linux/decompress_unlzma.h>
 #endif

There is no reason to include header files conditionally.

Quoted 3 lines

It might be worthwhile to create a proper subdirectory rather than using an underscored namespace (also, in general, dashes are preferred in filenames.)

I hate to contradict you, but in that case, lots of other filenames would need fixing too:

Quoted 1 line

ls include/linux/*_*.h

include/linux/8250_pci.h             include/linux/linux_logo.h
include/linux/ac97_codec.h           include/linux/lm_interface.h
include/linux/acpi_pmtmr.h           include/linux/memory_hotplug.h
include/linux/adfs_fs.h              include/linux/minix_fs.h
include/linux/adfs_fs_i.h            include/linux/mm_inline.h
include/linux/adfs_fs_sb.h           include/linux/mm_types.h
include/linux/affs_hardblocks.h      include/linux/mmu_notifier.h
include/linux/agp_backend.h          include/linux/mnt_namespace.h
include/linux/aio_abi.h              include/linux/mod_devicetable.h
include/linux/anon_inodes.h          include/linux/msdos_fs.h

....

And dashes are not even in the majority:

Quoted 1 line

ls include/linux/*-*.h | wc

     67      67    1867
Quoted 1 line

ls include/linux/*_*.h | wc

    282     282    7598

Any other people want to chime in about this before I make update5? I'm all for adopting common coding standards, but only if they are actually common...

Quoted 10 lines

lib/decompress_unlzma.c line 101

Quoted 8 lines
(quoted diff) +2 -0
+#ifndef always_inline
+#  if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 &&

__GNUC_MINOR__ > 0)

lib/decompress_unlzma.c +5 -0
+#    define always_inline __attribute__((always_inline)) inline
+#  else
+#    define always_inline inline
+#  endif
+#endif

Any reason to not just use <linux/compiler.h> here?

As you may have understood, the decompressors themselves are samples and/or reference implementations downloaded from elsewhere, and thus might not be up to the coding standards of the rest of the kernel.

... but the same can be said of inflate.c (the existing gzip decompressor), which would not pass muster either (and indeed, the only scripts/checkpatch.pl WARNINGS of my patch are about funny indentation of inflate.c that happen in the context of my changes...)

There's a fine line to walk here between "bringing up" these codes to standard (at the risk of breaking them...) or touching the decompressing engines as little as possible.

But, I've taken note for update5...

Quoted 9 lines

lib/decompress_unlzma.c line 107

Quoted 5 lines
lib/decompress_unlzma.c +5 -0
+#ifdef CONFIG_FEATURE_LZMA_FAST
+#  define speed_inline always_inline
+#else
+#  define speed_inline
+#endif

Should this be always_inline or just plain inline?

-hpa

Same remark: this is 3rd party code which I preferred to touch as little as possible...

Alain

#3 lore raw
Quoted 8 lines · Alain Knaff
Quoted 5 lines

There is no reason to include header files conditionally.

It might be worthwhile to create a proper subdirectory rather than using an underscored namespace (also, in general, dashes are preferred in filenames.)

I hate to contradict you, but in that case, lots of other filenames would need fixing too:

Not arguing that. However, in this case I think the right thing is to make a subdirectory.

Quoted 5 lines
Quoted 1 line

Any reason to not just use <linux/compiler.h> here?

As you may have understood, the decompressors themselves are samples and/or reference implementations downloaded from elsewhere, and thus might not be up to the coding standards of the rest of the kernel.

I'm familiar with that. However, I think in this case it is preferrable to use the all-kernel facilities, since there is an obvious direct mapping.

-hpa

#4 lore raw

What do you think about update5? Any things still to improve, or is it already scheduled for inclusion in one of the upcoming kernels? If so, which one?

Thanks for any info,

Alain

#5 lore raw
Quoted 5 lines · Alain Knaff

What do you think about update5? Any things still to improve, or is it already scheduled for inclusion in one of the upcoming kernels? If so, which one?

Thanks for any info,

I was out of town for LKS/LPC last week, and I didn't get a chance to deal with it before I left. However, it's definitely getting there.

I will add it to the -tip tree, and assuming it doesn't cause massive breakage it probably will be pushed into .28.

-hpa

#6 lore raw
Quoted 7 lines · H. Peter Anvin
Quoted 5 lines · Alain Knaff

What do you think about update5? Any things still to improve, or is it already scheduled for inclusion in one of the upcoming kernels? If so, which one?

Thanks for any info,

Quoted 7 lines

I was out of town for LKS/LPC last week, and I didn't get a chance to deal with it before I left. However, it's definitely getting there.

I will add it to the -tip tree, and assuming it doesn't cause massive breakage it probably will be pushed into .28.

-hpa

Thanks,

Alain

#7 lore raw
Quoted 10 lines · Alain Knaff
Quoted 9 lines · H. Peter Anvin
Quoted 5 lines · Alain Knaff

What do you think about update5? Any things still to improve, or is it already scheduled for inclusion in one of the upcoming kernels? If so, which one?

Thanks for any info,

I was out of town for LKS/LPC last week, and I didn't get a chance to deal with it before I left. However, it's definitely getting there.

Quoted 8 lines
Quoted 4 lines

I will add it to the -tip tree, and assuming it doesn't cause massive breakage it probably will be pushed into .28.

-hpa

Thanks,

Alain

Just did so, and it broke my first test build.

arch/x86/boot/compressed/head_64.o: In function `relocated':
(.text+0x28): undefined reference to `_end' make[3]: *** [arch/x86/boot/compressed/vmlinux] Error 1 make[2]: *** [arch/x86/boot/compressed/vmlinux] Error 2 make[1]: *** [bzImage] Error 2
make: *** [sub-make] Error 2

-hpa

#8 lore raw
Quoted 10 lines · H. Peter Anvin

Just did so, and it broke my first test build.

arch/x86/boot/compressed/head_64.o: In function `relocated':
(.text+0x28): undefined reference to `_end' make[3]: *** [arch/x86/boot/compressed/vmlinux] Error 1 make[2]: *** [arch/x86/boot/compressed/vmlinux] Error 2 make[1]: *** [bzImage] Error 2
make: *** [sub-make] Error 2

-hpa

Just leave the changes in head_64.S away; this was only about improved memory management. It is not strictly needed, as the change in /include/asm-x86/boot.h still makes sure that the heap is big enough, even for bzip2

Regards,

Alain

#9 lore raw
Quoted 10 lines · Alain Knaff
Quoted 9 lines · H. Peter Anvin

Just did so, and it broke my first test build.

arch/x86/boot/compressed/head_64.o: In function `relocated':
(.text+0x28): undefined reference to `_end' make[3]: *** [arch/x86/boot/compressed/vmlinux] Error 1 make[2]: *** [arch/x86/boot/compressed/vmlinux] Error 2 make[1]: *** [bzImage] Error 2
make: *** [sub-make] Error 2

Quoted 7 lines
Quoted 1 line

-hpa

Just leave the changes in head_64.S away; this was only about improved memory management. It is not strictly needed, as the change in /include/asm-x86/boot.h still makes sure that the heap is big enough, even for bzip2

OK, this kind of underscores something I have been thinking already: this is a really large patch and should be broken down into a patchset.
Presumably something like:

- Cleanups to inflate library code
- Use existing library code for initramfs
- Add bzip2 library code
- Add lzma library code
- Add support for bzip2/lzma initrd
- Add support for bzip2/lzma bzImage

-hpa

#10 lore raw
In reply to Alain Knaff
Quoted 10 lines · Alain Knaff
Quoted 9 lines · H. Peter Anvin

Just did so, and it broke my first test build.

arch/x86/boot/compressed/head_64.o: In function `relocated':
(.text+0x28): undefined reference to `_end' make[3]: *** [arch/x86/boot/compressed/vmlinux] Error 1 make[2]: *** [arch/x86/boot/compressed/vmlinux] Error 2 make[1]: *** [bzImage] Error 2
make: *** [sub-make] Error 2

Quoted 6 lines
Quoted 1 line

-hpa

Just leave the changes in head_64.S away; this was only about improved memory management. It is not strictly needed, as the change in /include/asm-x86/boot.h still makes sure that the heap is big enough, even for bzip2

More failures...

/bin/sh: scripts/bin_size: No such file or directory

Happens with O=.

-hpa

#11 lore raw
Quoted 3 lines · H. Peter Anvin

More failures...

/bin/sh: scripts/bin_size: No such file or directory

Could be a permission issue. Did you try to chmod 755 scripts/bin_size ? Hmmm, diff does indeed not encode permissions, how should such cases be usually handled?

Quoted 1 line

Happens with O=.

What do you mean by this?

Quoted 1 line

-hpa

Alain

#12 lore raw
Quoted 9 lines · Alain Knaff
Quoted 3 lines · H. Peter Anvin

More failures...

/bin/sh: scripts/bin_size: No such file or directory

Could be a permission issue. Did you try to chmod 755 scripts/bin_size ? Hmmm, diff does indeed not encode permissions, how should such cases be usually handled?

git handles them, so that's usually okay.

Quoted 3 lines
Quoted 1 line

Happens with O=.

What do you mean by this?

I mean I'm using O= to build in a different object directory. It sometimes means one needs $(src) in places.

-hpa

#13 lore raw
Quoted 3 lines · H. Peter Anvin

I mean I'm using O= to build in a different object directory. It sometimes means one needs $(src) in places.

Sorry, $(srctree), not $(src).

-hpa

#14 lore raw
In reply to H. Peter Anvin
Quoted 1 line · H. Peter Anvin

I mean I'm using O= to build in a different object directory.

Could you please post an example of such a command line?

Thanks

Alain

#15 lore raw

[Trimming Cc: list]

Quoted 4 lines · Alain Knaff
Quoted 1 line · H. Peter Anvin

I mean I'm using O= to build in a different object directory.

Could you please post an example of such a command line?

mkdir o.junk
make O=o.junk defconfig
make O=o.junk

-hpa

#16 lore raw
Quoted 6 lines · H. Peter Anvin

[Trimming Cc: list]

Quoted 3 lines · Alain Knaff
Quoted 1 line · H. Peter Anvin

I mean I'm using O= to build in a different object directory.

Quoted 7 lines
Quoted 1 line

Could you please post an example of such a command line?

mkdir o.junk
make O=o.junk defconfig
make O=o.junk

-hpa

Thanks. That's interesting, especially when testing stuff for several architectures.

Alain

#17 lore raw

Hi Alain,

Are you planning to submit an updated patch any time soon? If so, please separate the ARM, x86, library and generic portions into separate patches. It looks like at least some of them already went into ARM, which makes it impractical to include this as a monolithic patch, which it really shouldn't have to be, anyway.

-hpa

#18 lore raw
Quoted 9 lines · H. Peter Anvin

Hi Alain,

Are you planning to submit an updated patch any time soon? If so, please separate the ARM, x86, library and generic portions into separate patches. It looks like at least some of them already went into ARM, which makes it impractical to include this as a monolithic patch, which it really shouldn't have to be, anyway.

-hpa

I'll look into it (the split) this weekend, if I'll find the time. Should each part be compilable on its own? If so, it might be difficult to do the split along the lines outlined above.

Alain

#19 lore raw
Quoted 9 lines · Alain Knaff
Quoted 8 lines · H. Peter Anvin

Hi Alain,

Are you planning to submit an updated patch any time soon? If so, please separate the ARM, x86, library and generic portions into separate patches. It looks like at least some of them already went into ARM, which makes it impractical to include this as a monolithic patch, which it really shouldn't have to be, anyway.

Quoted 6 lines
Quoted 1 line

-hpa

I'll look into it (the split) this weekend, if I'll find the time. Should each part be compilable on its own? If so, it might be difficult to do the split along the lines outlined above.

Not individually, but part 1 should compile, as should parts 1+2, etc.

This pretty much means the order should be:

1. add library functions
2. generic functionality
3. x86 functionality
4. ARM functionality

Soem of these may be obsolete; I noticed collisions with the ARM tree.

-hpa

#20 lore raw
Quoted 17 lines · H. Peter Anvin
Quoted 9 lines · Alain Knaff
Quoted 8 lines · H. Peter Anvin

Hi Alain,

Are you planning to submit an updated patch any time soon? If so, please separate the ARM, x86, library and generic portions into separate patches. It looks like at least some of them already went into ARM, which makes it impractical to include this as a monolithic patch, which it really shouldn't have to be, anyway.

Quoted 6 lines
Quoted 1 line

-hpa

I'll look into it (the split) this weekend, if I'll find the time. Should each part be compilable on its own? If so, it might be difficult to do the split along the lines outlined above.

Quoted 8 lines

Not individually, but part 1 should compile, as should parts 1+2, etc.

This pretty much means the order should be:

1. add library functions
2. generic functionality
3. x86 functionality
4. ARM functionality

Unfortunately, due to the nature of the patch, it will be hard to separate out "x86 functionality" from changes in lib/inflate.c . Indeed, a large part of the patch consists in moving some gzip-specific headers and internal variable declarations from the callers:
arch/x86/boot/compressed/misc.c on one hand, and init/do_mounts_rd.c and init/initramfs.c on the other hand into lib/inflate.c

So, leaving out the x86-specific change (arch/x86/boot/compressed/misc.c) in the first change, would force to leave that change out of lib/inflate.c as well (or else, the above-listed items would be doubly defined). But, if I left out these changes of lib/inflate.c, I'd need to leave them out of and init/do_mounts_rd.c and init/initramfs.c too (or else the above-listed items would not be defined at all in that situation). Can you suggest a solution? I could theoretically break that dependency chain using an #ifdef (as was the case until patch 3), but apparently #ifdef's are highly frowned upon. Or was it just the name of the ifdef ("NEW_CODE") that you objected to? Another option would be to (temporarily) keep 2 copies of lib/inflate.c around, but somehow that doesn't feel right.

So can you suggest some way out of the situation?

Quoted 4 lines

Soem of these may be obsolete; I noticed collisions with the ARM tree.

-hpa

Great! Could you tell me where to download the ARM tree from, so that I can have a look?

Thanks,

Alain

#21 lore raw
Quoted 14 lines · Alain Knaff

So, leaving out the x86-specific change (arch/x86/boot/compressed/misc.c) in the first change, would force to leave that change out of lib/inflate.c as well (or else, the above-listed items would be doubly defined). But, if I left out these changes of lib/inflate.c, I'd need to leave them out of and init/do_mounts_rd.c and init/initramfs.c too (or else the above-listed items would not be defined at all in that situation). Can you suggest a solution? I could theoretically break that dependency chain using an #ifdef (as was the case until patch 3), but apparently #ifdef's are highly frowned upon. Or was it just the name of the ifdef ("NEW_CODE") that you objected to? Another option would be to (temporarily) keep 2 copies of lib/inflate.c around, but somehow that doesn't feel right.

Quoted 2 lines

So can you suggest some way out of the situation?

Temporarily leaving two copies would work, as would be leaving in an #ifdef as long as it is gone by the end of the patch series.

-hpa

#22 lore raw
In reply to Alain Knaff
Quoted 6 lines · Alain Knaff

Great! Could you tell me where to download the ARM tree from, so that I can have a look?

Thanks,

Alain

Anybody can help here?

Thanks

Alain

#23 lore raw
In reply to Alain Knaff
Quoted 9 lines · Alain Knaff
Quoted 3 lines · H. Peter Anvin

More failures...

/bin/sh: scripts/bin_size: No such file or directory

Could be a permission issue. Did you try to chmod 755 scripts/bin_size ? Hmmm, diff does indeed not encode permissions, how should such cases be usually handled?

A few more thoughts:

quiet_cmd_bzip2 = BZIP2 $@
cmd_bzip2 = (bzip2 -9 < $< ; $(size_append) $<) > $@

quiet_cmd_lzma = LZMA $@
cmd_lzma = (lzma -9 -c $< ; $(size_append) $<) >$@

These will produce stale files on failure. Using stdout in Makefiles is a bit tricky. You probably need something like:

(bzip2 -9 < $< && $(size_append) $<) > $@ || (rm -f $@ ; false)

-hpa

#24 lore raw
In reply to Alain Knaff
Quoted 8 lines · Alain Knaff
Quoted 3 lines · H. Peter Anvin

More failures...

/bin/sh: scripts/bin_size: No such file or directory

Could be a permission issue. Did you try to chmod 755 scripts/bin_size ? Hmmm, diff does indeed not encode permissions, how should such cases be usually handled?

either you find a way to chmod +x from a makefile (but this is a bit tricky) or better, you call it with $(CONFIG_SHELL) :

   $(CONFIG_SHELL) scripts/bin_size

Some other commands in the makefiles are already handled this way.

Willy