Presentation is loading. Please wait.

Presentation is loading. Please wait.

Michael Opdenacker Linux Tiny Linux-Tiny - The diet must go on Michael Opdenacker Free Electrons

Similar presentations


Presentation on theme: "Michael Opdenacker Linux Tiny Linux-Tiny - The diet must go on Michael Opdenacker Free Electrons"— Presentation transcript:

1 Michael Opdenacker Linux Tiny Linux-Tiny - The diet must go on Michael Opdenacker Free Electrons http://free-electrons.com

2 Michael Opdenacker Who I am Michael Opdenacker ● The founder of Free Electrons, a company supporting organizations and individuals using FOSS in embedded systems. ● Author of free embedded Linux training materials(1500 + pages): http://free-electrons.com/training/. http://free-electrons.com/training/ ● Interested in CELF projects, in particular size and boot time issues. ● The new maintainer of Linux Tiny.

3 Michael Opdenacker Linux kernel size evolution Size of the Linux kernel from 2.6.12 to 2.6.23 ● Tested on a minimalist PC emulated by Qemu. ● Kernels only configured with the below features: – Support for ELF binaries – IDE disk support – ext2 file system ● Each of these kernels boots successfully!

4 Michael Opdenacker Right to copy Attribution – ShareAlike 2.5 You are free to copy, distribute, display, and perform the work to make derivative works to make commercial use of the work Under the following conditions Attribution. You must give the original author credit. Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. For any reuse or distribution, you must make clear to others the license terms of this work. Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above. License text: http://creativecommons.org/licenses/by-sa/2.5/legalcodehttp://creativecommons.org/licenses/by-sa/2.5/legalcode © Copyright 2007 Free Electrons feedback@free-electrons.com Document sources, updates and translations: http://free- electrons.com/articles/linux-tinyhttp://free- electrons.com/articles/linux-tiny Corrections, suggestions, contributions and translations are welcome!

5 Michael Opdenacker Expansion of our universe

6 Michael Opdenacker Why does it grow? ● Because the Universe grows ● More features ● Support for more use cases ● Support for legacy situations ● Because it's easier to add than remove code. ● Because there are not enough reviewers for kernel code.

7 Michael Opdenacker Need for a smaller Linux kernel ● Booting on a floppy disk ;-) Any Windows Vista boot floppies BTW? ● Embedded systems: Linux can run on systems with very little RAM and storage. Every KB counts if it can make Linux fit. ● Because we don't want to force people to use older, smaller kernels. ● To reduce complexity, useful for debugging. ● To reduce compile time.

8 Michael Opdenacker The Linux Tiny project ● First started by Linus Torvalds in 1996, when he accidentally ran: rm -rf linux-src (a bit too small) ● Continued by Matt Mackall in December, 2003. Many patches merged in mainstream. ● Stalled in late 2005 (Linux 2.6.14) ● Revived in 2007 by Tim Bird: upgraded remaining patches patches from 2.6.15 to 2.6.22.

9 Michael Opdenacker Project staff ● Tim Bird (Sony) ● John Cooper (WindRiver) ● Michael Opdenacker (Free Electrons) ● Matt Mackall (Selenic.com) ● The LKML: Deterring people from merging code ;-) ● You! Contributors are most welcome.

10 Michael Opdenacker Linux Tiny's goals (1) Improve the mainstream Linux kernel ● Hunt for bloat, or at least resist it. ● Offer tools to find bloat ● Reduce the kernel's memory consumption.

11 Michael Opdenacker Linux Tiny's goals (2) Remove features not needed in a production or dedicated systems ● Productions systems: no need for core dumps, debugging, console (printk). ● Dedicated systems: just need to support a fix set of programs doing very specific things. Generic systems (PCs, PDAs, smart phones) have to be ready to support any new program or libraries. apt-get install gdb !?

12 Michael Opdenacker Where we are today A configuration the Linux kernel is comfortable with: ● 4 MB of RAM ● 1.5 MB of storage, including the compressed kernel (< 1 MB) Of course, depends on userspace complexity. A configuration we would like to support: ● 2 MB of RAM ● A compressed kernel as small as 300 KB for simple configurations.

13 Michael Opdenacker Linux Tiny Reducing the size of a standard kernel

14 Michael Opdenacker The most powerful tool make allnoconfig ● Selects only but the minimum features. ● Then, add only the features you need. ● Dramatically reduces compile time.

15 Michael Opdenacker Using Embedded options Screen capture from 2.6.23.

16 Michael Opdenacker Disabling debugging messages One for the biggest space savers ● Removing support for printk() and BUG(): Kernel debugging too late in production systems ;-) ● Raw size reduction: -83 KB in our simple Qemu testcase (2.6.23) ● The bigger your kernel, the greater space savings are.

17 Michael Opdenacker The SLOB memory allocator ● Created by Matt Mackall ● A replacement for the SLAB memory allocator which is more space efficient, but doesn't scale well. Can be used in small embedded systems when saving a few hundred KB matters. ● Available in the standard kernel. ● Need to see how it compares to SLUB, the new allocator.

