LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-05-2016, 01:25 AM   #1
jegadezz
LQ Newbie
 
Registered: Oct 2015
Location: Bangalore,India
Distribution: Fedora,Ubuntu
Posts: 27

Rep: Reputation: Disabled
Need some help to use LZ4 algoritm to compress and decompress a kernel


Hello All,

Now I am using the LZO algorithm to compress and decompress a Vmlinux kernel. Now I have a plan to use LZ4.

I have done the all following changes available in internet to add lz4 feature, Because Im using 3.8 kernel version and this LZ4 feature available from 3.12 only,

arch/arm/Kconfig | 1 +
arch/arm/boot/compressed/.gitignore | 1 +
arch/arm/boot/compressed/Makefile | 3 +-
arch/arm/boot/compressed/decompress.c | 4 +
arch/arm/boot/compressed/piggy.lz4.S | 6 +
arch/x86/Kconfig | 1 +
arch/x86/boot/compressed/Makefile | 5 +-
arch/x86/boot/compressed/misc.c | 4 +
include/linux/decompress/unlz4.h | 10 ++
include/linux/lz4.h | 62 +++++++++++
init/Kconfig | 13 ++-
lib/Kconfig | 7 ++
lib/Makefile | 2 +
lib/decompress.c | 5 +
lib/decompress_unlz4.c | 199 ++++++++++++++++++++++++++++++++++
lib/lz4/Makefile | 1 +
lib/lz4/lz4_decompress.c | 199 ++++++++++++++++++++++++++++++++++
lib/lz4/lz4defs.h | 129 ++++++++++++++++++++++
scripts/Makefile.lib | 5 +
usr/Kconfig | 9 ++

The following changes in kernel defconfig,

CONFIG_RD_LZ4=y
CONFIG_HAVE_KERNEL_LZ4=y
CONFIG_KERNEL_LZ4=y
CONFIG_LZ4_COMPRESS=y
CONFIG_LZ4_DECOMPRESS=y
CONFIG_DECOMPRESS_LZ4=y

After compiling the rpm I have checked the .config which is present in inside /root/build/kernel.x.x/linux.x.x folder,

All the changes are reflected in .config file except CONFIG_LZ4_COMPRESS and CONFIG_LZ4_DECOMPRESS. Still it shows CONFIG_LZO_COMPRESS=y and CONFIG_LZO_DECOMPRESS=y. I just want to understand even though I am giving compression and decompression parameter with LZ4 bt still .config using LZO.

After installing the kernel on the target, I have checked /proc/kallsyms and the output looks for decompressing a VMlinux using LZO only.

Any comments or suggestions are highly appreciated.
 
Old 08-05-2016, 06:54 PM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,412

Rep: Reputation: 610Reputation: 610Reputation: 610Reputation: 610Reputation: 610Reputation: 610
if the version of your kernel doesnt support a feature, it doesn't matter what you put in the config it will just get ignored/overitten/kicked out etc, setting an option in the config file wont suddenly make the code understand new features.
 
Old 08-08-2016, 02:27 AM   #3
jegadezz
LQ Newbie
 
Registered: Oct 2015
Location: Bangalore,India
Distribution: Fedora,Ubuntu
Posts: 27

Original Poster
Rep: Reputation: Disabled
Hi Hedger,

We can enable the LZ4 algorithm to compress and decompress a vmlinux by applying a few patches and some config changes. And Finally I able to use LZ4 for compress and decompress a vmlinux.

After added the lz4 seems the boot time is improved. I found one command to get the decompress details from the system.

cat /proc/kallsyms |grep lz4

c114bc34 t _lzo1x_1_do_compress
c114bf73 T lzo1x_1_compress
c114c030 T lzo1x_decompress_safe
c114c538 T lz4_decompress_unknownoutputsize
c114c6fb T lz4_decompress
c1209f98 t regcache_lzo_sync
c120a03c t regcache_lzo_exit
c120a09c t regcache_lzo_decompress_cache_block.clone.4
c120a0f9 t regcache_lzo_read
c120a19b t regcache_lzo_compress_cache_block.clone.5
c120a201 t regcache_lzo_write
c120a313 t regcache_lzo_init
c14fb2d9 T unlz4

Now I'm seeing both LZO and LZ4 from output. How to debug which algorithm will be used for decompress a static kernel.

Thanks in Advance,
Jegathesan
 
Old 08-08-2016, 03:13 AM   #4
zk1234
4MLinux Maintainer
 
Registered: Oct 2010
Location: Poland
Distribution: 4MLinux, Slackware
Posts: 639

Rep: Reputation: 131Reputation: 131
Assuming that your patch works...

Open the .config file. Set ALL compression algorithms to "is not set", for example:
Code:
# CONFIG_KERNEL_GZIP is not set
# CONFIG_KERNEL_BZIP2 is not set
# CONFIG_KERNEL_LZMA is not set
# CONFIG_KERNEL_XZ is not set
# CONFIG_KERNEL_LZO is not set
# CONFIG_KERNEL_LZ4 is not set
Save changes. Now execute:
Code:
make oldconfig
The configuration script will now start with asking you what compression method you want to use (as the default one).
.

Last edited by zk1234; 08-08-2016 at 11:44 AM.
 
Old 08-08-2016, 03:48 AM   #5
jegadezz
LQ Newbie
 
Registered: Oct 2015
Location: Bangalore,India
Distribution: Fedora,Ubuntu
Posts: 27

Original Poster
Rep: Reputation: Disabled
Hi zk1234,

This is the .config file content related compression algorithm by default,

# CONFIG_KERNEL_GZIP is not set
# CONFIG_KERNEL_BZIP2 is not set
# CONFIG_KERNEL_LZMA is not set
# CONFIG_KERNEL_XZ is not set
# CONFIG_KERNEL_LZO is not set
CONFIG_KERNEL_LZ4=y

So I already modified and compiling a kernel with this changes.

Last edited by jegadezz; 08-08-2016 at 03:53 AM.
 
Old 08-08-2016, 09:25 AM   #6
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,412

Rep: Reputation: 610Reputation: 610Reputation: 610Reputation: 610Reputation: 610Reputation: 610
If you are going to patch the kernel anyway why not just use an upto date one that has the options you want? Seems a bit like re-inventing the wheel to me, or is there some specific reason to use the older kernel.
 
Old 08-15-2016, 08:14 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,445
Blog Entries: 4

Rep: Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897
Also, I would candidly suggest that a change to the (de-)compression algorithm would change boot-time, "at best, only slightly." The things that slow down system initialization usually occur well after the resident-kernel itself has been decompressed and loaded into memory.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bug in Kernel's LZ4-HC in 64bit kirankankipati Linux - Networking 9 06-29-2014 10:06 AM
[SOLVED] How do I edit the initrd.img (decompress & compress) yanfaun Linux - Software 18 10-19-2010 08:49 PM
LXer: Basic commands Les I: Compress and decompress files using rar, bzip, tarball(t LXer Syndicated Linux News 0 07-10-2009 04:10 PM
Slow Kernel Decompress chasingmytail Linux - Laptop and Netbook 4 07-16-2004 09:22 AM
Slow Kernel Decompress chasingmytail Slackware 9 07-15-2004 09:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 11:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration