LINUXBOOT

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Reducing Boot Time: Techniques for Fast Booting

Chris Hallinan Field Applications Engineer Author: Embedded Linux Primer

Agenda

Introduction and Overview

Hardware Discussion

Software Components

Overview of Boot Sequence

Bootloader Issues Linux Kernel Optimizations Tools pplications!"serland

Introduction

#ast Boot is Important to $an% &roducts

Consumer'

utomotive' $edical Devices' etc(

Si)nificant )ains w( minimal investment #irst' define *+oot,( Does it mean

Splas. screen/ 0st user process started/ Device full% up and runnin)' connected/ Hardware Desi)n Bootloader Implementation Kernel Confi)uration pplication &rofile

Boot time is affected +% man% factors

Typical Boot Sequence


Power Applied Pwr/Clk/Reset Bootloader Kernel Init

Optimization Opportunities

Bootloader

$a% +e multiple sta)es 1emove support for unused features $odif%!remove .ardware pro+in) features Keep it Simple' Small -2 $an% opportunities for optimization Low .an)in) fruit can +e eas% to 3pluc43 $ost are up to %ou5

Kernel

pplications

Root FS Mount

$ost initialization is serial Ta4e measurements to decide w.ere to focus5


4

Userland Apps

2008 MontaVista Software - Confidential

Bootloader Considerations

Bootloader .as two primar% responsi+ilities

Initialize C&"!Hardware 6minimall%2 Locate' load and execute a 4ernel ima)e

$a% involve several steps' includin) device I!O' decompression' etc(

Bootloader Considerations

$ost +ootloaders .ave man% more features


7sp( loo4 for an% t%pe of +us enumeration Lots of useful *development, functionalit%

d.cp' tftp' pci scan' mem utils device initialization' #las. utilities' etc In a production s%stem' man% of t.ese features ma% +e unnecessar% Disa+lin) t.ese features can .ave a si)nificant impact on +oot time

#or fast +oot' )et t.e +ootloader out of t.e wa% quic4l%

1emem+er' small 88 fast

Kernel Image Optimization

"se "ncompressed Kernel


Decompression can ta4e several seconds5 Tradeoff- more #las. stora)e required Ima)e and zIma)e 6 1$2 O+viousl%' zIma)e is t.e compressed version

Kernel +uild produces two ima)es9


On i($:;0' t.is saved on avera)e <=>? mS @$$A' dependin) on C&" speed' #L SH speed(((
9Details var% for eac. arc.itecture' 1$ discussed .ere
2008 MontaVista Software - Confidential 7

Linux Kernel Configuration

7liminate "nnecessar% Kernel Options


1educes 4ernel size Speeds up 4ernel loadin) In some cases' will reduce 4ernel init time once 4ernel is loaded

T%pical default 4ernel confi) contains lots of 3stuff3 6i(e( features2 %ou ma% not need

$D!1aid support' I&vB' Cumerous #ile S%stems' 7xtended &artition support' etc( De+u) features suc. as 4ernel s%m+ols' i4confi)' etc( $an% are compiled in features and increase 4ernel size
8

2008 MontaVista Software - Confidential

Kernel Config Options to Consider Disabling

COC#IDE$D

1 ID!LA$ support
Saves init time if not used on HF w! ID7 ctrlr Can also use .dx8nopro+e

COC#IDEIKCOC#ID

COC#IDEID7

1emoves support for confi) info' ma4es 4ernel smaller

COC#IDED7B"DEK71C7L COC#IDEK LLS@$S COC#IDEB"D

COC#IDE&CC 1D COC#IDEHOT&L"D

"sed for de+u) G can +e removed if desired

1emove support for .otplu) if not required

2008 MontaVista Software - Confidential

More Interesting Kernel Config Options

C.ec4 Cetwor4in) options


