Linux: Need build-in CONFIG_SQUASHFS_LZ4=y and other.

Created on 12 May 2017  路  22Comments  路  Source: raspberrypi/linux

Because default kernel use other systems, good idea add several parametrs:

$ make bcm2709_defconfig
$ echo "CONFIG_ZSWAP=y
CONFIG_ZPOOL=y
CONFIG_Z3FOLD=y
CONFIG_OVERLAY_FS=y
CONFIG_SQUASHFS=y
CONFIG_SQUASHFS_LZ4=y
CONFIG_CRYPTO_LZ4HC=m" >> .config
$ make oldconfig

or

$ diff .config.new .config.orig
560,561c560,561
< CONFIG_ZSWAP=y
< CONFIG_ZPOOL=y
---
> # CONFIG_ZSWAP is not set
> # CONFIG_ZPOOL is not set
563d562
< CONFIG_Z3FOLD=y
5220c5219
< CONFIG_OVERLAY_FS=y
---
> CONFIG_OVERLAY_FS=m
5300c5299
< CONFIG_SQUASHFS=y
---
> CONFIG_SQUASHFS=m
5308c5307
< CONFIG_SQUASHFS_LZ4=y
---
> # CONFIG_SQUASHFS_LZ4 is not set
5769c5768
< CONFIG_CRYPTO_LZO=y
---
> CONFIG_CRYPTO_LZO=m
5772c5771
< CONFIG_CRYPTO_LZ4HC=m
---
> # CONFIG_CRYPTO_LZ4HC is not set
5841d5839
< CONFIG_LZ4HC_COMPRESS=m
  1. build-in overlayfs need for boot RO rootfs w/o initramfs
  2. build-in squashfs need for boot squashfs as rootfs w/o initramfs
  3. lz4hc is very very fast for squashfs (squashfs_lz4 include lz4hc)
  4. zswap is very good idea for raspberry ;)
Close within 30 days Waiting for external input Waiting for internal comment

Most helpful comment

Hi @pelwell,

Is there anything I can do to help get this changed?

Thanks!

All 22 comments

Do you have any figures for impact on kernel size and performance? Given a limited resources device like the Pi we like to ensure that kernel changes for smaller use cases do not have a detrimental impact.

1 may impose a small overhead on file operations (one of it's dependencies adds some extra code in many places in the VFS layer), but it isn't much impact even on systems with very high-speed storage (read as high-end NVMe SSD's), so it likely won't be noticeable on a Pi, 2 and 3 should have no impact on performance, 4 will have near zero performance impact when not turned on (and it defaults to disabled), although it will result in pathologically bad memory usage if enabled when using zram for swap.

As far as space usage, I can't' give much advice, except that if SquashFS is built-in, you should make sure all the supported compression algorithms are enabled, otherwise you will get complaints from peopel wanting to use other algorithms.

lz4 have very-very small code, and it is very-very fast, it designed for small and slow systems
lz4hc is better from lz4 for one time compress many time decompress

minimum change is
CONFIG_ZSWAP=m
CONFIG_ZPOOL=m
CONFIG_Z3FOLD=m
CONFIG_SQUASHFS_LZ4=y
CONFIG_CRYPTO_LZ4HC=m

my raspberry pi 3 with SanDiskUltra
f2fs+zswap+swapfs->loopdev->sparsefile+tmpfs
is faster then my big comp with hdd now

PS I think you undestand russian link, because shell-commands is english :)

for example, then I compile kernel for upgrade
(/tmp is tmpfs,1Gb + zram 1Gb or zswap 2Gb)

cd /tmp
wget -P ~ https://github.com/raspberrypi/linux/archive/rpi-4.9.y.zip
unzip ~/rpi-4.9.y.zip
mksquashfs linux-rpi-4.9.y ~/rpi-4.9.y.squash -comp lz4  -Xhc -noI
rm -R linux-rpi-4.9.y
mkdir -p linux/low linux/up linux/work
sudo mount ~/rpi-4.9.y.squash linux/low
sudo mount -t overlay overlay -olowerdir=linux/low,upperdir=linux/up,workdir=linux/work linux
cd linux
make bcm2709_defconfig
echo "CONFIG_ZSWAP=y
CONFIG_ZPOOL=y
CONFIG_Z3FOLD=y
CONFIG_OVERLAY_FS=y
CONFIG_SQUASHFS=y
CONFIG_SQUASHFS_LZ4=y
CONFIG_CRYPTO_LZ4HC=m" >> .config
make oldconfig
make -j4 zImage modules dtbs
make modules_install
...

it's very fast, because did not write to SD then compile,
read and decompress faster than only read (if do not make squash)
unzip and mksquashfs faster then only unzip to SD

time and size mksquashfs raspbian-full:

  1. gzip 9:23 1444Mb
  2. lzo 17:11 1564Mb
  3. lz4 2:54 1912Mb
  4. lz4hc 6:05 1668Mb
  5. xz 24:24 1222Mb

lzo is very long time for me

@popcornmix @pelwell You guys have any thoughts on this?

I actually do the same thing, and I can also confirm faster build times along with better boot performance on the kernels as well, on average it shaves off 4 seconds from the default kernels.

Along with that, system performance is also a lot better. Using raspian stretch repos, LxQT, LightDM, watchdog, UFW, SSH, VC4 KMS, and VNC, I use 190MB on boot.

I also use KSM as well, since it helps with memory management with interperated, VM/IR, or JIT languages as well.

We are unlikely to move from modules to builtins as it affects the memory used and kernel load time for every pi user (when the vast majority don't use the features).
It is also a slippery slope for every user requesting their favourite modules are built in.

We'd need very compelling evidence for what the benefits are for the majority of pi users.
The output of free after booting with stock kernel and with modifies kernel would be useful information to provide.

You are right. Not everything modules is need built in.
I'll think about evidence. what is to need and not to need.

I am shure need add CONFIG_SQUASHFS_LZ4=y CONFIG_CRYPTO_LZ4HC=m
because it is modules, and it's very fast, that important for RPI
1) SQUASHFS_LZ4 faster then SQUASHFS_LZO
2) CONFIG_CRYPTO_LZ4HC=m need for ZRAM
CONFIG_CRYPTO_LZ4HC=m automaticaly add CONFIG_LZ4_COMPRESS=m
and then for ZRAM (or zswap if it exist) can select this compressor

