blob: 87639391f5bc70b7c33b862d0e44f4216f7caf81 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
This is a general procedure for improving Linux boot times. It only deals
with Linux drivers and userspace.
NOTE: Everything before Linux (hardware, bootloader) have very important
roles also. They also must be considered for a complete fast boot
concept.
1. Add "poweroff -f" to the beginning of the boot script /etc/init.d/rcS
- this allows us to measure time with "time ./start-vm.sh"
2. Do not enable audio in qemu: QEMU_AUDIO_DRV=none
- this reduces qemu startup time (we want to measure Linux, not qemu)
3. Switch from NFS-Root to initramfs.
- this avoids ethernet setup and DHCP at boot
- this avoids network latencies during filesystem interaction
- initramfs uses /init as default start program, so we add a soft link
from /init to bin/busybox in the root filesystem
- removed "ip=dhcp root=... nfsroot=..." from kernel arguments
4. Strip all libraries and binaries.
- this makes the initramfs *much* smaller
- smaller initramfs means faster "populate rootfs" on boot
5. Remove libm dependency from busybox.
- the busybox features using libm are not needed for fast boot requirements
- removing libm means smaller initramfs
- less dependencies means faster busybox start time
6. Add "printk.time=1 loglevel=8" to kernel arguments.
- ./start-vm.sh > boot.log
- browse boot.log to find any errors, unused features, slow non-important
features.
- disable or compile the drivers/features as modules
7. Add "initcall_debug" to kernel arguments.
- now we can see the time consumed by each driver's init function
- if the device is in the device-tree, this time will also include
the device's probe time
- ./start-vm.sh > boot.log
- cat boot.log | linux-4.6/scripts/bootgraph.pl > boot.svg
8. Remove (or change to modules) drivers not needed for fast boot requirements
- search kernel code to find init function
- look at the Makefile in that directory to see the corresponding
kernel config option
- remove amba_clcdfd_init (as example)
- change smsc911x_init to module (as example)
9. Remove initcall_debug, consoles and set loglevel=0.
- we are done evaluating individual driver times
- the console is slow, so don't output anything to it
- maybe even disable the console in the kernel config
10. Pre-configure loops per jiffy calibration.
- ./start-vm.sh | grep lpj=
- add lpj=xyz to kernel parameters
11. Choose optimal kernel compression
- General setup -> Kernel compression mode
- set kernel compression to LZO
12. Create fastpoweroff script to run instead of busybox-init.
- add kernel parameter "rdinit=/bin/fastpoweroff"
- now init is not started (since init did much more than just
run /etc/init.d/rcS)
13. Create binary to run instead of script or busybox-init.
- change kernel parameter to "rdinit=/bin/poweroff"
- (busybox was hacked so "poweroff" automatically uses "-f")
- in #12 first a shell is loaded, then the script is parsed,
then poweroff is called
- now poweroff is directly called by kernel
14. Add ld.so.cache for initramfs libraries.
- the dynamic loader now does not search for dependencies
15. For systemd-based userspace, use systemd tools.
- systemd-analyze blame
- systemd-analyze plot > systemd.svg
- systemd-analyze critcal-chain app-qt
|