howtobootlinuxinonesecond - elinux.org · lpj= measuringpoint time bootstrap-kernel 676ms...

71
How to boot Linux in one second …why userland is a waste of time ;) Jan Altenberg Linutronix GmbH Jan Altenberg Linutronix GmbH 1

Upload: hakhanh

Post on 16-Aug-2019

228 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

How to boot Linux in one second…why userland is a waste of time ;)

Jan Altenberg

Linutronix GmbH

Jan Altenberg Linutronix GmbH 1

Page 2: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

from zero…

Jan Altenberg Linutronix GmbH 2

Page 3: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

to hero…

Jan Altenberg Linutronix GmbH 3

Page 4: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Overview

..1 BasicsMotivationSome technical basics

..2 OptimizationsBootloaderKernelFilesystemApplication

..3 ExampleOptimizing an ARMv5 based deviceOptimizing the test system

Jan Altenberg Linutronix GmbH 4

Page 5: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Motivation

..1 BasicsMotivationSome technical basics

..2 OptimizationsBootloaderKernelFilesystemApplication

..3 ExampleOptimizing an ARMv5 based deviceOptimizing the test system

Jan Altenberg Linutronix GmbH 5

Page 6: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Motivation

Motivation

''marketing''automotive applicationsenergy saving

• solution: power-off instead of suspending• BUT: Users are not used to wait

Jan Altenberg Linutronix GmbH 6

Page 7: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Motivation

Motivation

''marketing''automotive applicationsenergy saving

• solution: power-off instead of suspending

• BUT: Users are not used to wait

Jan Altenberg Linutronix GmbH 6

Page 8: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Motivation

Motivation

''marketing''automotive applicationsenergy saving

• solution: power-off instead of suspending• BUT: Users are not used to wait

Jan Altenberg Linutronix GmbH 6

Page 9: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Some technical basics

..1 BasicsMotivationSome technical basics

..2 OptimizationsBootloaderKernelFilesystemApplication

..3 ExampleOptimizing an ARMv5 based deviceOptimizing the test system

Jan Altenberg Linutronix GmbH 7

Page 10: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Some technical basics

First step: Define your requirements!!!!

What's the limit for the boot time?Which functionality should be available?Speed vs. flexibility

NOTE: FastBOOT is not a product, it's a concept!!

Jan Altenberg Linutronix GmbH 8

Page 11: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Some technical basics

Boot process

Jan Altenberg Linutronix GmbH 9

Page 12: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Some technical basics

Components of the boot process

Hardware resetBootloaderOperating System (drivers, filesystem, …))INIT process, application (userland)

Jan Altenberg Linutronix GmbH 10

Page 13: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Some technical basics

Critical hardware components

Power supplyReset logicBoot logic / boot orderBoot mediaPeripherals which need to be accessed while booting

IMPORTANT: the hardware is a central part of a fastboot concept!!!

Jan Altenberg Linutronix GmbH 11

Page 14: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Some technical basics

Bootloader

Basic setup of the CPUPreparing and handing over ATAGS / devicetreeFlushing the cachesSwitch off the MMU

Jan Altenberg Linutronix GmbH 12

Page 15: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Some technical basics

The Linux Kernel

A lot of functions for boot time optimizationVery flexibleConfigurable compression typeCan deffer or parallelize initializations150ms - 250ms from starting the kernel to mounting the RFS

Jan Altenberg Linutronix GmbH 13

Page 16: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Some technical basics

The application

Usually the biggest target for optimizationsStart scripts / INIT processLinking

Jan Altenberg Linutronix GmbH 14

Page 17: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Bootloader

..1 BasicsMotivationSome technical basics

..2 OptimizationsBootloaderKernelFilesystemApplication

..3 ExampleOptimizing an ARMv5 based deviceOptimizing the test system

Jan Altenberg Linutronix GmbH 15

Page 18: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Bootloader

Optimizing the bootloader (U-Boot) 1

Remove unused features:/* inc lude / conf igs /boardname . h */[ . . . ]# inc lude <config_cmd_default . h>#undef CONFIG_CMD_NET[ . . . ]

Jan Altenberg Linutronix GmbH 16

Page 19: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Bootloader

Optimizing the bootloader (U-Boot) 2

