LZ4 compression mode for wandboard linux kernel


#1

Hello,

I am trying to reduce the boot time for my wandboard, and I decide to change kernel compression mode from gzip to lz4 to let decompression faster.

After edit the setting in menuconfig then rebuild kernel, it seems build_kernel.sh is failed because there is no “Script Complete” message appear after script done, and armv7-multiplatform/deploy folder is empty.

Do I need other config to achieve lz4 compressed kernel ?


#2

@John_Doe, you need to install the lz4 package:

Which is currently only available in:

Debian Unstable: Buster/Sid

https://packages.debian.org/sid/lz4

Ubuntu: Cosmic/Disco

https://packages.ubuntu.com/cosmic/lz4

PS, we’ve been shipping CONFIG_KERNEL_XZ=y for awhile now in the armv7-multiplatform repo, for this exact reason. So I’m not sure why you were using CONFIG_KERNEL_GZIP…

Regards,


#3

Thanks for fast reply, and yes, you are right! Original compression mode is xz.

After install liblz4-tool, I can see kernel image is in the deploy folder.

But here comes a problem, if I change the kernel image’s compression mode, does u-boot know how to deal with it?

I tried just replace the original image file to new lz4 image file with same name, and then console hang after “Starting kernel …” print.

Do you know what the reason is?


#4

@John_Doe, u-boot doesn’t care… The kernel decompresser is at the front of the kernel image binary in un-compressed form… AKA… The kernel decompress’s it self. It’s more likely there’s an issue between your userspace version of lz4 and the version in the kernel.

Regards,


#5

Thanks for correcting me.

After some experiment, I found that there is a legacy format signature “02 21 4c 18” in my lz4 zImage.
So I think this is very strange for decompress failed.

I also downgrade my lz4 on my host machine(1.8.3->1.8.0) but got the same result.

By the way, I tried lzo format too, but the result as same as l4z format, it hang after “Starting kernel…” message print.

Maybe I need to find another way to reduce boot time.


#6

@John_Doe, here’s some numbers to look at:

U-Boot 2018.09, WandBoard Rev D Dual Core, from: http://elinux.org/BeagleBoardDebian default setting is CONFIG_KERNEL_XZ=y, it might be worth it for me to switch to LZO now, just need to double check with a single core WandBoard…

grabserial -d /dev/ttyUSB1 -t -e 30 -m "^Running uname_boot ..." -i "default username"
4.19.8-armv7-x11: CONFIG_KERNEL_XZ: (zImage: 7.3M)  (current default)
18.349406
18.615958
18.362553
4.19.8-armv7-x11: CONFIG_KERNEL_LZO: (zImage: 9.9M)
14.679745
14.553701
14.755084
4.19.8-armv7-x11: CONFIG_KERNEL_LZ4: (zImage: 11M)
14.656390
14.590860
14.648786
4.19.8-armv7-x11: CONFIG_KERNEL_GZIP: (zImage: 8.9M)
14.969708
15.036323
15.118005

Regards,


#7

@John_Doe, and with the Single Core WandBoard:

4.19.8-armv7-x11: CONFIG_KERNEL_XZ: (zImage: 7.3M)  (current default)
25.084367
25.012570
25.201086
4.19.8-armv7-x11: CONFIG_KERNEL_LZO: (zImage: 9.9M)
21.473511
21.485932
21.459568
4.19.8-armv7-x11: CONFIG_KERNEL_LZ4: (zImage: 11M)
21.138732
21.511619
21.669964
4.19.8-armv7-x11: CONFIG_KERNEL_GZIP: (zImage: 8.9M)
27.006874
27.274157
27.123350

I think i’m going to start transitioning our default to LZO, simply as it’s support by default in all Debian/Ubuntu stable distro’s with a nice speed up!

Regards,


#8

I have been tested the lzo kernel(4.19.8) on a quad core wandboard, and it can boot successfully with same speed like single core wandboard which you tested(~21sec).

And about the console hang issue I describe above, because I am using a 4.14 kernel. So I think here is the problem.

Maybe I can try 4.14 kernel with lzo compression mode again on a clean sdcard instead of only change the kernel image which under /boot folder to check this is not a kernel bug.


#9

@John_Doe,

I don’t see a hang with v4.14.x, just make sure you update both the kernel image and dtb’s…

4.14.71-armv7-x11.1: CONFIG_KERNEL_XZ
27.322555
27.415568
27.648054
4.14.71-armv7-x11.1: CONFIG_KERNEL_LZO
24.541265
24.511779
24.356083
4.14.71-armv7-x11.1: CONFIG_KERNEL_LZ4
24.486091
24.615016
24.497784
[2.908993 0.001383] Running uname_boot ...
[0.000677 0.000677] Using: mmcroot=PARTUUID=129f75fe-01 ro ...
[0.140033 0.139356] loading /boot/vmlinuz-4.14.71-armv7-x11.1 ...
[0.858913 0.718880] 12116480 bytes read in 708 ms (16.3 MiB/s)
[2.691806 1.832893] loading /boot/dtbs/4.14.71-armv7-x11.1/imx6dl-wandboard-revb1.dtb ...
[4.512762 1.820956] 48616 bytes read in 1809 ms (25.4 KiB/s)
[4.695491 0.182729] debug: [console=ttymxc0 root=PARTUUID=129f75fe-01 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0] ...
[4.696909 0.001418] debug: [bootz 0x12000000 - 0x18000000] ...
[4.697453 0.000544] ## Flattened Device Tree blob at 18000000
[4.698046 0.000593]    Booting using the fdt blob at 0x18000000
[4.698696 0.000650]    Using Device Tree in place at 18000000, end 1800ede7
[4.711522 0.012826] 
[4.711581 0.000059] Starting kernel ...
[4.711920 0.000339] 
[9.168339 4.456419] [    0.000000] Booting Linux on physical CPU 0x0
[9.168897 0.000558] [    0.000000] Linux version 4.14.71-armv7-x11.1 (voodoo@work-i7) (gcc version 7.3.1 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05)) #3 SMP PREEMPT Tue Dec 11 09:04:53 CST 2018
[9.171269 0.002372] [    0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c5387d
[9.172058 0.000789] [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[9.172928 0.000870] [    0.000000] OF: fdt: Machine model: Wandboard i.MX6 Dual Lite Board rev B1
[9.212391 0.039463] [    0.000000] Memory policy: Data cache writeback
[9.213291 0.000900] [    0.000000] efi: Getting EFI parameters from FDT:
[9.214255 0.000964] [    0.000000] efi: UEFI not found.
[9.214898 0.000643] [    0.000000] cma: Reserved 48 MiB at 0x2d000000
[9.215780 0.000882] [    0.000000] CPU: All CPU(s) started in SVC mode.
[9.216685 0.000905] [    0.000000] random: get_random_bytes called from start_kernel+0xac/0x454 with crng_init=0
[9.218141 0.001456] [    0.000000] percpu: Embedded 18 pages/cpu @dcb1d000 s41164 r8192 d24372 u73728
[9.218986 0.000845] [    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 129920
[9.255742 0.036756] [    0.000000] Kernel command line: console=ttymxc0 root=PARTUUID=129f75fe-01 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0
[9.258068 0.002326] [    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[9.259277 0.001209] [    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[9.260748 0.001471] [    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[9.262159 0.001411] [    0.000000] Memory: 446104K/524288K available (14336K kernel code, 1644K rwdata, 5112K rodata, 2048K init, 380K bss, 29032K reserved, 49152K cma-reserved, 0K highmem)
[9.299006 0.036847] [    0.000000] Virtual kernel memory layout:
[9.299557 0.000551] [    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[9.300341 0.000784] [    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[9.301122 0.000781] [    0.000000]     vmalloc : 0xe0800000 - 0xff800000   ( 496 MB)
[9.302083 0.000961] [    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
[9.303084 0.001001] [    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[9.304087 0.001003] [    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[9.341901 0.037814] [    0.000000]       .text : 0xc0008000 - 0xc0f00000   (15328 kB)
[9.343486 0.001585] [    0.000000]       .init : 0xc1400000 - 0xc1600000   (2048 kB)
[9.345016 0.001530] [    0.000000]       .data : 0xc1600000 - 0xc179b328   (1645 kB)
[9.346277 0.001261] [    0.000000]        .bss : 0xc17a67bc - 0xc1805910   ( 381 kB)
[9.347405 0.001128] [    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[9.348681 0.001276] [    0.000000] ftrace: allocating 46687 entries in 137 pages
[9.349738 0.001057] [    0.000000] Preemptible hierarchical RCU implementation.
[9.350542 0.000804] [    0.000000] 	RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=2.
[9.385702 0.035160] [    0.000000] 	Tasks RCU enabled.
[9.386327 0.000625] [    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[9.387665 0.001338] [    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[9.388381 0.000716] [    0.000000] L2C-310 erratum 769419 enabled
[9.388901 0.000520] [    0.000000] L2C-310 enabling early BRESP for Cortex-A9
[9.389562 0.000661] [    0.000000] L2C-310 full line of zeros enabled for Cortex-A9
[9.390283 0.000721] [    0.000000] L2C-310 ID prefetch enabled, offset 16 lines
[9.390958 0.000675] [    0.000000] L2C-310 dynamic clock gating enabled, standby mode enabled
[9.429183 0.038225] [    0.000000] L2C-310 cache controller enabled, 16 ways, 512 kB
[9.429980 0.000797] [    0.000000] L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x76450001
[9.430626 0.000646] [    0.000000] Switching to timer-based delay loop, resolution 333ns

Regards,