18 Michael Opdenacker Linux 2.6.23 figures Still for our Qemu system ● With the default kernel: Raw: 1385 KB, compressed: 583 KB ● With mainstream Linux Tiny switches (including SLOB): Raw: 1155 KB, compressed: 470 KB ● With all Linux Tiny switches, including those not in mainstream yet: Raw: 1106 KB, compressed: 454 KB We can do much better: the compressed kernel size was 320 KB in 2.6.14.

19 Michael Opdenacker Measuring size ● Use the below command: nm --size vmlinux ● Use the scripts/bloat-o-meter script in the kernel to compare 2 kernel versions See http://elinux.org/Kernel_Size_Tuning_Guidehttp://elinux.org/Kernel_Size_Tuning_Guide

20 Michael Opdenacker Current status http://elinux.org/Linux_Tiny_Patch_Details ● Lots of patches still need mainlining! Current number of patches: approx. 40. ● Otherwise, bitrot will quickly make them obsolete again.

21 Michael Opdenacker Linux Tiny Ongoing projects, ideas and future work

22 Michael Opdenacker Measuring size reduction Linux Tiny Test Project ● http://elinux.org/Linux_Tiny_Test_Project http://elinux.org/Linux_Tiny_Test_Project ● Automatically identify the Linux Tiny patches which bring best footprint savings ● Doesn't measure memory consumption savings.

23 Michael Opdenacker Measure the impact of kernel options ● Ongoing work by John Cooper to automate the size impact of each option of the Linux kernel. More details soon on the project page.

24 Michael Opdenacker Finding unconditional code find drivers -name Makefile -exec grep -H "obj-y" {} ';' ● Look for suspicious stuff. Findings: ● arch/i386/kernel/Makefile: (-254 B) #obj-y += pcspeaker.o ● arch/i386/kernel/cpu/Makefile: (-16.5 KB) #obj-y += amd.o #obj-y += cyrix.o #obj-y += centaur.o #obj-y += transmeta.o obj-y += intel.o intel_cacheinfo.o addon_cpuid_features.o #obj-y += nexgen.o #obj-y += umc.o

25 Michael Opdenacker More findings mm/Makefile: obj-y := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \ page_alloc.o page-writeback.o pdflush.o \ readahead.o swap.o truncate.o vmscan.o \ prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \ $(mmu-y) ● pdflush, readahead, swap : not needed when no storage is available (when you use only an initramfs: a root file system embedded in the kernel image) ● pdflush: not needed when you have only read-only partitions: squashfs, cramfs, read-only mounts.

26 Michael Opdenacker Looking for complexity? ● How to find complex functions? Static C checkers to detect functions exceeding a given length? -> Opportunity to propose simpler implementations. ● Compressing source code and see which source files are best compressed. -> Opportunity to factor redundant information.

27 Michael Opdenacker More ideas ● Compile all files at once (David Woodhouse) ● proc filesystem with a reduced fileset. Otherwise, it consumes 130 KB. ● Migration of debugging interfaces to debugfs ● do-printk patch (Tim Bird) Enable printk debugging only on specific files ● Compile only printk messages above a specified severity (Rob Landley)

28 Michael Opdenacker Things to do To list just a few: ● Propose existing patches to the LKML for merging. Only maintain the ones which stand a change to be merged. ● Offer qemu images to test tiny kernels: i386, arm, ppc, mips, sparc, m68k ● Compare SLOB vs. SLUB. ● Improve Tiny kernel testing

29 Michael Opdenacker Reasons for contributing ● To help us build a smaller and simpler kernel ● Opportunities to discover and explore many parts of the kernel. ● Interesting to read other people's code and discuss improvements with experienced kernel developers. ● Much easier than investing in expertise in very specific kernel topics.

30 Michael Opdenacker Quotation One of my most productive days was throwing away 1,000 lines of code. -- Ken Thompson

31 Michael Opdenacker How to contribute ● When you make a patch or send a suggestion, it's best to copy both the Linux Tiny and Linux Kernel mailing lists. ● We are interested in ideas, experiments, benchmarks... ● Write your ideas on http://elinux.org/Linux_Tiny_Patch_Ideas http://elinux.org/Linux_Tiny_Patch_Ideas Even tiny contributions are welcome ;-)

32 Michael Opdenacker References ● Home page: http://elinux.org/Linux_Tiny http://elinux.org/Linux_Tiny ● Mailing list: http://selenic.com/mailman/listinfo/linux-tiny http://selenic.com/mailman/listinfo/linux-tiny ● Other techniques to reduce system size (in userspace too): http://free-electrons.com/articles/optimizations/ http://free-electrons.com/articles/optimizations/ ● Small system demos: http://free-electrons.com/community/demos/ http://free-electrons.com/community/demos/


Download ppt "Michael Opdenacker Linux Tiny Linux-Tiny - The diet must go on Michael Opdenacker Free Electrons"

Similar presentations


Ads by Google