Verifying the kernel image:

setenv verify n

Switch off the bootloader console:

setenv silent 1

Switch off the boot delay:

setenv bootdelay 0

Jan Altenberg Linutronix GmbH 17

Page 20: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Bootloader

Optimizing the bootloader: IPL / SPL

Replacing the general purpose bootloader by an optimized IPL…also useful for update conceptsU-Boot offers a generic way: The U-Boot SPL(CONFIG_SPL_OS_BOOT)

Jan Altenberg Linutronix GmbH 18

Page 21: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Kernel

..1 BasicsMotivationSome technical basics

..2 OptimizationsBootloaderKernelFilesystemApplication

..3 ExampleOptimizing an ARMv5 based deviceOptimizing the test system

Jan Altenberg Linutronix GmbH 19

Page 22: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Kernel

Optimizing the kernel

Configuration and buildCompression methodBoot parameters (kernel commandline)Driver init callsRootfilesystem (RFS)

Jan Altenberg Linutronix GmbH 20

Page 23: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Kernel

Optimizing the kernel: Configuration

General setup --->Kernel compression mode -->

LZO usually a good choice for embedded systemCopy vs. de-compress''Execute in Place (XIP)'

Jan Altenberg Linutronix GmbH 21

Page 24: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Kernel

Optimizing the kernel: Kernel commandline

Delay Loop Calibration: ''lpj=''; can save > 100ms on ARMv5 basedsystemsParameters for boot time analysis: ''initcall_debug'',''printk_time=1''

Jan Altenberg Linutronix GmbH 22

Page 25: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Kernel

Optimizing the kernel: printk.time

...[0.000000] VIC @f1140000: id 0x00041190,

vendor 0x41[0.000000] FPGA IRQ chip 0 "SIC" @ f1003000,

21 irqs[0.000000] Console: colour dummy device 80x30[0.018847] Calibrating delay loop...

626.68 BogoMIPS (lpj=3133440)[0.316717] pid_max: default: 32768 minimum: 301[0.317552] Mount-cache hash table entries: 512...

Jan Altenberg Linutronix GmbH 23

Page 26: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Kernel

Optimizing the kernel: Delay Loop

...[0.018847] Calibrating delay loop...

626.68 BogoMIPS (lpj=3133440)[0.316717] pid_max: default: 32768 minimum: 301...

Jan Altenberg Linutronix GmbH 24

Page 27: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Kernel

Optimizing the kernel: initcall_debug

[0.452115] calling exceptions_init+0x0/0x90 @ 1[0.452172] initcall exceptions_init+0x0/0x90

returned 0 after 0 usecs[0.452203] calling versatile_i2c_init+0x0/0x24 @ 1[0.452321] initcall versatile_i2c_init+0x0/0x24

returned 0 after 0 usecs[0.452352] calling pl011_init+0x0/0x54 @ 1[0.452382] Serial: AMBA PL011 UART driver[0.453647] dev:f1: ttyAMA0 at MMIO 0x101f1000

(irq = 12) is a PL011 rev1[0.481540] console [ttyAMA0] enabled...[0.484427] initcall pl011_init+0x0/0x54

returned 0 after 29296 usecs

Jan Altenberg Linutronix GmbH 25

Page 28: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Kernel

bootgraph.pl

..1 Boot your systemwith ''initcall_debug loglevel=8

..2 On the target:$ dmesg > bootlog.txt

..3 On the host:$ cd linux-XXX$ cat /path_to_rfs/bootlog.txt | \

perl scripts/bootgraph.pl > bootlog.svg

Jan Altenberg Linutronix GmbH 26

Page 29: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Kernel

scripts/bootchart.pl

Jan Altenberg Linutronix GmbH 27

Page 30: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Filesystem

..1 BasicsMotivationSome technical basics

..2 OptimizationsBootloaderKernelFilesystemApplication

..3 ExampleOptimizing an ARMv5 based deviceOptimizing the test system

Jan Altenberg Linutronix GmbH 28

Page 31: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Filesystem

UbiFS

The best choice for flash devicesPower-Fail safeThe underlying UBI layer can be optimized with (FastMAP)…

Jan Altenberg Linutronix GmbH 29

