Boosting up Embedded Linux Device: Experience on Linux-Based Smartphone
Total Page:16
File Type:pdf, Size:1020Kb
Boosting up Embedded Linux device: experience on Linux-based Smartphone Kunhoon Baik Saena Kim Samsung Electronics Co., Ltd. Samsung Electronics Co., Ltd. [email protected] [email protected] Suchang Woo Jinhee Choi Samsung Electronics Co., Ltd. Samsung Electronics Co., Ltd. [email protected] [email protected] Abstract infrastructure because it is implemented in the kernel. Therefore, there is little effort required, even when the Modern smartphones have extensive capabilities and target hardware is changed. We prototyped our quick connectivities, comparable to those of personal com- boot solution using a S5PC110[17]-based smartphone. puters (PCs). As the number of smartphone features The results of our experiments indicate that we can ob- increases, smartphone boot time also increases, since tain get dramatic gain in performance in a practical man- all features must be initialized during the boot time. ner using this quick boot solution. Many fast boot techniques have focused on optimizing the booting sequence. However, it is difficult to obtain 1 Introduction quick boot time (under 5 seconds) using the fast boot techniques, and many parts of the software platform re- Smartphones generally require long boot times. As the quire additional optimization. An intuitive way to obtain number of smartphone functions increases, the initial- instant boot times, while avoiding these issues, is to boot ization times required for the corresponding software directly from hibernation. We apply hibernation-based modules also increase. In addition, as smartphones are techniques to a Linux-based smartphone, and thereby equipped with more and more peripheral devices such overcome two major obstacles: long loading times for as sensors, cameras, Bluetooth and WiFi, these devices snapshot image and maintenance costs related to hard- require their own initialization times, which further in- ware change. creases boot time. We propose two mechanisms, based on hibernation, to To obtain instant boot times, "boot optimization" or obtain outstanding reductions in boot time. First, min- "hibernation-based boot" techniques can be used. In the imize the size of snapshot image via page reclamation, case of "boot optimization", each module must be opti- which reduces the load time of image. Snapshot is split mized and the initialization flow must be modified after into two major segments: essential-snapshot-image and a profiling step. This can be difficult to accomplish if supplementary-snapshot-image. The essential snapshot there are many software modules involved, or if the ini- image is a minimally-sized image used to run the Linux tialization process is complex. However, in the case of kernel and idle screen, and the supplementary-snapshot- "hibernation-based boot" techniques, we can obtain in- image contains the remained that could be restored on stant boot times quite easily. In this paper, we apply demand. Second, we add additional device information hibernation-based fast boot techniques to a Linux-based to the essential-snapshot-image, which is used when the smartphone. the device is reactivated upon booting up. As a result, our mechanism omits some time-consuming jobs related There remain some barriers to applying hibernation- to device re-initialization and software state recovery. In based boot techniques. addition to quick boot times, our solution is low main- tenance. That is, while the snapshot boot[3] is imple- 1. Mobile software platforms, such as Android[14], mented in the bootloader, our solution utilizes the kernel hold about 100MB of RAM capacity, but Flash • 9 • 10 • Boosting up Embedded Linux device: experience on Linux-based Smartphone memory offers only poor I/O speed. If the read an important issue. However, boot time has become an performance is 20MB/s, then snapshot image alone important feature as more and more embedded systems require loading time of about 5 seconds. There- are adopting Linux due to benefits such as low cost and fore, we cannot obtain instant boot times via the the ability to be utilized across a variety of hardware hibernation-based boot technique alone. platorms. 2. Because swsusp’s the device reactivation flow Boot time optimization techniques include profiling, re- in the standard Linux kernel was developed for duction and optimizing techniques. These techniques generic purposes1, it has some additional steps to were well summarized by the Bootup Time Working reactivate devices. The snapshot boot technique Group of the CE Linux Forum[5]. This section intro- eliminates these steps by restoring snapshot image duces some of these techniques, which can be used with in the bootloader, but also requires additional im- our approach. plementations in the bootloader. At the bootloader level, uncompressed kernel[6] or fast 3. If the same snapshot image is used every time the kernel decompression[7] techniques can be used. In the device boots up, information inconsistency prob- case of uncompressed kernel techniques, the kernel im- lems will occur in the file system and database. age loading time is longer but decompression time is not required. Fast kernel decompression improves ker- nel decompression performance using fast decompress In this paper, we introduce new methods to obtain in- mechanisms such as UCL[18] stant boot times by solving these issues. We focus on the following two methods. The first method opti- At the kernel level, disable console[8], preset loops mizes the size of snapshot image to be less than 15MB per jiffy(LPJ)[9] and deferred initcalls[10] techniques without compression, to reduce snapshot image loading may be used. The disable console technique mini- time. The second method improves the device reactiva- mizes kernel printk messages during boot time to re- tion flow to obtain similar performance to the snapshot duce serial console accessing time. The preset LPJ boot technique, without tinkering with the bootloader. uses a constant delay value instead of the calibrate_ We also briefly discuss related issues such as informa- delay() function that is commonly used for calibrat- tion inconsistency problems. ing delay time in the kernel. The deferred initcalls tech- nique forces some initcalls to run later if they do not This paper is organized as follows. In section 2, we need to be initialized early. summarize fast boot techniques already developed in Embedded Linux systems, and compare them with our Hibernation-based techniques also reduce boot time. approach. In section 3, we analyze smartphone boot Hibernation is a feature used for power management in times and investigate points where improvements can Linux. As a power saving mode, hibernation backs up be made. In section 4, we introduce our approach, the running state of the system into the disk space as a which optimizes snapshot image loading times with on- snapshot image, and powers down the system. When the demand-paging and early device reactivation. Section power comes back up, the system is restored to the run- 5 describes the experimental environment and provides ning state based on the snapshot image. Hibernation can experimental results. Finally, in sections 6 and 7, we be implemented by several techniques. Among these, suggest directions for future work and summarize the the most common techniques are the swsusp technique paper. that is included in the standard Linux kernel, and the TuxOnIce(suspend2)[11] technique that is provided as a patch of the kernel. The fundamentals are almost the 2 Related studies same in these two techniques, but TuxOnIce offers more useful options compared to swsusp. However, the Tux- Until recently, Linux development has focused on the OnIce patch requires many changes for the kernel, and desktop and server markets, in which boot time is not therefore also incurs additional maintenance costs ac- cording to the kernel revision. The snapshot boot tech- 1swsusp (Software Suspend) is a suspend-to-disk implementa- tion in the 2.6 series Linux kernel. It is the Linux equivalent of nique is a fast boot technique based on swsusp. In this Windows hibernate functionality. technique, every time a device boots up, the snapshot 2010 Linux Symposium • 11 Figure 1: Bootchart – normal boot sequence of the smartphone used in this study image is loaded in the bootloader instead of the original than 5 seconds by optimizing the boot sequence. Even kernel image. Device initialization tasks are also per- if we implement hibernation-based fast boot techniques, formed at the bootloader level to improve the device re- we cannot achieve 5 second boot times due to the barri- activation flow in swsusp. However, most of the changes ers described in section 1. in the bootloader are heavily dependent on hardware, and for this reason, the associated maintenance costs To solve these problems, we must analyze each el- are increased due to required changes of hardware de- ement of hibernation-based boot time. We calculate sign. This shortcoming makes the application of snap- hibernation-based boot time(tb) using the following for- shot boot techniques less practical. Even if the snapshot mula. boot technique is applied to a system, instant boot may not be achieved without further optimizing the size of t = t +t + t the snapshot image. Recent smartphones require more b p l ∑ r memory space than older models, because of their ex- tensive functionalities, and for this reason optimizing tp includes the block device setup time for loading snap- snapshot image must be considered a necessity. In a pre- shot image and the cpu/clock/timer/power setup times vious case study examining the use of the snapshot boot for minimal operation. These constitute the necessary technique for digital TV systems[4] many parts of the initialization events for booting from hibernation, and software platform were modified to minimize the size therefore the time required for these steps cannot be re- of the snapshot image. However, such an approach in- duced. tl is the time required to load the image from creases maintenance costs due to the necessity of hard- disk to the original memory location, and tr is the time ware and software platform revisions.