Lots of functionalit% G do %ou need it all/ ie( 4ernel autoconf' multicast' advanced router' etc( Default confi)s often .ave muc. of t.is ena+led
COC#IDEDCOTI#@ COC#IDEICOTI#@ COC#IDE:#S COC#IDE "TO#SHE#S 6 utomounter2 etc

1emove support for unnecessar% #S features

1emem+er- Smaller 4ernel 8 #aster load


If in doubt, make small changes. Test early and often so you can rollback breakages easily!

2008 MontaVista Software - Confidential

10

Calibration Routines

$an% .ardware platforms spend considera+le time in cali+ration routines


*Calculatin) Bo)o$ips(((, llows precise Idela%62 routines Can ta4e si)nificant time lpK8xxxxx

"se 4ernel command line- loopsJperJKiff%

7as% to use- most platforms will displa% correct value in 4ernel lo) 6and to console2 on startup
2008 MontaVista Software - Confidential 11

Driver Configuration

Consider %our s%stem requirements

F.at functionalit% must +e availa+le immediatel%/ F.at functionalit% can +e deferred/ F.at drivers are not needed/

$odules 6COC#IDE98$2' if unused' are irrelevant

Fon3t affect 4ernel startup time

2008 MontaVista Software - Confidential

12

Driver Configuration

Drivers can +e preJcompiled into 4ernel or +uilt as modules for loadin) later

"se staticall%Jlin4ed drivers for functions t.at must +e immediatel% availa+le "se Loada+le $odules for deferred functionalit%

Caveat- if %ou can avoid COC#IDE$OD"L7S' 4ernel will +e smaller9' t.us faster to load( T.ere is pro+a+l% also a minor .it to readin) t.e driver from t.e #S instead of it +ein) in t.e 4ernel
*Assumes minimal system, few drivers.
2008 MontaVista Software - Confidential

13

File System Selection

Consider C1 $#S for initial readJonl% #S


Compact and fast Co Kournalin) entries to scan on initial mount

"se tmpfs for !tmp' possi+l% !var' ot.ers $ount writa+le #S later' suc. as L##SM on CO1 #las. Consider %our tolerance to sudden power off

Lournalin) file s%stems can protect +ut at a cost of increased startup times

2008 MontaVista Software - Confidential

14

XIP Execute in Place

&rocessor does not cop% Kernel ima)e to D1 $

7xecutes directl% from 6CO12 #las. 1educes D1 $ requirements 6and t.us power2 7liminates timeJconsumin) cop% from #las. Dependin) on .!w arc.itecture' could +e muc. slower

dvanta)es

Disadvanta)es

i(e( +urst!cac.e performance' etc(

Cost of #las. G 4ernel must +e stored uncompressed

@our $ilea)e $a% Aar%


2008 MontaVista Software - Confidential 15

Remove Support for printk()

T.e *Brute #orce, approac. J COC#IDE&1ICTK

Completel% eliminates calls to print462 Saves si)nificant 4ernel size' and t.erefore load time 7liminates man% +oot messa)es J decreasin) +oot time Co 4ernel status messa)e are availa+le5 $a4es 4ernel de+u))in) ver% difficult

dvanta)es

Disadvanta)e

t.orou).l% tested 4ernel s.ould wor4 well .ere lternativel%' use *quiet, command line parameter

suppresses print4 output durin) +oot' preservin) t.e print4 infrastructure to +e used postJ+oot
2008 MontaVista Software - Confidential 16

Tools

K#T- Kernel #unction Timin)


1equires K LLS@$S' mentioned a+ove &rovides function call tracin) and timin)

Entry Duration Local Pid Trace ---------- ---------- ---------- ------- ----------------------------162 11523 0 0 paging_init 162 11523 0 0 | free_area_init_nodes 162 11523 12 0 | | free_area_init_node 162 11511 11511 0 | | | _etext+0x2f0 162 11511 0 0 __alloc_bootmem_node 162 11511 11511 0 ! __alloc_bootmem_core 11787 2307 2307 0 vfs_caches_init_early 11787 1531 69 0 vfs_caches_init_early 11787 686 0 0 [ alloc_large_system_hash 11787 686 0 0 [ [ __alloc_bootmem 11787 686 0 0 [ [ [ __alloc_bootmem_nopanic 11787 686 686 0 [ [ [ [ __alloc_bootmem_core 13318 776 776 0 [ inode_init_early 14094 1208 641 0 mem_init 14094 567 4 0 # free_all_bootmem 14094 563 563 0 # # free_all_bootmem_core 15607 3851 3851 0 schedule 15607 3848 3848 0 schedule 15630 1573099 1573099 1 kernel_init 15666 81152 81152 4 schedule 15666 81139 81139 4 schedule

2008 MontaVista Software - Confidential

17

Tools

Linux Trace Tool4it

2008 MontaVista Software - Confidential

18

Tools

print4 timestamps 6COC#IDE&1ICTKETI$72


ppends time info to print462 output 7na+les measurement of lon) operations' esp( at +oot time

[ [ [ [ [ [ [ [ [ [ [ [ [ [

1.321054] 1.326629] 1.331964] 1.342289] 1.345936] 1.350403] 1.355816] 1.360571] 1.366034] 2.880506] 2.883575] 2.892227] 2.897798] 2.906152]

md: linear personality registered for level -1 md: raid0 personality registered for level 0 md: raid1 personality registered for level 1 TCP cubic registered NET: Registered protocol family 1 NET: Registered protocol family 17 RPC: Registered udp transport module. RPC: Registered tcp transport module. drivers/rtc/hctosys.c: unable to open rtc device (rtc0) IP-Config: Complete: device=eth0, addr=192.168.1.201, mask=255.255.255.0, gw=255... host=8349itx, domain=, nis-domain=(none), bootserver=192.168.1.9, rootserver=192.168.1.9, rootpath= md: Autodetecting RAID arrays.

2008 MontaVista Software - Confidential

19

Tools

initcallEde+u)

Dreat wa% to )et a coarse view of s%stem init timin)


4 msecs: initcall c02c7da0 t linear_init 5 msecs: initcall c02c6bbc t init_sd 6 msecs: initcall c02c7d78 t mpc83xx_wdt_init 7 msecs: initcall c02cc450 t init_sunrpc 10 msecs: initcall c02c01a8 t slab_sysfs_init 15 msecs: initcall c02c8d50 t genl_init 24 msecs: initcall c02c55c4 t serial8250_init 30 msecs: initcall c02c6364 t gfar_init 34 msecs: initcall c02c743c t physmap_init 72 msecs: initcall c02c9c60 t inet_init 127 msecs: initcall c02c4e4c t pty_init 4597 msecs: initcall c02cabe0 t ip_auto_config

2008 MontaVista Software - Confidential

20

An example of boot time reduction

i($:;0 1eference +oard Initial confi)uration

?-;B power on to command prompt 1ed+oot +ootloader ta4es 0? seconds Cetwor4in)' static I& Bus%+ox userland $an% 4ernel optimizations M(= Seconds J Kernel start to s.ell prompt $inimal en)ineerin) investment
21

#inal Confi)uration

2008 MontaVista Software - Confidential

Applications/Userland

Startup scripts

void &erl!&%t.on dependencies 6will reduce #S size as well2 One custom startup script instead of usin) S%sA Init and !etc!init(d

Cac.es 6+i) impact if %ou .ave a +i) userland2

Li+rar% Cac.e setup ICOC #ont

&relin4 li+raries "se tools to profile execution

strace and ltrace can +e useful .ere


2008 MontaVista Software - Confidential 22

Additional Ideas and Resources

&arallelize t.e init tas4s


*+oot, ever%t.in) at once drivers and tas4s can do t.eir several seconds of waitin) at t.e same time Splas. screens' etc )ive impression t.at unit is +ooted w.ile initialization continues Dets +ac4 to definin) w.at *+ooted, means(((

&rovide user feed+ac4 earl%


2008 MontaVista Software - Confidential

23

Additional Ideas and Resources

Save a canned memor% and s%stem state to nonJvolatile stora)e

so t.at +ootin) can occur as fast as t.e memor% ima)e can +e read from dis4 6.i+ernation2( 1equires si)nificant stora)e

Suspend!1esume G man% consumer devices almost never cold +oot(

e()( man% *Smart &.ones, onl% cold +oot if %ou remove N replace +atter%

2008 MontaVista Software - Confidential

24

Additional Ideas and Resources

Oprofile G S%stemwide Stat( &rofilin) for Linux


On one proKect' t.is .elped ID #las. as a +ottlenec4 #ocused on acceleratin) #las. I!O reduced +oot time <M>O

.ttp-!!elinux(or)!BootETime Tim Bird3s OLS M??H presentation


$et.ods to Improve Bootup Time in Linux .ttp-!!4ernel(or)!doc!ols!M??H!olsM??Hv0Jpa)esJ=PJQQ(pdf

rKan van de Aen' Linux &lum+ers Conference Bootin) Linux in > Seconds 6xQB!Des4top focused2 6Sept 0Q' M??Q2

.ttp-!!lwn(net! rticles!MPPHQ;!

$eld 6next slide2

2008 MontaVista Software - Confidential

25

A Meld discussion on Linux startup...

2008 MontaVista Software - Confidential

26

Thank you!

Chris Hallinan, Field Apps Engineer MontaVista Software, Inc. challinan@mvista.com

You might also like