Page 32: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Filesystem

InitRAMFS

dir /dev 755 0 0nod /dev/console 644 0 0 c 5 1nod /dev/loop0 644 0 0 b 7 0dir /bin 755 1000 1000slink /bin/sh busybox 777 0 0file /bin/busybox initfs/busybox 755 0 0[...]dir /proc 755 0 0dir /sys 755 0 0dir /mnt 755 0 0

Jan Altenberg Linutronix GmbH 30

Page 33: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Filesystem

InitRAMFS: Switch root

The INIT process for the InitRAMFS can be configured with rdinit=. Forexample: rdinit=/etc/init.d/start.sh

Jan Altenberg Linutronix GmbH 31

Page 34: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Filesystem

InitRAMFS: Switch root

/etc/init.d/start.sh:

#!/bin/shmount -t proc proc /procmount -t sysfs sysfs /sysmount -t devtmpfs devtmpfs /dev# Mount RFS / do some critical stuffmount /dev/mmcblk0p1 /mediafbsplash -s /media/splash.ppm -d /dev/fb0mount -o move /proc /media/procmount -o move /sys /media/sysmount -o move /dev /media/dev# Switch to production systemexec switch_root /media /linuxrc

Jan Altenberg Linutronix GmbH 32

Page 35: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Application

..1 BasicsMotivationSome technical basics

..2 OptimizationsBootloaderKernelFilesystemApplication

..3 ExampleOptimizing an ARMv5 based deviceOptimizing the test system

Jan Altenberg Linutronix GmbH 33

Page 36: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Application

The INIT process

SystemVSystemD

One letter makes a BIG difference ;-)

Jan Altenberg Linutronix GmbH 34

Page 37: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Application

Optimizing the application

Analyse the INIT process with bootchartd or systemd-analyzeReplace the INIT process with your own application (init=)LinkingPre-Linking and function reordering

Jan Altenberg Linutronix GmbH 35

Page 38: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Application

Moving start script tasks into your application

ret = mount("sysfs", "/sys","sysfs", 0, NULL);

if(ret < 0)perror("Can't mount sysfs\n");

Jan Altenberg Linutronix GmbH 36

Page 39: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Application

Dynamic linking

..1 ELF DT_RPATH section

..2 LD_LIBRARY_PATH

..3 ELF DT_RUNPATH section

..4 Binary file /etc/ld.so.cache

..5 Default paths /lib und /usr/lib

Jan Altenberg Linutronix GmbH 37

Page 40: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Application

Dynamic linking: Debug and visualize

$ LD_DEBUG=libs ls3082: find library=librt.so.1 [0];

searching3082: search cache=/etc/ld.so.cache3082: trying file=/lib/librt.so.1

Jan Altenberg Linutronix GmbH 38

Page 41: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing an ARMv5 based device

..1 BasicsMotivationSome technical basics

..2 OptimizationsBootloaderKernelFilesystemApplication

..3 ExampleOptimizing an ARMv5 based deviceOptimizing the test system

Jan Altenberg Linutronix GmbH 39

Page 42: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing an ARMv5 based device

Test system

ARM9 CPU (Atmel AT91 series)Starting point: Busybox based image (Angstrom Distribution)Boot media: NAND-FlashTest application: Toggling a GPIO via SysFS

Jan Altenberg Linutronix GmbH 40

Page 43: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing an ARMv5 based device

Boot strategy of the AT91 controller family

Jan Altenberg Linutronix GmbH 41

Page 44: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing an ARMv5 based device

Bootmodes of the AT91 controller family

RomBOOT: internal boot logicExternal bus interface (CS0, e.g. NOR flash)

Jan Altenberg Linutronix GmbH 42

Page 45: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing an ARMv5 based device

AT91 RomBOOT

Jan Altenberg Linutronix GmbH 43

Page 46: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing an ARMv5 based device

Power supply

Jan Altenberg Linutronix GmbH 44

Page 47: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing an ARMv5 based device

Reset logic

Jan Altenberg Linutronix GmbH 45

Page 48: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing an ARMv5 based device

RomBOOT

Jan Altenberg Linutronix GmbH 46

Page 49: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing an ARMv5 based device