PS for other questions I reopen new issues

Raspbian Stretch was released
squashfs-tools support lz4 now, but I can not mount this
I think need add CONFIG_SQUASHFS_LZ4=y for kernel support lz4 too
PS good idea for add CONFIG_CRYPTO_LZ4HC=m too (for zram support lz4hc too)

Hi all,

I have just hit this issue while preparing my custom OS image, I was hoping to switch to LZ4 (LZ4HC makes more sense) to speed up my embedded rpis. I already use LZ4 for ZRAM compression, so this would complement it nicely.

CONFIG_SQUASHFS_LZ4=y
CONFIG_CRYPTO_LZ4HC=m

Hi @popcornmix

As requested here is a comparison between vanilla git kernel, and after the above enabled options:

Linux raspberrypi-vanilla 4.9.52+ #1 Thu Oct 5 19:23:11 CEST 2017 armv6l GNU/Linux

              total        used        free      shared  buff/cache   available
Mem:         444492       21204      333952        5856       89336      369816
Swap:        102396           0      102396
Linux raspberrypi-lz4 4.9.52+ #1 Thu Oct 5 19:44:51 CEST 2017 armv6l GNU/Linux

              total        used        free      shared  buff/cache   available
Mem:         444492       21168      336796        3076       86528      372648
Swap:        102396           0      102396

So I would say there is no memory impact.

Please enable:

CONFIG_SQUASHFS_LZ4=y
CONFIG_CRYPTO_LZ4HC=m

Thanks!

Hi @pelwell,

Is there anything I can do to help get this changed?

Thanks!

@jayslovak, Thx
English is not easy for me.

@popcornmix @pelwell Any further thoughts?

Volumio2 is a good and popular system that uses SQUASHFS.

Hi @popcornmix @pelwell

Could we get some feedback from you guys?

Thanks

@pelwell @popcornmix Any thoughts? Or have we already done this?

These are not currently set on the 4.19 kernel, so presumably we are not inclined to set them.

This issue will be closed within 30 days unless further interactions are posted. If you wish this issue to remain open, please add a comment. A closed issue may be reopened if requested.

Closing due to lack of activity. Please request to be reopened if you feel this issue is still relevant.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mi-hol picture mi-hol  路  8Comments

awlx picture awlx  路  4Comments

thomasklingbeil picture thomasklingbeil  路  4Comments

steros76 picture steros76  路  3Comments

XECDesign picture XECDesign  路  6Comments