SlideShare une entreprise Scribd logo
1  sur  109
Télécharger pour lire hors ligne
Shorten Device Boot Time for
Automotive IVI and Navigation Systems
Jim Huang ( 黃敬群 ) <jserv@0xlab.org>
Dr. Shi-wu Lo <shiwulo@gmail.com>
May 28, 2013 / Automotive Linux Summit (Spring)
Rights to copy
Attribution – ShareAlike 3.0
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/3.0/legalcode
© Copyright 2013 0xlab
http://0xlab.org/
contact@0xlab.org
Corrections, suggestions, contributions and translations
are welcome!
Latest update: May 28, 2013
Goal of This Presentation
• Propose a practical approach of the mixture of
ARM hibernation (suspend to disk) and Linux
user-space checkpointing
– to shorten device boot time
• An intrusive technique for Android/Linux
– minimal init script and root file system changes
are required
• Boot time is one of the key factors for Automotive IVI
– mentioned by “Linux Powered Clusters” and “Silver Bullet
of Virtualization (Pitfalls, Challenges and Concerns)
Continued” at ALS 2013
– highlighted by “Boot Time Optimizations” at ALS 2012
About this presentation
• joint development efforts of the following entities
– 0xlab team - http://0xlab.org/
– OSLab, National Chung Cheng University of Taiwan, led
by Dr. Shi-wu Lo. "Software platform on SoC" prject at
ITRI/ICL, supported by MOEA of Taiwan.
– DMTCP Project at Northeastern University, led by Dr.
Gene Cooperman
• The implementation is public for reference
– Kernel part: GNU GPLv2
– Userspace: GNU LGPL
• Some areas of the implementation might be
patented. We don't expect to discuss here.
Disclaimer of Warranties
• Technical background knowledge in this
presentation is based on the experience with our
customers / partners such as CSR and MediaTek.
– We share non-confidential parts to endorse the
collaboration of Linux ecosystem.
• We make no warranty, either express or implied
with respect to any product, and specially disclaim
the correctness or real-world behavior.
Agenda (1) Concepts: Analysis, Strategies
(2) Boot Time Reduction:
from traditional to our experiments
(3) ARM Hibernation
(4) Checkpointing
(5) Mixed model
Concepts: Analysis & Strategies
(no silver bullet, but you can optimize iteratively)
Boot Time Measurement
http://elinux.org/Boot_Time
Traditional Linux Environment:
printk, initcall_debug, bootchart, strace, oprofile,
perf, ..
Bootchart
$ bootchart bootchart.tgz -f png
Strace
Trace system calls during process execution and output
timing information.
$ strace -tt ls
15:11:04.243357 execve("/bin/ls", ["ls"], [/* 51 vars */]) = 0
15:11:04.244252 brk(0) = 0x234f000
15:11:04.244458 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT
15:11:04.244676 mmap(NULL, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1444794000
15:11:04.244852 access("/etc/ld.so.preload", R_OK) = -1 ENOENT
15:11:04.245096 open("/etc/ld.so.cache", O_RDONLY) = 3
OProfile
Output Example
$ opreport --exclude-dependent
CPU: PIII, speed 863.195 MHz (estimated)
Counted CPU_CLK_UNHALTED events (clocks processor is not
halted)...
450385 75.6634 cc1plus
60213 10.1156 lyx
29313 4.9245 XFree86
11633 1.9543 as
10204 1.7142 oprofiled
7289 1.2245 vmlinux
7066 1.1871 bash
6417 1.0780 oprofile
6397 1.0747 vim
...
Perf
Recording:
Output
$ perf record -a -f
^C
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.288 MB perf.data (~12567
samples)]
$ perf report --sort comm,dso,symbol|head -10
# Events: 1K cycles
#
# Overhead Command Shared Object Symbol
# ........ ........... ...................... ............
#
35.47% firefox libxul.so [.] 0xc1b3a7
3.08% firefox libcairo.so.2.11000.2 [.] 0xff88
2.98% Xorg Xorg (deleted) [.] 0xe201c
2.51% firefox firefox [.] 0x2726
1.49% Xorg [kernel.kallsyms] [k] find_vma
0.93% perf_3.0.0 perf_3.0.0 [.] hex2u64
Perf
Timechart
$ perf timechart record
$ perf timechart
Android Environment
Bootchart
Original “bootchartd” is not suitable on embedded
devices.
Android re-implemented in its “init”.
Bootchart
To build:
$ cd system/core/init
$ touch init.c
$ mm INIT_BOOTCHART=true
Bootchart
To run:
$ adb shell 'echo 120 > /data/bootchart-start'
Remember the /data directory must be write able during
boot.
Use grab-bootchart.sh to retrieve the data.
Strace
Modify init.rc from
service zygote /system/bin/app_process 
-Xzygote /system/bin 
--zygote --start-system-server
service zygote /system/xbin/strace -tt 
-o/data/boot.strace 
/system/bin/app_process -Xzygote 
/system/bin 
--zygote --start-system-server
To
Logcat
Android log utility
Can output timing information
Adjust loglevel to 6 in init.rc

Displays time spent for each command
Dalvik Method Tracer
Method tracer is built into Dalvik
Use DDMS or using calls inside source to collect data.
// start tracing to "/sdcard/calc.trace"
Debug.startMethodTracing("calc");
// ...
// stop tracing
Debug.stopMethodTracing();
Stopwatch
Not real stopwatch
A utility in Android Framework for measuring C++ code.
Output result to system log
#include <utils/StopWatch.h>
…
{
StopWatch watch("blah");
/* your codes here */
}
Android Boot Time Analysis
Boot-loader Init
Usually constant time
Avoid init hardware multiple times
Ensure to use maximum CPU frequency
Use faster NAND/MMC reading mechanism
Kernel Init
Mostly usual suspects

ip_auto_config

USB init

Flash driver initialization
Fullow the standard Kernel optimizing guide:

http://elinux.org/Boot_Time
Avoid loading unneeded kernel module at boot time
Zygote Class Preloading
Android Framework has thousands of Java classes
Preloaded by Zygote and instantiated in its heap
To improve Application startup time and save memory
Controlled by resource: preloaded-classes

frameworks/base/preloaded-classes
Zygote Class Preloading
Can use the tool in framework to adjust the list:
$ adb logcat > logcat.txt
$ java -p preload.jar Compile logcat.txt logcat.compiled
$ java -p preload.jar PrintCsv logcat.compiled
Google Android Developer Dianne Hackborn said:

The content of the file is a “black art”

You can adjust this as much as you like

But the result maybe suboptimal
PackageManager Package Scannig
Every APK is scanned at boot time
Package management code is inefficient
Uses mmaped files means each access will cause page
fault
ParseZipArchive() scans entire APK for only one
AndroidManifest.xml file
System Services Starting
Last stage of Android boot
Start every base service
Zygote start SystemServer process
Start native service (SurfaceFlinger, AudioFlinger) first
Start each service sequentially
Boot Time Reduction
Boot Time Reduction:
The traditional approaches mentioned by many
developers/speakers already
Qi Boot-loader

Developed by Openmoko and
0xlab

Only one stage boot-loader

Small footprint ~30K

Currently support
− IMX31, Samsung 24xx,
Beagleboard, Pandaboard

KISS concept
− Boot device and load kernel
Boot-loader Improvements:
Write our faster one!
Qi
Boot-oader
U-Boot + XLoader
Size ~30K ~270K+20K
Time to Kernel < 1 s > 5s
Usage Product Engineering
Code Simple Complicated
Another example:
“Boot Time Optimizations”, Alexandre Belloni, ELCE 2012
Kernel Boot Time
Fullow the standard Kernel optimizing guide:

http://elinux.org/Boot_Time
Minimize kernel size
Use compression or not
Enable embedded options
Avoid loading unneeded kernel module at boot time
Optimize Android Init
Parallize init tasks

insmod cannot be parallized

Use external scripts to init at background
Start services on demand
Optimize Class Preloading
Trade-off between preload class and application startup
time
Split class to more packages to reduce dependency
Save inited heap for later use
Share heaps between zygote and children
Filesystem Optimization
According to reasearch by Linaro Kernel WG
Use correct NAND configuration will improve the
performance
MMC controllers are often optimized for particular
usage / filesystem
Adjust the filesystem partition scheme
Toothpaste Effect
Observed by Sony Developer Tim Bird
“When you squeeze a tube of toothpaste, sometimes it
just moves the toothpaste somewhere else in the tube,
and nothing actually comes out.”
Example:
“Trying to Improve Android Boot Time With Readahead”, Tim Bird,
ABS 2011
Lessons learnt
• Complex userspace environments like Android
usually contribute the most to boot time.
– (reported) < 1s boot time often refers to minimal
kernel + simplified initscript, which doesn't help
• GregKH: "If you want a faster D-Bus, rewrite the
daemon / library, don't mess with the kernel." at
ALS 2013
• Propose an intrusive technique for Android/Linux
– Mixture of Hibernation and Userspace
checkpointing
Part I:
Hibernation based Technologies
ARM Hibernation Solutions
• swsup hibernation
– Reference: “Extending the swsusp Hibernation
Framework to ARM”, Russell Dill at ELC 2013
• QuickBoot (proprietary)
• FastON
RAM
Hard disk
4GB
Write out
(seq.)
ARM Hibernation Diagram (1)
ARM Hibernation Diagram (2)
RAM
Hard disk
4GB
Swap space
(/hibernation
file)
ARM Hibernation Diagram (3)
RAM
Hard disk
4GB
Read-in
(seq.)
ARM Hibernation Diagram (4)
RAM
Hard disk4GB
QuickBoot
Developed by Japanese
company, Ubiquitous
Demand loading of
required page from flash
Requires deep
integration of hardware
and software
No visible information;
No production record
FastON
Developed by OSLab of National Chung Cheng
University in Taiwan
– Based on existing technologies thus requires little
modifications to userspace
– Release clean-pages before suspend
– Swap out dirty-pages before save image
– Image size reduced leads to faster resume time.
Reference: “Swap-before-hibernate: a time efficient
method to suspend an OS to a flash drive”, Dr.
Shi-wu Lo
Memory Analysis
Dirty pages
Clean pages
working
set
1. Most of the memory
status is unmodified
(clean), with an exact
copy in secondary
storage.
2. The size of working set
is very very small.
FastON Diagram (1)
flash drive
Write-out
(rand.)
FastON Diagram (2)
50
Read-in
(rand.) flash drive (fs &
swp)
Only working set is
read and resumed!
FastON
time
The
machine is
ready
Read the hibernation file
(load the Linux kernel)
The time we
measured in the
“experimental
results”
Swap in the data needed to
“run” applications
(load the working set)
0
The definition of “run” is we can start to operate the
applications very smoothly. (for example, scroll down
and up, key in)
Boot Time: Original vs. FastON
Original:
FastON:
sizeof(hiberfile)
speedseq.
+
sizeof(workingset)
speedrand.(16k)
+ device_init
sizeof(main_memory)
speedseq.
+ device_init
Boot Time: Original vs. FastON
Boottime
Complexity / Memory size
Original
FastON
Original
The hotpath
Boot Time: Original vs. FastON
Android Wakelocks & TuxOnIce
TuxOnIce Patch
TuxOnIce (was Software Suspend 2) is a hibernation
patchset
Can save images to different locations
Can use different compresion algorithms
Suspend to Disk Resume
Android Wakelocks
An aggressive approach to save device power
Use wakelocks to prevent device going suspend
Porting TOI to Android has to deal with wakelocks
because MMC driver might hold a wakelock
Source available: http://gitorious.org/0xlab-kernel
Example: Android on Beagleboard
OMAP353x; ARM Cortex-A8 600 Mhz; 256MB RAM
Kernel: 2.6.32 + TOI patch
Bootloader: Qi
Android 2.x system
Original Boot Sequence
Hibernation Boot
Further optimizations:
No Need for full-featured
Bootloader when resuming
R-Loader
Normal suspend-to-disk approach has many duplicated
effort

Boot-loader inits some hardwares

Boot-loader loads the normal kernel image

Kernel inits some hardwares again

Kernel loads the suspended kernel image

Kernel resumes, inits some hardwares again
R-Loader
0xlab proposed “Resume-Loader”
– A customized “snapshot” boot
R-Loader inits some hardware then reads the
suspended kernel image as fast as possible
Jump directly to the resume point
Kernel will takeover the job and inits reset hardwares
Advanced Topics for integrating
Hibernation with Android
Save the heap image (like core dump) of Zygote after
preloading classes
Modify Dalvik to make hibernation image after system
init and before Launcher startup
Parallize Android init
Cache & Share JITed code fragment
Part II:
Userspace solution: Checkpointing
Hibernation looks fine, why another?
• Hibernation is sometimes harmful to userspace
especially for recovering from file system or
updating packages, that is crucial for Linux-based
“smart” devices
• Post-actions are still necessary: connectivity,
firmware management, security, etc.
• Broken drivers are impossible to work with
hibernation framework, but they usually appear
from chip vendors though.
Basic Idea of checkpointing:
Process Migration
• Process Migration (in past applications)
– Distributed Load Balancing
– Efficient Resource Utilization
• Crash Recovery and Rollback Transaction
– Useful to system admin
Node
Processes
Communication Channel
Node
Processes
Node
Processes
TCP/IP
Library Library Library
TCP/IP TCP/IP
Checkpoint
Ideas about Checkpointing for
Android/Linux
• Resume to stored state for faster Android boot time
• Better product field trial experience due to regular
checkpointing
• Deploy problematic states for engineering analysis and
debugging transparently
• Q&A stress test purpose
Communication state checkpoint
Checkpoint State
Control
Rh
Rt
Recv
buffers
St
Sh
Send
buffers
ShRt+1
Timers,
Options,
etc.
Rh St+1 ShRt+1 XX
receive()
direct
access
direct
access
State for one socket
Rh
Rt
...
St
Sh
...
Rt+1
Rh
Sh
St+1
Timers,
Options,
etc.
Control
Recv buffers Send buffers
copied_seq
rcv_nxt snd_una
write_seq
Live Communication State
• Acquire network stack locks to
freeze TCP processing
• Save receive buffers using
socket receive system call in
peek mode
• Save send buffers by walking
kernel structures
• Copy control state from kernel
structures
• Modify two sequence numbers
in saved state to reflect empty
socket buffers
Communication state restart
Control
Live Communication State
copied_seq
rcv_nxt snd_una
write_seq
St
Sh
...
Send buffers
Checkpoint State
Control
Rh
Rt
Recv
buffers
St
Sh
Send
buffers
ShRt+1
Timers,
Options,
etc.
Rt+1 Sh
Rt+1
Rt+1
Sh
Timers,
Options,
etc.
Rh
Rt
Recv
data
direct
update
St+1
write()
To App by intercepted
receive system call
Sh
State for one socket
• Create a new socket
• Copy control state in
checkpoint to socket structure
• Restore checkpointed send
buffer data using the socket
write call
• Deliver checkpointed receive
buffer data to application on
demand
Existing Checkpointing mechanisms
• CryoPID
– http://cryopid.berlios.de/
• BLCR (Berkeley Lab Checkpoint/Restart)
– https://ftg.lbl.gov/projects/CheckpointRestart/
• DMTCP
– http://dmtcp.sourceforge.net/
Implementation Considerations
• Checkpointing can be implemented in
– kernel modifications + helpers in userspace
– pure userspace
• Introduce a virtualization layer groups processes into specific
states with private virtual name space
– Intercepts system calls to expose only virtual identifiers (e.g.,
vpid)
– Preserves resource names and dependencies across
migration
• Mechanism to checkpoint and restart states
– User and kernel-level state
– Primarily uses system call handlers
– File system not saved or restored
DMTCP
• Distributed Multi-Threaded CheckPointing.
• Works with Linux Kernel 2.6.9 and later.
• Supports sequential and multi-threaded computations
across single/multiple hosts.
• Entirely in user space (no kernel modules or root
privilege).
– Transparent (no recompiling, no re-linking).
• Developed in Northeastern University and MIT and
under active development since 2006.
• License: GNU LGPL (allows freely using and linking)
Process Structure
CT = DMTCP checkpoint thread
T = User Thread
DMTCP
Coordinator
CTCT
T1T1 T2
Signal (USR2)
Network Socket
Process 1 Process N
dmtcp_checkpoint <EXE> # starts coordinator
dmtcp_command –c # talks to coordinator
dmtcp_restart ckpt_<EXE>-*.dmtcp
• Coordinator: a stateless synchronization server for the
distributed checkpointing algorithm.
• Checkpoint/Restart performance related to size of memory,
disk write speed, and synchronization.
How DMTCP works (1/4)
• MTCP : component for checkpoint single-process
• SIGUSR2: Used internally from checkpoint thread to
user threads.
CT
T1 T2
User program
Checkpoint thread
1. CT sends SIGUSR2 to
each threads for suspending
2. Write checkpoint image
to disk
3. Exit SIGUSR2 handler,
and resume.
How DMTCP works (2/4)
• LD_PRELOAD: Transparently preloads checkpoint libraries
`dmtcphijack.so` which installs libc wrappers and checkpointing
code.
• Wrappers: Only on less heavily used calls to libc
– open, fork, exec, system, pipe, bind, listen,
setsockopt, connect, accept, clone, close, ptsname,
openlog, closelog, signal, sigaction, sigvec,
sigblock, sigsetmask, sigprocmask, rt_sigprocmask,
pthread_sigmask
– Overhead is negligible.
...
fd = open(path,
flags);
...
User Program
int open(const char *path,
int flags){
...
funcs[_open](path, flags);
...
}
dmtcphijack.so
int open(const char *path,
int flags){
...
}
libc.so
How DMTCP works (3/4)
• Additional wrappers when process id & thread id
virtualization is enabled
– getpid, getppid, gettid, tcgetpgrp,
tcsetprgrp, getgrp, setpgrp, getsid,
setsid, kill, tkill, tgkill, wait, waitpid,
waitid, wait3, wait4
...
pid = getpid();
...
User Program
int getpid(){
...
real_pid = funcs[_getpid]();
return pid_table[real_pid];
}
dmtcphijack.so
int getpid(){
...
}
libc.so
How DMTCP works (4/4)
• Checkpoint image compression on-the-fly (default).
• Currently only supports dynamically linking to libc.so.
Support for static libc.a is feasible, but not
implemented.
Checkpoint under DMTCP(1/7)
• dmtcphijack.so and libmtcp.so present in executable’s
memory.
– dmtcp_checkpoint <EXE>
CT
T1 T2
Coordinator
User program
Connect to exist coordinator
or create a new coordinator
CT
T1 T2
User program
Checkpoint under DMTCP(2/7)
• Ask coordinator process for checkpoint via
dmtcp_command.
– dmtcp_command -c
• DMTCP also provides API to send command or query
status
CT
T1 T2
Coordinator
User program
command
Send checkpoint
command
CT
T1 T2
User program
Checkpoint under DMTCP(3/7)
• Suspend user threads with SIGUSR2.
CT
T1 T2
Coordinator
User program
1. send command
for prepare
checkpoint
2. CT sends SIGUSR2 to
each threads for suspending
CT
T1 T2
User program
Checkpoint under DMTCP(4/7)
• Pre-checkpoint stage
• Synchronize every node and elect shared file
descriptor leaders.
• Drain kernel buffers and do network handshake with
peers.
CT
T1 T2
Coordinator
User program
2. Drain buffers
CT
T1 T2
User program
Wait until all nodes are ready.
1. Report all thread
except CT are suspended
Checkpoint under DMTCP(5/7)
• Write checkpoint to disk
– One checkpoint file per process
– ckpt_<EXE>_<uid>.dmtcp
CT
T1 T2
Coordinator
User program
Write checkpoint to
disk separately
CT
T1 T2
User program
Wait until all nodes of
checkpoint are done
Checkpoint under DMTCP(6/7)
• Post-Checkpint stage
• Refill kernel buffers
CT
T1 T2
Coordinator
User program
Refill buffer and
re-handshake with peers.
CT
T1 T2
User program
Wait until all nodes of
post-checkpoint are done
Checkpoint under DMTCP(7/7)
• Resume user threads.
CT
T1 T2
Coordinator
User program
Resume!
CT
T1 T2
User program
Send resume command
Restart under DMTCP(1/6)
• Restart Process loads in memory.
– dmtcp_restart ckpt_<EXE>_<uid>.dmtcp
CT
Coordinator
dmtcp_restart
1. Connect to exist coordinator
or create a new coordinator
2. Load process to memory
Restart under DMTCP(2/6)
• Fork user program
CT
Coordinator
dmtcp_restart
CT
dmtcp_restart
Restart under DMTCP(3/6)
• Reopen files and recreate ptys
• Recreate and reconnect sockets
• Rearrange file descriptors to initial layout
CT
Coordinator
dmtcp_restart
Wail all node recreate socket
and reopen file
1. Reopen file/ptys/sockets
CT
dmtcp_restart
2. Rearrange FD via dup2
Restart under DMTCP(4/6)
• Restore memory content.
• Restore stack status for checkpoint thread.
CT
Coordinator
dmtcp_restart
CT
dmtcp_restart
CT
Coordinator
CT
User programUser program
dmtcp_restart
mtcp_restart
User program
execve
mmap + magic!!
FDs will preserved across execve!
Restart under DMTCP(5/6)
• Restore other threads.
– Recreate thread and restore stack and context.
– Restore back to the post-checkpint stage
• Refill kernel buffer
CT
Coordinator
Wail all nodes restoring are done
1. Memory and thread
come back now!
CT
T1 T2T1 T2
User programUser program
2. Refill buffers
Restart under DMTCP(6/6)
• Resume user threads
CT
Coordinator
Resume!CT
T1 T2T1 T2
User programUser program
<user_func1>
<user_func2>
<user_funcN>
...
<sig-handler>
stopthisthread
Thread Call Stack
...
while (mtcp_state_value(&thread -> state)
== ST_SUSPENDED) {
mtcp_state_futex (&(thread -> state),
FUTEX_WAIT,
ST_SUSPENDED,
NULL);
}
...
DMTCP Workflow
Start with dmtcp
wrapper
Run
Pre-Checkpoint
Checkpoint
Post-Checkpoint
Restart
Re-open FDs
Restore memory
Restore threads
Provide hook
point!
Get checkpoint
command
OS Features supported by DMTCP
• Threads, mutexes/semaphores, fork, exec
• Shared memory (via mmap), TCP/IP sockets, UNIX
domain sockets, pipes, ptys, terminal modes,
ownership of controlling terminals, signal handlers,
open and/or shared fds, I/O (including the readline
library), parent-child process relationships, process id
& thread id virtualization, session and process group
ids, and more…
DMTCP/Android: Additional Features
(LGPL; separated from Android)
• ARM Architecture support
– Verified on Samsung Galaxy S2 + Android 4.0
• Binder IPC
– Client: supported
– Server: partially supported
• Ashmem: supported
• Logger: supported
• Properties: supported
• Wakelocks: Not supported
Already merged in upstream DMTCP
Android Binder support for DMTCP
• BinderConnection
– Reopen /dev/binder and reset ioctl parameters
– Restore the mmap region
• Hijack the whole libbinder
– Prevent libbinder from interpreting data twice
– Implement necessary DMTCP hooks: preCheckpoint,
postCheckpoint, postRestart
• Re-initialize libbinder in postRestart
• The server part is partially supported because binder
server is calling a blocked ioctl and blocking the whole
checkpoint process.
– We implement an early checkpoint stage to suspend
such kind of threads.
More extensions in DMTCP/Android
• Improve the hook system in DMTCP
– Original design only allows one set hook function.
– Allow more than one set hook function in
DMTCP/Android.
• Implement per thread callback hook
– Restore the DVM internal thread info
• Add barrier and synchronize mechanisms to DMTCP
– In order to make precise program checkpointing.
Android specific modifications
• Reorder code in framework
– registerZygoteSocket()
• The socket is inherited from the parent process `init`,
which implies we can not handle it in DMTCP.
– Move few initializations later than the checkpoint process
since the current binder support is incomplete.
• Reserve the ashmem's file descriptor
– Original behavior is to close the fd after mmap
– DMTCP binds connection to one fd, so the connection will be
destroyed if that fd is closed.
• Implement the missing PThread function in bionic libc
– pthread_tryjoin_np is required by DMTCP,
but it s not implemented in original bionic.
Technical Issues when modifying
DMTCP• ARM Architecture support is incomplete.
• Different TLS implementation semantics between glibc and
bionic libc
– DMTCP/Android follows the techniques used in Android´s
OpenGL ES package which links and defers to the slot of
TLS in bionic libc. Not elegant, but it works
• PThread implementation expectation is quite different
– AOSP master branch is merging libc from NetBSD, so it
should be better for compatibility.
• Behavior of dynamic linker differs a lot in bionic libc.
• Flags in dlopen() is not really functional.
• The way to find symbol in bionic libc differs: weak symbol
Checkpoint for Zygote
• Experiment environment:
– Android on ARM Cortex-A9 dual (1GHz; Memory: 512 MB)
with gzip without gzip
Checkpoint time
~8s ~4.5s
Restart time
~0.3s ~0.1s
Image size
~3M ~17M
--------- beginning of /dev/log/system
I/Vold ( 1270): Vold 2.1 (the revenge) firing up
D/Vold ( 1270): Volume usb state changing -1 (Initializing) -> 0 (No-Media)
I/Netd ( 1271): Netd 1.0 starting
I/ ( 1275): ServiceManager: 0x8062b50
I/ ( 1276): ServiceManager: 0x804fb98
I/AudioFlinger( 1276): Loaded primary audio interface from LEGACY Audio HW HAL (audio)
I/AudioFlinger( 1276): Using 'LEGACY Audio HW HAL' (audio.primary) as the primary audio interface
...
D/AudioHardware( 1276): ### setVoiceVolume: 1.000000
I/AudioPolicyService( 1276): [1276]Loaded audio policy from LEGACY Audio Policy HAL (audio_policy)
E/BatteryService( 1382): usbOnlinePath not found
D/AndroidRuntime( 1902):
D/AndroidRuntime( 1902): >>>>>> AndroidRuntime START com.android.internal.os.ZygoteInit <<<<<<
D/AndroidRuntime( 1902): CheckJNI is ON
I/SamplingProfilerIntegration( 1902): Profiling disabled.
I/Zygote ( 1902): Preloading classes...
D/dalvikvm( 1902): GC_EXPLICIT freed 35K, 85% free 399K/2560K, paused 0ms+0ms
...
I/Zygote ( 1902): ...preloaded 379 resources in 548ms.
D/dalvikvm( 1902): GC_EXPLICIT freed 20K, 1% free 6417K/6467K, paused 0ms+0ms
I/Zygote ( 1902): ...preloaded 31 resources in 13ms.
D/dalvikvm( 1902): GC_EXPLICIT freed 14K, 1% free 6418K/6467K, paused 0ms+0ms
D/dalvikvm( 1902): GC_EXPLICIT freed 5K, 1% free 6412K/6467K, paused 0ms+0ms
D/dalvikvm( 1902): GC_EXPLICIT freed <1K, 1% free 6412K/6467K, paused 0ms+2ms
I/dalvikvm( 1902): System server process 1911 has been created
--------- beginning of /dev/log/system
I/Vold ( 1270): Vold 2.1 (the revenge) firing up
D/Vold ( 1270): Volume usb state changing -1 (Initializing) -> 0 (No-Media)
I/Netd ( 1271): Netd 1.0 starting
I/ ( 1275): ServiceManager: 0x8062b50
I/ ( 1276): ServiceManager: 0x804fb98
I/AudioFlinger( 1276): Loaded primary audio interface from LEGACY Audio HW
I/AudioFlinger( 1276): Using 'LEGACY Audio HW HAL' (audio.primary) as the
….
D/AudioHardware( 1276): ### setVoiceVolume: 1.000000
I/AudioPolicyService( 1276): [1276]Loaded audio policy from LEGACY Audio P
D/dalvikvm( 1373): GC_EXPLICIT freed 14K, 1% free 6418K/6467K, paused 0
D/dalvikvm( 1373): GC_EXPLICIT freed 5K, 1% free 6412K/6467K, paused 0m
D/dalvikvm( 1373): GC_EXPLICIT freed <1K, 1% free 6412K/6467K, paused 0
I/dalvikvm( 1373): System server process 1382 has been created
Normal bootup log message Bootup log message with restart
Observations from logcat
Part III:
Mixted Model
Mixed Model: Hibernation + Checkpointing
• Basic Idea
– Swap out dirty-pages before save image
– Reducing image size leads to faster resume time
– Only the “static” working set is suspended, other parts
utilizes checkpointing
– Room for keeping __broken__ device drivers
• However, the state machine is relatively intricate
because of application framework awareness.
Technical Challenges of Mixed Model
• Have to modify Android/Tizen framework in order to
figure the proper checkpoint to perform.
– It is not straightforward since recent application frameworks
depend on web rendering engine as the core component.
– Working-set is hard to be minimized accordingly.
• Separate the device initializations into two areas:
– essential zone: taken for Hibernation
– post-resuming: used for checkpointing, firmware
management, and connectivity → problem of maintenance
• Storage access time is crucial since we touch for
several times
– I/O scheduler modifications are under investigation
Timing diagram of Hibernation stage
(when request speed > response speed, it means I/O operations are busy)
Time diagram of Device Resuming
Conclusion
• No silver bullet for device boot time optimizations
• Developing an intrusive technique for Android or
complex Linux systems is possible for design
aspects
• The quality of device driver and file system causes
essential impacts as well no matter how a new
technique is introduced.
• Mixed model can be used for the production of
dedicated systems such as digital TV and
automotive IVI.
Reference
• Embedded Linux Wiki: http://elinux.org/Boot_Time
• “DMTCP: An New Linux Checkpointing Mechanism
for Vanilla Universe Job”, Condor Project, University of
Wisconsin-Madison
• “Checkpointing using DMTCP, Condor, Matlab and
FReD”, Gene Cooperman, Northeastern University, Boston
• “Boot Time Optimizations”, Alexandre Belloni, ELCE 2012
• “Extending the swsusp Hibernation Framework to
ARM”, Russell Dill, ELC 2013
http://0xlab.org

Contenu connexe

Tendances

Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
Utkarsh Mankad
 
Linux internal
Linux internalLinux internal
Linux internal
mcganesh
 

Tendances (20)

Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
 
Linux PCI device driver
Linux PCI device driverLinux PCI device driver
Linux PCI device driver
 
Deep Dive into the AOSP
Deep Dive into the AOSPDeep Dive into the AOSP
Deep Dive into the AOSP
 
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveAndroid graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
 
Android device driver structure introduction
Android device driver structure introductionAndroid device driver structure introduction
Android device driver structure introduction
 
Introduction to Android Window System
Introduction to Android Window SystemIntroduction to Android Window System
Introduction to Android Window System
 
Character drivers
Character driversCharacter drivers
Character drivers
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)
 
Building aosp
Building aospBuilding aosp
Building aosp
 
BKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateBKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack Update
 
Linux Internals - Part II
Linux Internals - Part IILinux Internals - Part II
Linux Internals - Part II
 
Linux Internals - Part I
Linux Internals - Part ILinux Internals - Part I
Linux Internals - Part I
 
Implementing generic JNI hardware control for Kotlin based app on AOSP
Implementing generic JNI hardware control for Kotlin based app on AOSPImplementing generic JNI hardware control for Kotlin based app on AOSP
Implementing generic JNI hardware control for Kotlin based app on AOSP
 
Linux internal
Linux internalLinux internal
Linux internal
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
 
Linux Porting
Linux PortingLinux Porting
Linux Porting
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 

En vedette

En vedette (20)

Hints for L4 Microkernel
Hints for L4 MicrokernelHints for L4 Microkernel
Hints for L4 Microkernel
 
Lecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and ImplementationLecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and Implementation
 
Implement Runtime Environments for HSA using LLVM
Implement Runtime Environments for HSA using LLVMImplement Runtime Environments for HSA using LLVM
Implement Runtime Environments for HSA using LLVM
 
olibc: Another C Library optimized for Embedded Linux
olibc: Another C Library optimized for Embedded Linuxolibc: Another C Library optimized for Embedded Linux
olibc: Another C Library optimized for Embedded Linux
 
Construct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoTConstruct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoT
 
Embedded Virtualization applied in Mobile Devices
Embedded Virtualization applied in Mobile DevicesEmbedded Virtualization applied in Mobile Devices
Embedded Virtualization applied in Mobile Devices
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsDevelop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM Boards
 
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded SystemsF9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
 
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
 
The Internals of "Hello World" Program
The Internals of "Hello World" ProgramThe Internals of "Hello World" Program
The Internals of "Hello World" Program
 
Microkernel Evolution
Microkernel EvolutionMicrokernel Evolution
Microkernel Evolution
 
Priority Inversion on Mars
Priority Inversion on MarsPriority Inversion on Mars
Priority Inversion on Mars
 
Hardware Accelerated 2D Rendering for Android
Hardware Accelerated 2D Rendering for AndroidHardware Accelerated 2D Rendering for Android
Hardware Accelerated 2D Rendering for Android
 
Xvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisorXvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisor
 
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
 
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
 
Virtual Machine Constructions for Dummies
Virtual Machine Constructions for DummiesVirtual Machine Constructions for Dummies
Virtual Machine Constructions for Dummies
 
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
 
Faults inside System Software
Faults inside System SoftwareFaults inside System Software
Faults inside System Software
 

Similaire à Shorten Device Boot Time for Automotive IVI and Navigation Systems

How to accelerate docker adoption with a simple and powerful user experience
How to accelerate docker adoption with a simple and powerful user experienceHow to accelerate docker adoption with a simple and powerful user experience
How to accelerate docker adoption with a simple and powerful user experience
Docker, Inc.
 

Similaire à Shorten Device Boot Time for Automotive IVI and Navigation Systems (20)

How to accelerate docker adoption with a simple and powerful user experience
How to accelerate docker adoption with a simple and powerful user experienceHow to accelerate docker adoption with a simple and powerful user experience
How to accelerate docker adoption with a simple and powerful user experience
 
Renesas DevCon 2010: Starting a QT Application with Minimal Boot
Renesas DevCon 2010: Starting a QT Application with Minimal BootRenesas DevCon 2010: Starting a QT Application with Minimal Boot
Renesas DevCon 2010: Starting a QT Application with Minimal Boot
 
Linux Assignment 3
Linux Assignment 3Linux Assignment 3
Linux Assignment 3
 
Introduction to Operating System (Important Notes)
Introduction to Operating System (Important Notes)Introduction to Operating System (Important Notes)
Introduction to Operating System (Important Notes)
 
Parallelizing CI using Docker Swarm-Mode
Parallelizing CI using Docker Swarm-ModeParallelizing CI using Docker Swarm-Mode
Parallelizing CI using Docker Swarm-Mode
 
DockerCon Europe 2018 Monitoring & Logging Workshop
DockerCon Europe 2018 Monitoring & Logging WorkshopDockerCon Europe 2018 Monitoring & Logging Workshop
DockerCon Europe 2018 Monitoring & Logging Workshop
 
Apache Spark Performance is too hard. Let's make it easier
Apache Spark Performance is too hard. Let's make it easierApache Spark Performance is too hard. Let's make it easier
Apache Spark Performance is too hard. Let's make it easier
 
Performance Analysis of Idle Programs
Performance Analysis of Idle ProgramsPerformance Analysis of Idle Programs
Performance Analysis of Idle Programs
 
DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.
 
Reproducibility in artificial intelligence
Reproducibility in artificial intelligenceReproducibility in artificial intelligence
Reproducibility in artificial intelligence
 
Fast boot
Fast bootFast boot
Fast boot
 
Java Memory Hogs.pdf
Java Memory Hogs.pdfJava Memory Hogs.pdf
Java Memory Hogs.pdf
 
Pentesting iOS Apps
Pentesting iOS AppsPentesting iOS Apps
Pentesting iOS Apps
 
Node js meetup
Node js meetupNode js meetup
Node js meetup
 
Tuning Java Servers
Tuning Java Servers Tuning Java Servers
Tuning Java Servers
 
A DevOps guide to Kubernetes
A DevOps guide to KubernetesA DevOps guide to Kubernetes
A DevOps guide to Kubernetes
 
C# Production Debugging Made Easy
 C# Production Debugging Made Easy C# Production Debugging Made Easy
C# Production Debugging Made Easy
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
 
The DevOps paradigm - the evolution of IT professionals and opensource toolkit
The DevOps paradigm - the evolution of IT professionals and opensource toolkitThe DevOps paradigm - the evolution of IT professionals and opensource toolkit
The DevOps paradigm - the evolution of IT professionals and opensource toolkit
 
The DevOps Paradigm
The DevOps ParadigmThe DevOps Paradigm
The DevOps Paradigm
 

Plus de National Cheng Kung University

Plus de National Cheng Kung University (12)

PyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtimePyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtime
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
2016 年春季嵌入式作業系統課程說明
2016 年春季嵌入式作業系統課程說明2016 年春季嵌入式作業系統課程說明
2016 年春季嵌入式作業系統課程說明
 
Interpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratchInterpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratch
 
How A Compiler Works: GNU Toolchain
How A Compiler Works: GNU ToolchainHow A Compiler Works: GNU Toolchain
How A Compiler Works: GNU Toolchain
 
從線上售票看作業系統設計議題
從線上售票看作業系統設計議題從線上售票看作業系統設計議題
從線上售票看作業系統設計議題
 
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
 
Open Source from Legend, Business, to Ecosystem
Open Source from Legend, Business, to EcosystemOpen Source from Legend, Business, to Ecosystem
Open Source from Legend, Business, to Ecosystem
 
Summer Project: Microkernel (2013)
Summer Project: Microkernel (2013)Summer Project: Microkernel (2013)
Summer Project: Microkernel (2013)
 
Develop Your Own Operating System
Develop Your Own Operating SystemDevelop Your Own Operating System
Develop Your Own Operating System
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Shorten Device Boot Time for Automotive IVI and Navigation Systems

  • 1. Shorten Device Boot Time for Automotive IVI and Navigation Systems Jim Huang ( 黃敬群 ) <jserv@0xlab.org> Dr. Shi-wu Lo <shiwulo@gmail.com> May 28, 2013 / Automotive Linux Summit (Spring)
  • 2. Rights to copy Attribution – ShareAlike 3.0 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/3.0/legalcode © Copyright 2013 0xlab http://0xlab.org/ contact@0xlab.org Corrections, suggestions, contributions and translations are welcome! Latest update: May 28, 2013
  • 3. Goal of This Presentation • Propose a practical approach of the mixture of ARM hibernation (suspend to disk) and Linux user-space checkpointing – to shorten device boot time • An intrusive technique for Android/Linux – minimal init script and root file system changes are required • Boot time is one of the key factors for Automotive IVI – mentioned by “Linux Powered Clusters” and “Silver Bullet of Virtualization (Pitfalls, Challenges and Concerns) Continued” at ALS 2013 – highlighted by “Boot Time Optimizations” at ALS 2012
  • 4. About this presentation • joint development efforts of the following entities – 0xlab team - http://0xlab.org/ – OSLab, National Chung Cheng University of Taiwan, led by Dr. Shi-wu Lo. "Software platform on SoC" prject at ITRI/ICL, supported by MOEA of Taiwan. – DMTCP Project at Northeastern University, led by Dr. Gene Cooperman • The implementation is public for reference – Kernel part: GNU GPLv2 – Userspace: GNU LGPL • Some areas of the implementation might be patented. We don't expect to discuss here.
  • 5. Disclaimer of Warranties • Technical background knowledge in this presentation is based on the experience with our customers / partners such as CSR and MediaTek. – We share non-confidential parts to endorse the collaboration of Linux ecosystem. • We make no warranty, either express or implied with respect to any product, and specially disclaim the correctness or real-world behavior.
  • 6. Agenda (1) Concepts: Analysis, Strategies (2) Boot Time Reduction: from traditional to our experiments (3) ARM Hibernation (4) Checkpointing (5) Mixed model
  • 7. Concepts: Analysis & Strategies (no silver bullet, but you can optimize iteratively)
  • 10. Traditional Linux Environment: printk, initcall_debug, bootchart, strace, oprofile, perf, ..
  • 12. Strace Trace system calls during process execution and output timing information. $ strace -tt ls 15:11:04.243357 execve("/bin/ls", ["ls"], [/* 51 vars */]) = 0 15:11:04.244252 brk(0) = 0x234f000 15:11:04.244458 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT 15:11:04.244676 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1444794000 15:11:04.244852 access("/etc/ld.so.preload", R_OK) = -1 ENOENT 15:11:04.245096 open("/etc/ld.so.cache", O_RDONLY) = 3
  • 13. OProfile Output Example $ opreport --exclude-dependent CPU: PIII, speed 863.195 MHz (estimated) Counted CPU_CLK_UNHALTED events (clocks processor is not halted)... 450385 75.6634 cc1plus 60213 10.1156 lyx 29313 4.9245 XFree86 11633 1.9543 as 10204 1.7142 oprofiled 7289 1.2245 vmlinux 7066 1.1871 bash 6417 1.0780 oprofile 6397 1.0747 vim ...
  • 14. Perf Recording: Output $ perf record -a -f ^C [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.288 MB perf.data (~12567 samples)] $ perf report --sort comm,dso,symbol|head -10 # Events: 1K cycles # # Overhead Command Shared Object Symbol # ........ ........... ...................... ............ # 35.47% firefox libxul.so [.] 0xc1b3a7 3.08% firefox libcairo.so.2.11000.2 [.] 0xff88 2.98% Xorg Xorg (deleted) [.] 0xe201c 2.51% firefox firefox [.] 0x2726 1.49% Xorg [kernel.kallsyms] [k] find_vma 0.93% perf_3.0.0 perf_3.0.0 [.] hex2u64
  • 15. Perf Timechart $ perf timechart record $ perf timechart
  • 17. Bootchart Original “bootchartd” is not suitable on embedded devices. Android re-implemented in its “init”.
  • 18. Bootchart To build: $ cd system/core/init $ touch init.c $ mm INIT_BOOTCHART=true
  • 19. Bootchart To run: $ adb shell 'echo 120 > /data/bootchart-start' Remember the /data directory must be write able during boot. Use grab-bootchart.sh to retrieve the data.
  • 20. Strace Modify init.rc from service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server service zygote /system/xbin/strace -tt -o/data/boot.strace /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server To
  • 21. Logcat Android log utility Can output timing information Adjust loglevel to 6 in init.rc  Displays time spent for each command
  • 22. Dalvik Method Tracer Method tracer is built into Dalvik Use DDMS or using calls inside source to collect data. // start tracing to "/sdcard/calc.trace" Debug.startMethodTracing("calc"); // ... // stop tracing Debug.stopMethodTracing();
  • 23. Stopwatch Not real stopwatch A utility in Android Framework for measuring C++ code. Output result to system log #include <utils/StopWatch.h> … { StopWatch watch("blah"); /* your codes here */ }
  • 24. Android Boot Time Analysis
  • 25. Boot-loader Init Usually constant time Avoid init hardware multiple times Ensure to use maximum CPU frequency Use faster NAND/MMC reading mechanism
  • 26. Kernel Init Mostly usual suspects  ip_auto_config  USB init  Flash driver initialization Fullow the standard Kernel optimizing guide:  http://elinux.org/Boot_Time Avoid loading unneeded kernel module at boot time
  • 27. Zygote Class Preloading Android Framework has thousands of Java classes Preloaded by Zygote and instantiated in its heap To improve Application startup time and save memory Controlled by resource: preloaded-classes  frameworks/base/preloaded-classes
  • 28. Zygote Class Preloading Can use the tool in framework to adjust the list: $ adb logcat > logcat.txt $ java -p preload.jar Compile logcat.txt logcat.compiled $ java -p preload.jar PrintCsv logcat.compiled Google Android Developer Dianne Hackborn said:  The content of the file is a “black art”  You can adjust this as much as you like  But the result maybe suboptimal
  • 29. PackageManager Package Scannig Every APK is scanned at boot time Package management code is inefficient Uses mmaped files means each access will cause page fault ParseZipArchive() scans entire APK for only one AndroidManifest.xml file
  • 30. System Services Starting Last stage of Android boot Start every base service Zygote start SystemServer process Start native service (SurfaceFlinger, AudioFlinger) first Start each service sequentially
  • 32. Boot Time Reduction: The traditional approaches mentioned by many developers/speakers already
  • 33. Qi Boot-loader  Developed by Openmoko and 0xlab  Only one stage boot-loader  Small footprint ~30K  Currently support − IMX31, Samsung 24xx, Beagleboard, Pandaboard  KISS concept − Boot device and load kernel Boot-loader Improvements: Write our faster one! Qi Boot-oader U-Boot + XLoader Size ~30K ~270K+20K Time to Kernel < 1 s > 5s Usage Product Engineering Code Simple Complicated Another example: “Boot Time Optimizations”, Alexandre Belloni, ELCE 2012
  • 34. Kernel Boot Time Fullow the standard Kernel optimizing guide:  http://elinux.org/Boot_Time Minimize kernel size Use compression or not Enable embedded options Avoid loading unneeded kernel module at boot time
  • 35. Optimize Android Init Parallize init tasks  insmod cannot be parallized  Use external scripts to init at background Start services on demand
  • 36. Optimize Class Preloading Trade-off between preload class and application startup time Split class to more packages to reduce dependency Save inited heap for later use Share heaps between zygote and children
  • 37. Filesystem Optimization According to reasearch by Linaro Kernel WG Use correct NAND configuration will improve the performance MMC controllers are often optimized for particular usage / filesystem Adjust the filesystem partition scheme
  • 38. Toothpaste Effect Observed by Sony Developer Tim Bird “When you squeeze a tube of toothpaste, sometimes it just moves the toothpaste somewhere else in the tube, and nothing actually comes out.” Example: “Trying to Improve Android Boot Time With Readahead”, Tim Bird, ABS 2011
  • 39. Lessons learnt • Complex userspace environments like Android usually contribute the most to boot time. – (reported) < 1s boot time often refers to minimal kernel + simplified initscript, which doesn't help • GregKH: "If you want a faster D-Bus, rewrite the daemon / library, don't mess with the kernel." at ALS 2013 • Propose an intrusive technique for Android/Linux – Mixture of Hibernation and Userspace checkpointing
  • 41. ARM Hibernation Solutions • swsup hibernation – Reference: “Extending the swsusp Hibernation Framework to ARM”, Russell Dill at ELC 2013 • QuickBoot (proprietary) • FastON
  • 42. RAM Hard disk 4GB Write out (seq.) ARM Hibernation Diagram (1)
  • 43. ARM Hibernation Diagram (2) RAM Hard disk 4GB Swap space (/hibernation file)
  • 44. ARM Hibernation Diagram (3) RAM Hard disk 4GB Read-in (seq.)
  • 45. ARM Hibernation Diagram (4) RAM Hard disk4GB
  • 46. QuickBoot Developed by Japanese company, Ubiquitous Demand loading of required page from flash Requires deep integration of hardware and software No visible information; No production record
  • 47. FastON Developed by OSLab of National Chung Cheng University in Taiwan – Based on existing technologies thus requires little modifications to userspace – Release clean-pages before suspend – Swap out dirty-pages before save image – Image size reduced leads to faster resume time. Reference: “Swap-before-hibernate: a time efficient method to suspend an OS to a flash drive”, Dr. Shi-wu Lo
  • 48. Memory Analysis Dirty pages Clean pages working set 1. Most of the memory status is unmodified (clean), with an exact copy in secondary storage. 2. The size of working set is very very small.
  • 49. FastON Diagram (1) flash drive Write-out (rand.)
  • 50. FastON Diagram (2) 50 Read-in (rand.) flash drive (fs & swp) Only working set is read and resumed!
  • 51. FastON time The machine is ready Read the hibernation file (load the Linux kernel) The time we measured in the “experimental results” Swap in the data needed to “run” applications (load the working set) 0 The definition of “run” is we can start to operate the applications very smoothly. (for example, scroll down and up, key in)
  • 52. Boot Time: Original vs. FastON Original: FastON: sizeof(hiberfile) speedseq. + sizeof(workingset) speedrand.(16k) + device_init sizeof(main_memory) speedseq. + device_init
  • 53. Boot Time: Original vs. FastON Boottime Complexity / Memory size Original FastON Original The hotpath
  • 54. Boot Time: Original vs. FastON
  • 56. TuxOnIce Patch TuxOnIce (was Software Suspend 2) is a hibernation patchset Can save images to different locations Can use different compresion algorithms
  • 57. Suspend to Disk Resume
  • 58. Android Wakelocks An aggressive approach to save device power Use wakelocks to prevent device going suspend Porting TOI to Android has to deal with wakelocks because MMC driver might hold a wakelock Source available: http://gitorious.org/0xlab-kernel
  • 59. Example: Android on Beagleboard OMAP353x; ARM Cortex-A8 600 Mhz; 256MB RAM Kernel: 2.6.32 + TOI patch Bootloader: Qi Android 2.x system
  • 62. Further optimizations: No Need for full-featured Bootloader when resuming
  • 63. R-Loader Normal suspend-to-disk approach has many duplicated effort  Boot-loader inits some hardwares  Boot-loader loads the normal kernel image  Kernel inits some hardwares again  Kernel loads the suspended kernel image  Kernel resumes, inits some hardwares again
  • 64. R-Loader 0xlab proposed “Resume-Loader” – A customized “snapshot” boot R-Loader inits some hardware then reads the suspended kernel image as fast as possible Jump directly to the resume point Kernel will takeover the job and inits reset hardwares
  • 65. Advanced Topics for integrating Hibernation with Android Save the heap image (like core dump) of Zygote after preloading classes Modify Dalvik to make hibernation image after system init and before Launcher startup Parallize Android init Cache & Share JITed code fragment
  • 67. Hibernation looks fine, why another? • Hibernation is sometimes harmful to userspace especially for recovering from file system or updating packages, that is crucial for Linux-based “smart” devices • Post-actions are still necessary: connectivity, firmware management, security, etc. • Broken drivers are impossible to work with hibernation framework, but they usually appear from chip vendors though.
  • 68. Basic Idea of checkpointing: Process Migration • Process Migration (in past applications) – Distributed Load Balancing – Efficient Resource Utilization • Crash Recovery and Rollback Transaction – Useful to system admin Node Processes Communication Channel Node Processes Node Processes TCP/IP Library Library Library TCP/IP TCP/IP Checkpoint
  • 69. Ideas about Checkpointing for Android/Linux • Resume to stored state for faster Android boot time • Better product field trial experience due to regular checkpointing • Deploy problematic states for engineering analysis and debugging transparently • Q&A stress test purpose
  • 70. Communication state checkpoint Checkpoint State Control Rh Rt Recv buffers St Sh Send buffers ShRt+1 Timers, Options, etc. Rh St+1 ShRt+1 XX receive() direct access direct access State for one socket Rh Rt ... St Sh ... Rt+1 Rh Sh St+1 Timers, Options, etc. Control Recv buffers Send buffers copied_seq rcv_nxt snd_una write_seq Live Communication State • Acquire network stack locks to freeze TCP processing • Save receive buffers using socket receive system call in peek mode • Save send buffers by walking kernel structures • Copy control state from kernel structures • Modify two sequence numbers in saved state to reflect empty socket buffers
  • 71. Communication state restart Control Live Communication State copied_seq rcv_nxt snd_una write_seq St Sh ... Send buffers Checkpoint State Control Rh Rt Recv buffers St Sh Send buffers ShRt+1 Timers, Options, etc. Rt+1 Sh Rt+1 Rt+1 Sh Timers, Options, etc. Rh Rt Recv data direct update St+1 write() To App by intercepted receive system call Sh State for one socket • Create a new socket • Copy control state in checkpoint to socket structure • Restore checkpointed send buffer data using the socket write call • Deliver checkpointed receive buffer data to application on demand
  • 72. Existing Checkpointing mechanisms • CryoPID – http://cryopid.berlios.de/ • BLCR (Berkeley Lab Checkpoint/Restart) – https://ftg.lbl.gov/projects/CheckpointRestart/ • DMTCP – http://dmtcp.sourceforge.net/
  • 73. Implementation Considerations • Checkpointing can be implemented in – kernel modifications + helpers in userspace – pure userspace • Introduce a virtualization layer groups processes into specific states with private virtual name space – Intercepts system calls to expose only virtual identifiers (e.g., vpid) – Preserves resource names and dependencies across migration • Mechanism to checkpoint and restart states – User and kernel-level state – Primarily uses system call handlers – File system not saved or restored
  • 74. DMTCP • Distributed Multi-Threaded CheckPointing. • Works with Linux Kernel 2.6.9 and later. • Supports sequential and multi-threaded computations across single/multiple hosts. • Entirely in user space (no kernel modules or root privilege). – Transparent (no recompiling, no re-linking). • Developed in Northeastern University and MIT and under active development since 2006. • License: GNU LGPL (allows freely using and linking)
  • 75. Process Structure CT = DMTCP checkpoint thread T = User Thread DMTCP Coordinator CTCT T1T1 T2 Signal (USR2) Network Socket Process 1 Process N dmtcp_checkpoint <EXE> # starts coordinator dmtcp_command –c # talks to coordinator dmtcp_restart ckpt_<EXE>-*.dmtcp • Coordinator: a stateless synchronization server for the distributed checkpointing algorithm. • Checkpoint/Restart performance related to size of memory, disk write speed, and synchronization.
  • 76. How DMTCP works (1/4) • MTCP : component for checkpoint single-process • SIGUSR2: Used internally from checkpoint thread to user threads. CT T1 T2 User program Checkpoint thread 1. CT sends SIGUSR2 to each threads for suspending 2. Write checkpoint image to disk 3. Exit SIGUSR2 handler, and resume.
  • 77. How DMTCP works (2/4) • LD_PRELOAD: Transparently preloads checkpoint libraries `dmtcphijack.so` which installs libc wrappers and checkpointing code. • Wrappers: Only on less heavily used calls to libc – open, fork, exec, system, pipe, bind, listen, setsockopt, connect, accept, clone, close, ptsname, openlog, closelog, signal, sigaction, sigvec, sigblock, sigsetmask, sigprocmask, rt_sigprocmask, pthread_sigmask – Overhead is negligible. ... fd = open(path, flags); ... User Program int open(const char *path, int flags){ ... funcs[_open](path, flags); ... } dmtcphijack.so int open(const char *path, int flags){ ... } libc.so
  • 78. How DMTCP works (3/4) • Additional wrappers when process id & thread id virtualization is enabled – getpid, getppid, gettid, tcgetpgrp, tcsetprgrp, getgrp, setpgrp, getsid, setsid, kill, tkill, tgkill, wait, waitpid, waitid, wait3, wait4 ... pid = getpid(); ... User Program int getpid(){ ... real_pid = funcs[_getpid](); return pid_table[real_pid]; } dmtcphijack.so int getpid(){ ... } libc.so
  • 79. How DMTCP works (4/4) • Checkpoint image compression on-the-fly (default). • Currently only supports dynamically linking to libc.so. Support for static libc.a is feasible, but not implemented.
  • 80. Checkpoint under DMTCP(1/7) • dmtcphijack.so and libmtcp.so present in executable’s memory. – dmtcp_checkpoint <EXE> CT T1 T2 Coordinator User program Connect to exist coordinator or create a new coordinator CT T1 T2 User program
  • 81. Checkpoint under DMTCP(2/7) • Ask coordinator process for checkpoint via dmtcp_command. – dmtcp_command -c • DMTCP also provides API to send command or query status CT T1 T2 Coordinator User program command Send checkpoint command CT T1 T2 User program
  • 82. Checkpoint under DMTCP(3/7) • Suspend user threads with SIGUSR2. CT T1 T2 Coordinator User program 1. send command for prepare checkpoint 2. CT sends SIGUSR2 to each threads for suspending CT T1 T2 User program
  • 83. Checkpoint under DMTCP(4/7) • Pre-checkpoint stage • Synchronize every node and elect shared file descriptor leaders. • Drain kernel buffers and do network handshake with peers. CT T1 T2 Coordinator User program 2. Drain buffers CT T1 T2 User program Wait until all nodes are ready. 1. Report all thread except CT are suspended
  • 84. Checkpoint under DMTCP(5/7) • Write checkpoint to disk – One checkpoint file per process – ckpt_<EXE>_<uid>.dmtcp CT T1 T2 Coordinator User program Write checkpoint to disk separately CT T1 T2 User program Wait until all nodes of checkpoint are done
  • 85. Checkpoint under DMTCP(6/7) • Post-Checkpint stage • Refill kernel buffers CT T1 T2 Coordinator User program Refill buffer and re-handshake with peers. CT T1 T2 User program Wait until all nodes of post-checkpoint are done
  • 86. Checkpoint under DMTCP(7/7) • Resume user threads. CT T1 T2 Coordinator User program Resume! CT T1 T2 User program Send resume command
  • 87. Restart under DMTCP(1/6) • Restart Process loads in memory. – dmtcp_restart ckpt_<EXE>_<uid>.dmtcp CT Coordinator dmtcp_restart 1. Connect to exist coordinator or create a new coordinator 2. Load process to memory
  • 88. Restart under DMTCP(2/6) • Fork user program CT Coordinator dmtcp_restart CT dmtcp_restart
  • 89. Restart under DMTCP(3/6) • Reopen files and recreate ptys • Recreate and reconnect sockets • Rearrange file descriptors to initial layout CT Coordinator dmtcp_restart Wail all node recreate socket and reopen file 1. Reopen file/ptys/sockets CT dmtcp_restart 2. Rearrange FD via dup2
  • 90. Restart under DMTCP(4/6) • Restore memory content. • Restore stack status for checkpoint thread. CT Coordinator dmtcp_restart CT dmtcp_restart CT Coordinator CT User programUser program dmtcp_restart mtcp_restart User program execve mmap + magic!! FDs will preserved across execve!
  • 91. Restart under DMTCP(5/6) • Restore other threads. – Recreate thread and restore stack and context. – Restore back to the post-checkpint stage • Refill kernel buffer CT Coordinator Wail all nodes restoring are done 1. Memory and thread come back now! CT T1 T2T1 T2 User programUser program 2. Refill buffers
  • 92. Restart under DMTCP(6/6) • Resume user threads CT Coordinator Resume!CT T1 T2T1 T2 User programUser program <user_func1> <user_func2> <user_funcN> ... <sig-handler> stopthisthread Thread Call Stack ... while (mtcp_state_value(&thread -> state) == ST_SUSPENDED) { mtcp_state_futex (&(thread -> state), FUTEX_WAIT, ST_SUSPENDED, NULL); } ...
  • 93. DMTCP Workflow Start with dmtcp wrapper Run Pre-Checkpoint Checkpoint Post-Checkpoint Restart Re-open FDs Restore memory Restore threads Provide hook point! Get checkpoint command
  • 94. OS Features supported by DMTCP • Threads, mutexes/semaphores, fork, exec • Shared memory (via mmap), TCP/IP sockets, UNIX domain sockets, pipes, ptys, terminal modes, ownership of controlling terminals, signal handlers, open and/or shared fds, I/O (including the readline library), parent-child process relationships, process id & thread id virtualization, session and process group ids, and more…
  • 95. DMTCP/Android: Additional Features (LGPL; separated from Android) • ARM Architecture support – Verified on Samsung Galaxy S2 + Android 4.0 • Binder IPC – Client: supported – Server: partially supported • Ashmem: supported • Logger: supported • Properties: supported • Wakelocks: Not supported Already merged in upstream DMTCP
  • 96. Android Binder support for DMTCP • BinderConnection – Reopen /dev/binder and reset ioctl parameters – Restore the mmap region • Hijack the whole libbinder – Prevent libbinder from interpreting data twice – Implement necessary DMTCP hooks: preCheckpoint, postCheckpoint, postRestart • Re-initialize libbinder in postRestart • The server part is partially supported because binder server is calling a blocked ioctl and blocking the whole checkpoint process. – We implement an early checkpoint stage to suspend such kind of threads.
  • 97. More extensions in DMTCP/Android • Improve the hook system in DMTCP – Original design only allows one set hook function. – Allow more than one set hook function in DMTCP/Android. • Implement per thread callback hook – Restore the DVM internal thread info • Add barrier and synchronize mechanisms to DMTCP – In order to make precise program checkpointing.
  • 98. Android specific modifications • Reorder code in framework – registerZygoteSocket() • The socket is inherited from the parent process `init`, which implies we can not handle it in DMTCP. – Move few initializations later than the checkpoint process since the current binder support is incomplete. • Reserve the ashmem's file descriptor – Original behavior is to close the fd after mmap – DMTCP binds connection to one fd, so the connection will be destroyed if that fd is closed. • Implement the missing PThread function in bionic libc – pthread_tryjoin_np is required by DMTCP, but it s not implemented in original bionic.
  • 99. Technical Issues when modifying DMTCP• ARM Architecture support is incomplete. • Different TLS implementation semantics between glibc and bionic libc – DMTCP/Android follows the techniques used in Android´s OpenGL ES package which links and defers to the slot of TLS in bionic libc. Not elegant, but it works • PThread implementation expectation is quite different – AOSP master branch is merging libc from NetBSD, so it should be better for compatibility. • Behavior of dynamic linker differs a lot in bionic libc. • Flags in dlopen() is not really functional. • The way to find symbol in bionic libc differs: weak symbol
  • 100. Checkpoint for Zygote • Experiment environment: – Android on ARM Cortex-A9 dual (1GHz; Memory: 512 MB) with gzip without gzip Checkpoint time ~8s ~4.5s Restart time ~0.3s ~0.1s Image size ~3M ~17M
  • 101. --------- beginning of /dev/log/system I/Vold ( 1270): Vold 2.1 (the revenge) firing up D/Vold ( 1270): Volume usb state changing -1 (Initializing) -> 0 (No-Media) I/Netd ( 1271): Netd 1.0 starting I/ ( 1275): ServiceManager: 0x8062b50 I/ ( 1276): ServiceManager: 0x804fb98 I/AudioFlinger( 1276): Loaded primary audio interface from LEGACY Audio HW HAL (audio) I/AudioFlinger( 1276): Using 'LEGACY Audio HW HAL' (audio.primary) as the primary audio interface ... D/AudioHardware( 1276): ### setVoiceVolume: 1.000000 I/AudioPolicyService( 1276): [1276]Loaded audio policy from LEGACY Audio Policy HAL (audio_policy) E/BatteryService( 1382): usbOnlinePath not found D/AndroidRuntime( 1902): D/AndroidRuntime( 1902): >>>>>> AndroidRuntime START com.android.internal.os.ZygoteInit <<<<<< D/AndroidRuntime( 1902): CheckJNI is ON I/SamplingProfilerIntegration( 1902): Profiling disabled. I/Zygote ( 1902): Preloading classes... D/dalvikvm( 1902): GC_EXPLICIT freed 35K, 85% free 399K/2560K, paused 0ms+0ms ... I/Zygote ( 1902): ...preloaded 379 resources in 548ms. D/dalvikvm( 1902): GC_EXPLICIT freed 20K, 1% free 6417K/6467K, paused 0ms+0ms I/Zygote ( 1902): ...preloaded 31 resources in 13ms. D/dalvikvm( 1902): GC_EXPLICIT freed 14K, 1% free 6418K/6467K, paused 0ms+0ms D/dalvikvm( 1902): GC_EXPLICIT freed 5K, 1% free 6412K/6467K, paused 0ms+0ms D/dalvikvm( 1902): GC_EXPLICIT freed <1K, 1% free 6412K/6467K, paused 0ms+2ms I/dalvikvm( 1902): System server process 1911 has been created --------- beginning of /dev/log/system I/Vold ( 1270): Vold 2.1 (the revenge) firing up D/Vold ( 1270): Volume usb state changing -1 (Initializing) -> 0 (No-Media) I/Netd ( 1271): Netd 1.0 starting I/ ( 1275): ServiceManager: 0x8062b50 I/ ( 1276): ServiceManager: 0x804fb98 I/AudioFlinger( 1276): Loaded primary audio interface from LEGACY Audio HW I/AudioFlinger( 1276): Using 'LEGACY Audio HW HAL' (audio.primary) as the …. D/AudioHardware( 1276): ### setVoiceVolume: 1.000000 I/AudioPolicyService( 1276): [1276]Loaded audio policy from LEGACY Audio P D/dalvikvm( 1373): GC_EXPLICIT freed 14K, 1% free 6418K/6467K, paused 0 D/dalvikvm( 1373): GC_EXPLICIT freed 5K, 1% free 6412K/6467K, paused 0m D/dalvikvm( 1373): GC_EXPLICIT freed <1K, 1% free 6412K/6467K, paused 0 I/dalvikvm( 1373): System server process 1382 has been created Normal bootup log message Bootup log message with restart Observations from logcat
  • 103. Mixed Model: Hibernation + Checkpointing • Basic Idea – Swap out dirty-pages before save image – Reducing image size leads to faster resume time – Only the “static” working set is suspended, other parts utilizes checkpointing – Room for keeping __broken__ device drivers • However, the state machine is relatively intricate because of application framework awareness.
  • 104. Technical Challenges of Mixed Model • Have to modify Android/Tizen framework in order to figure the proper checkpoint to perform. – It is not straightforward since recent application frameworks depend on web rendering engine as the core component. – Working-set is hard to be minimized accordingly. • Separate the device initializations into two areas: – essential zone: taken for Hibernation – post-resuming: used for checkpointing, firmware management, and connectivity → problem of maintenance • Storage access time is crucial since we touch for several times – I/O scheduler modifications are under investigation
  • 105. Timing diagram of Hibernation stage (when request speed > response speed, it means I/O operations are busy)
  • 106. Time diagram of Device Resuming
  • 107. Conclusion • No silver bullet for device boot time optimizations • Developing an intrusive technique for Android or complex Linux systems is possible for design aspects • The quality of device driver and file system causes essential impacts as well no matter how a new technique is introduced. • Mixed model can be used for the production of dedicated systems such as digital TV and automotive IVI.
  • 108. Reference • Embedded Linux Wiki: http://elinux.org/Boot_Time • “DMTCP: An New Linux Checkpointing Mechanism for Vanilla Universe Job”, Condor Project, University of Wisconsin-Madison • “Checkpointing using DMTCP, Condor, Matlab and FReD”, Gene Cooperman, Northeastern University, Boston • “Boot Time Optimizations”, Alexandre Belloni, ELCE 2012 • “Extending the swsusp Hibernation Framework to ARM”, Russell Dill, ELC 2013