Possible hardware optimizations

Using the internal oscillator for deriving the slowclock saves > 1s!!booting from CS0 will save 100 - 150ms

Jan Altenberg Linutronix GmbH 47

Page 50: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

..1 BasicsMotivationSome technical basics

..2 OptimizationsBootloaderKernelFilesystemApplication

..3 ExampleOptimizing an ARMv5 based deviceOptimizing the test system

Jan Altenberg Linutronix GmbH 48

Page 51: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Boot timemeasurements with a GPIO

Jan Altenberg Linutronix GmbH 49

Page 52: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Measuring points

Bootstrap - U-BootU-Boot - Early-Boot-Code of the kernel (incl. relocation anddecompression)Kernel - application (incl. mounting the RFS)

Jan Altenberg Linutronix GmbH 50

Page 53: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Initial boot time

Jan Altenberg Linutronix GmbH 51

Page 54: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Initial boot time

measuring point timebootstrap - u-boot ---u-boot - kernel 6,5s

kernel - application 4,5stotal 11s

Jan Altenberg Linutronix GmbH 52

Page 55: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Simple optimizations

Jan Altenberg Linutronix GmbH 53

Page 56: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

U-Boot w/o networking support

measuring point timebootstrap - u-boot ---u-boot - kernel 4,25s

kernel - application 4,5stotal 8,75s

Jan Altenberg Linutronix GmbH 54

Page 57: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

U-Boot verify=n

measuring point timebootstrap - u-boot ---u-boot - kernel 3,89s

kernel - application 4,5stotal 8,39s

Jan Altenberg Linutronix GmbH 55

Page 58: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Optimizing the kernel config

measuring point timebootstrap - u-boot ---u-boot - kernel 3,77s

kernel - application 4,33stotal 8,1s

Jan Altenberg Linutronix GmbH 56

Page 59: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Analyzing the INIT process: Bootchartd

Jan Altenberg Linutronix GmbH 57

Page 60: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Optimizing the start scripts

measuring point timebootstrap - u-boot ---u-boot - kernel 3,77s

kernel - application 3,61total 7,38s

Jan Altenberg Linutronix GmbH 58

Page 61: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Booting an InitRAMFS

Jan Altenberg Linutronix GmbH 59

Page 62: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

LZO compressed InitRAMFS

The test application is used as an INIT process (rdinit=)

measuring point timebootstrap - u-boot ---u-boot - kernel 3,79s

kernel - application 0,372stotal 4,162s

Jan Altenberg Linutronix GmbH 60

Page 63: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Modified AT91 Bootstrap

Jan Altenberg Linutronix GmbH 61

Page 64: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Modified AT91 Bootstrap

AT91 Bootstrap starts Linux (without U-Boot)

measuring point timebootstrap - kernel 676mskernel - application 584ms

total 1,260s

Jan Altenberg Linutronix GmbH 62

Page 65: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

lpj=

measuring point timebootstrap - kernel 676mskernel - application 384ms

total 1,060s

Jan Altenberg Linutronix GmbH 63

Page 66: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

< 1s !!

Jan Altenberg Linutronix GmbH 64

Page 67: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

No (serial) console output (quiet)

measuring point timebootstrap - kernel 524mskernel - application 212ms

total 736ms

Jan Altenberg Linutronix GmbH 65

Page 68: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

LZO compressed kernel image

measuring point timebootstrap - kernel 444mskernel - application 212ms

total 656ms

Jan Altenberg Linutronix GmbH 66

Page 69: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Final boot behaviour

Jan Altenberg Linutronix GmbH 67

Page 70: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Conclusion

Linux can combine the advantages of a modern OS with hard boottime requirementsSaving boot time with simple optimizationsThe hardware is an IMPORTANT part of a FastBOOT conceptThe boot concept is architecture independent!

Jan Altenberg Linutronix GmbH 68

Page 71: HowtobootLinuxinonesecond - eLinux.org · lpj= measuringpoint time bootstrap-kernel 676ms kernel-application 384ms total 1,060s JanAltenberg LinutronixGmbH 63. Optimizingthetestsystem

Optimizing the test system

Questions?

I'll also be around at the technical showcase! :)

Jan Altenberg Linutronix GmbH 69