skip to main content
article

Automated reduction of the memory footprint of the Linux kernel

Published:01 September 2007Publication History
Skip Abstract Section

Abstract

The limited built-in configurability of Linux can lead to expensive code size overhead when it is used in the embedded market. To overcome this problem, we propose the application of link-time compaction and specialization techniques that exploit the a priori known, fixed runtime environment of many embedded systems. In experimental setups based on the ARM XScale and i386 platforms, the proposed techniques are able to reduce the kernel memory footprint with over 16%. We also show how relatively simple additions to existing binary rewriters can implement the proposed techniques for a complex, very unconventional program, such as the Linux kernel. We note that even after specialization, a lot of seemingly unnecessary code remains in the kernel and propose to reduce the footprint of this code by applying code-compression techniques. This technique, combined with the previous ones, reduces the memory footprint with over 23% for the i386 platform and 28% for the ARM platform. Finally, we pinpoint an important code size growth problem when compaction and compression techniques are combined on the ARM platform.

References

  1. Anckaert, B., Vandeputte, F., De Bus, B., De Sutter, B., and De Bosschere, K. 2004. Link-time optimization of IA64 binaries. In Proceedings of the 2004 Euro-Par Conference. 284--291.Google ScholarGoogle ScholarCross RefCross Ref
  2. Bhatia, S., Consel, C., and Pu, C. 2004. Remote customization of systems code for embedded devices. In EMSOFT '04: Proceedings of the 4th ACM international conference on Embedded software. ACM Press, New York. 7--15. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Chanet, D., De Sutter, B., De Bus, B., Van Put, L., and De Bosschere, K. 2005. System-wide compaction and specialization of the Linux kernel. In Proc. of the 2005 ACM SIGPLAN/SIGBED Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES). 95--104. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Citron, D., Haber, G., and Levin, R. 2004. Reducing program image size by extracting frozen code and data. In EMSOFT '04: Proceedings of the 4th ACM international conference on Embedded software. ACM Press, New York. 297--305. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Clausen, L., Schultz, U., Consel, C., and Muller, G. 2000. Java bytecode compression for low-end embedded systems. ACM Transactions on Programming Languages and Systems 22, 3 (May), 471--489. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Cohn, R., Goodwin, D., Lowney, P., and Rubin, N. 1997. Spike: An optimizer for Alpha/NT executables. In Proceedings of the USENIX Windows NT Workshop. 17--24. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Corliss, M., Lewis, E., and Roth, A. 2003. A DISE implementation of dynamic code decompression. In Proceedings of the ACM SIGPLAN 2003 Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES'03). 232--243. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Cours, J., Navarro, N., and Hwu, W. 2004. Using coverage-based analysis to automate the customization of the Linux kernel for embedded applications. M.S. thesis, University of Illinois at Urbana-Champaign.Google ScholarGoogle Scholar
  9. De Bus, B. 2005. Reliable, retargetable and extensible link-time program rewriting. Ph.D. thesis, Ghent University.Google ScholarGoogle Scholar
  10. De Bus, B., Kästner, D., Chanet, D., Van Put, L., and De Sutter, B. 2003. Post-pass compaction techniques. Communications of the ACM 46, 8 (Aug.), 41--46. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. De Bus, B., De Sutter, B., Van Put, L., Chanet, D., and De Bosschere, K. 2004. Link-time optimization of ARM binaries. In Proc. of the 2004 ACM SIGPLAN/SIGBED Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES). 211--220. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. De Sutter, B., De Bus, B., De Bosschere, K., and Debray, S. 2001. Combining global code and data compaction. In Proc. of the ACM SIGPLAN Workshop on Languages, Compilers, and Tools for Embedded Systems. 29--38. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. De Sutter, B., De Bus, B., and De Bosschere, K. 2002. Sifting out the mud: low level C++ code reuse. In Proceedings of the 17th ACM SIGPLAN conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA). 275--291. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. De Sutter, B., De Bus, B., and De Bosschere, K. 2005. Link-time binary rewriting techniques for program compaction. ACM Transactions on Programming Languages and Systems 27, 5 (9), 882--945. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. De Sutter, B., Van Put, L., Chanet, D., De Bus, B., and De Bosschere, K. 2006. Link-time compaction and optimization of ARM executables. ACM Transactions on Embedded Computing Systems. To appear. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Debray, S., Muth, R., and Weippert, M. 1998. Alias analysis of executable code. In Proceedings of the ACM 1998 Symposium on Principles of Programming Languages (POPL'98). 12--24. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Debray, S. and Evans, W. 2002. Profile-guided code compression. In PLDI '02: Proceedings of the ACM SIGPLAN 2002 Conference on Programming language design and implementation. ACM Press, New York. 95--105. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Debray, S., Evans, W., Muth, R., and De Sutter, B. 2002. Compiler techniques for code compaction. ACM Transactions on Programming Languages and Systems 22, 2 (3), 378--415. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Denys, G., Piessens, F., and Matthijs, F. 2002. A survey of customizability in operating systems research. ACM Comput. Surv. 34, 4, 450--468. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Ernst, J., Evans, W., Fraser, C., Lucco, S., and Proebsting, T. 1997. Code compression. In Proceedings of the 1997 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI'97). 358--365. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Evans, W. S. and Fraser, C. W. 2001. Bytecode compression via profiled grammar rewriting. In PLDI '01: Proceedings of the ACM SIGPLAN 2001 conference on Programming language design and implementation. ACM Press, New York. 148--155. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Fassino, J.-P., Stefani, J.-B., Lawall, J. L., and Muller, G. 2002. Think: A software framework for component-based operating system kernels. In Proceedings of the General Track: 2002 USENIX Annual Technical Conference. USENIX Association, Berkeley, CA. 73--86. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Flower, R., Luk, C.-K., Muth, R., Patil, H., Shakshober, J., Cohn, R., and Lowney, G. 2001. Kernel optimizations and prefetch with the spike executable optimizer. In Proc of the 4th Workshop on Feedback-Directed and Dynamic Optimization (FDDO-4).Google ScholarGoogle Scholar
  24. Ford, B., Back, G., Benson, G., Lepreau, J., Lin, A., and Shivers, O. 1997. The flux oskit: a substrate for kernel and language research. In SOSP '97: Proceedings of the 16th ACM symposium on Operating systems principles. ACM Press, New York. 38--51. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Franz, M. 1997. Adaptive compression of syntax trees and iterative dynamic code optimization: Two basic technologies for mobile-object systems. In Mobile Object Systems: Towards the Programmable Internet, J. Vitek and C. Tschudin, Eds. Number 1222 in LNCS. Springer, New York. 263--276. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Franz, M. and Kistler, T. 1997. Slim binaries. Communications of the ACM 40, 12 (Dec.), 87--94. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Fraser, C. 1999. Automatic inference of models for statistical code compression. In Proceedings of the ACM SIGPLAN 1999 Conference on Programming Language Design and Implementation (PLDI'99). 242--246. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Gay, D., Levis, P., von Behren, R., Welsh, M., Brewer, E., and Culler, D. 2003. The nesC language: A holistic approach to networked embedded systems. In PLDI '03: Proceedings of the ACM SIGPLAN 2003 conference on Programming language design and implementation. ACM Press, New York. 1--11. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Hind, M. 2001. Pointer analysis: Haven't we solved this problem yet? In 2001 ACM SIGPLAN-SIGSOFT Workshop on Program Analysis for Software Tools and Engineering (PASTE'01). Snowbird, UT. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Kemp, T. M., Montoye, R. M., Harper, J. D., Palmer, J. D., and Auerbach, D. J. 1998. A decompression core for PowerPC. IBM J. Research and Development 42, 6 (Nov.). Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Kirovski, D., Kin, J., and Mangione-Smith, W. H. 1997. Procedure based program compression. In Proceedings of the 30th Annual International Symposium on Microarchitecture (MICRO-30). Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Krintz, C. and Wolski, R. 2005. Using phase behavior in scientific application to guide Linux operating system customization. In IPDPS '05: Proceedings of the 19th IEEE International Parallel and Distributed Processing Symposium (IPDPS'05)---Workshop 10. IEEE Computer Society, Washington, DC. 219.1. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Lee, C.-T., Lin, J.-M., Hong, Z.-W., and Lee, W.-T. 2004. An application-oriented Linux kernel customization for embedded systems. Journal of Information Science and Engineering 20, 6, 1093--1107.Google ScholarGoogle Scholar
  34. Lekatsas, H., Henkel, J., Chakradhar, S., Jakkula, V., and Sankaradass, M. 2003. Coco: a hardware/software platform for rapid prototyping of code compression technologies. In Proceedings of the 40th conference on Design Automation (DAC). 306--311. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Levine, J. 2000. Linkers & Loaders. Morgan Kaufmann, San Matco, CA.Google ScholarGoogle Scholar
  36. Linn, C., Debray, S., Andrews, G., and Schwarz, B. 2004. Stack analysis of x86 executables. Available from http://www.cs.arizona.edu/people/debray.Google ScholarGoogle Scholar
  37. Madou, M., De Sutter, B., De Bus, B., Van Put, L., and De Bosschere, K. 2004. Link-time optimization of MIPS programs. In Proceedings of the 2004 International Conference on Embedded Systems and Applications (ESA'04).Google ScholarGoogle Scholar
  38. McNamee, D., Walpole, J., Pu, C., Cowan, C., Krasic, C., Goel, A., Wagle, P., Consel, C., Muller, G., and Marlet, R. 2001. Specialization tools and techniques for systematic optimization of system software. ACM Trans. Comput. Syst. 19, 2, 217--251. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. McVoy, L. and Staelin, C. 1996. lmbench: Portable tools for performance analysis. In USENIX Annual Technical Conference. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Muchnick, S. S. 1997. Advanced Compiler Design & Implementation. Morgan Kaufmann, San Matco, CA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Muth, R., Debray, S., Watterson, S., and De Bosschere, K. 2001. Alto: a link-time optimizer for the Compaq Alpha. Software---Practice and Experience 31, 1, 67--101. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Proebsting, T. 1995. Optimizing an ANSI C interpreter with superoperators. In Proceedings of the ACM SIGPLAN-SIGACT 1995 Symposium on Principles of Programming Languages (POPL'95). 322--332. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Pugh, W. 1999. Compressing Java class files. In Proceedings of the 1999 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI'99). 247--258. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Ros, M. and Sutton, P. 2003. Compiler optimization and ordering effects on VLIW code compression. In Proceedings of the 2003 International Conference on Compilers, Architectures and Synthesis for Embedded Systems (CASES). 95--103. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Schmidt, W., Roediger, R., Mestad, C., Mendelson, B., Shavit-Lottem, I., and Bortnikov-Sitnitsky, V. 1998. Profile-directed restructuring of operating system code. IBM Systems Journal 37, 2. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Schwarz, B., Debray, S., Andrews, G., and Legendre, M. 2001. PLTO: A link-time optimizer for the Intel IA-32 architecture. In Proc. 2001 Workshop on Binary Rewriting (WBT-2001).Google ScholarGoogle Scholar
  47. Speer, S. E., Kumar, R., and Partridge, C. 1994. Improving UNIX kernel performance using profile based optimization. In 1994 Winter USENIX. 181--188. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Srivastava, A. and Wall, D. 1994. Link-time optimization of address calculation on a 64-bit architecture. In Proc. of the 1994 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). 49--60. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Tamches, A. and Miller, B. P. 1999. Fine-grained dynamic instrumentation of commodity operating system kernels. In Operating Systems Design and Implementation. 117--130. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. Tamches, A. and Miller, B. P. 2001. Dynamic kernel code optimization. In Workshop on Binary Translation (WBT-2001).Google ScholarGoogle Scholar
  51. TriMedia Technologies Inc. 2000. TriMedia32 Architecture. TriMedia Technologies Inc.Google ScholarGoogle Scholar

Index Terms

  1. Automated reduction of the memory footprint of the Linux kernel

        Recommendations

        Reviews

        Olivier Louis Marie Lecarme

        Nowadays, when one gigabyte (GB) of memory storage is considered much too small, one would be surprised to know that it is important to reduce the size of a program when it reaches about one megabyte (MB). To an old computer scientist, this may recall the times when a full operating system resident part would need no more than 100 kilobytes (KB). When using a monolithic kernel like Linux on an embedded platform with 64 MB of storage, it is important to reduce the memory footprint of the kernel as much as possible, even if this slightly reduces performance. Instead of trying to customize the kernel source code, or to parametrize it at compile time, Chanet et al. want to be able to automate the compaction techniques in order to operate at link time. Because of the very special nature of a kernel, they have to employ various techniques: eliminating unused system call handlers; specializing system calls in order to use available optimization techniques; specializing boot time parameters; moving initializing code to the part freed after initialization time; and compressing unexecuted code that could be called in abnormal situations only. They have to take into account several kernel code peculiarities, such as memory-mapped input/output (MMIO) or very low-level special instruction sequences, as well as multithreading. All these techniques are assessed separately, and their effect is clearly evaluated. The detailed results are significantly different on a CISC processor (x86) and a RISC one (ARM), but the overall footprint reduction is 23.3 percent on the first one, and 28.0 percent on the second one. I wonder whether using Hurd’s idea of a nonmonolithic kernel would avoid all this work. However, this 25-page paper makes a very interesting read, from cover to cover. Online Computing Reviews Service

        Access critical reviews of Computing literature here

        Become a reviewer for Computing Reviews.

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader