Multiple Page Size Support in the Linux Kernel

Multiple Page Size Support in the Linux Kernel

Multiple Page Size Support in the Linux Kernel Simon Winwood ‡§ Yefim Shuf ‡¶ §School of Computer Science and Engineering ¶Computer Science Department University of New South Wales Princeton University Sydney 2052, Australia Princeton, NJ 08544, USA [email protected] [email protected] Hubertus Franke ‡ ‡IBM T.J. Watson Research Center P.O. Box 218 Yorktown Heights, NY 10598, USA {swinwoo, yefim, frankeh}@us.ibm.com Abstract 1 Introduction To achieve high performance, many processors The Linux kernel currently supports a single supporting virtual memory implement a Trans- user space page size, usually the minimum dic- lation Lookaside Buffer (TLB) [8]. A TLB is tated by the architecture. This paper describes a small hardware cache for maintaining virtual the ongoing modifications to the Linux kernel to physical translation information for recently to allow applications to vary the size of pages referenced pages. During execution of any in- used to map their address spaces and to reap the struction, a translation from virtual to physical performance benefits associated with the use of addresses needs to be performed at least once. large pages. Thereby, a TLB is effectively reducing the cost The results from our implementation of mul- of obtaining translation information from page tiple page size support in the Linux kernel tables stored in memory. are very encouraging. Namely, we find that Programs with good spatial and temporal lo- the performance improvement of applications cality of reference achieve high TLB hit rates written in various modern programming lan- which contribute to higher application perfor- guages range from 10% to over 35%. The ob- mance. Because of long memory latencies, served performance improvements are consis- programs with poor locality can incur a notice- tent with those reported by other researchers. able performance hit due to low TLB utiliza- Considering that memory latencies continue to tion. Large working sets of many modern ap- grow and represent a barrier for achieving scal- plications and commercial middleware [12, 13] able performance on faster processors, we ar- make achieving high TLB hit rates a challeng- gue that multiple page size support is a neces- ing and important task. sary and important addition to the OS kernel and the Linux kernel in particular. Adding more entries to a TLB to increase its Ottawa Linux Symposium 2002 574 coverage and increasing the associativity of a The rest of the paper is organized as follows. TLB to reach higher TLB hit rates is not al- In Section 2, we present an overview of the ways feasible as large and complex TLBs make Linux virtual memory subsystem. We de- it difficult to attain short processor cycle times. scribe the design and implementation of mul- A short TLB latency is a critical requirement tiple page size support in the Linux kernel in for many modern processors with fast physi- Section 3 and Section 4 respectively. Experi- cally tagged caches, in which translation infor- mental results obtained from the implementa- mation (i.e., a physical page associated with a tion are presented and analyzed in Section 5. TLB entry) needs to be available to perform Related work is discussed in Section 6. Fi- cache tag checking [8]. Therefore, many pro- nally, we summarize the results of our work cessors achieve wider TLB coverage by sup- and present some ideas for future work in Sec- porting large pages. Traditionally, operating tion 7. systems did not expose large pages to appli- cation software, limiting this support to the kernel. Growing working sets of applications 2 The Virtual Memory Subsystem make it appealing to support large pages for ap- in Linux plications, as well as for the kernel itself. A key challenge for this work was to provide In this section, we give a brief overview of the 2 efficient support for multiple page sizes with Linux Virtual Memory (VM) subsystem . Un- only minor changes to the kernel. This paper less otherwise noted, this section refers to the discusses ongoing research to support multiple 2.4 series of kernels after version 2.4.18. page sizes in the context of the Linux operating system, and makes the following contributions: 2.1 Address space data structures • it describes the changes necessary to sup- Each address space is defined by a 3 port multiple page sizes in the Linux ker- mm_struct data structure . The nel; mm_struct contains information about the address space, including a list of Virtual • it presents validation data demonstrating Memory Areas (VMAs), a pointer to the page the accuracy of our implementation and directory, and various locks and resource its ability to meet our design goals; and counters. • it illustrates non-trivial performance ben- A VMA contains information about a single re- efits of large pages (reaching more than gion of the address space. This includes: 35%) for Java applications and (reaching over 15%) for C and C++ applications • the address range the VMA is responsible from well-known benchmark suites. for; We have an implementation of multiple page • the access rights — read, write, and exe- size support for the IA-32 architecture and are cute — for that region; currently working on an implementation for 2 the PowerPC1 architecture. This section is meant to be neither exhaustive or complete. 1This is for the PPC405gp and PPC440 processors, 3Note that multiple tasks can share the same address both of which support multiple page sizes. space Ottawa Linux Symposium 2002 575 • the file, if any, which backs the region; 2.2 The page data structure and allocator and The page data structure represents a page of • any performance hints supplied by an physical memory, and contains the following application, such as memory access be- properties: haviour. • its usage count, which denotes whether it A VMA is also responsible for populating is in the page cache, if it has buffers as- the region at page fault time via its nopage sociated with it, and how many processes method. A VMA generally maps a virtual ad- are using it; dress range onto a region of a file, or zero filled (anonymous) memory. • its associated mapping, which indicates how a file is mapped onto its data, and its A VMA exists for each segment in a process’s offset; executable (e.g., its text and data segments), its stack, any dynamically linked libraries, and • its wait queue, which contains processes any other files the process may have mapped waiting on the page; and into its address space. All VMAs, except for those created when a process is initially loaded, • its various flags, most importantly: are created with the mmap system call4. The locked This flag is used to lock a page. mmap system call essentially checks that the When a page is locked, I/O is pend- process is allowed the desired access to the re- ing on the page, or the page is being quested file5 and sets up the VMA. examined by the swap subsystem. The page directory contains mappings from error This flag is used to communicate to virtual addresses to physical addresses. Linux the VM subsystem that an error oc- uses a three level hierarchical page table (PT), curred during I/O to the page. although in most cases the middle level is op- referenced This flag is used by the swap- timised out. Each leaf node entry in the PT, ping algorithm. It is set when a page called a page table entry (PTE), contains the is referenced, for example, when the address of the corresponding physical page, the page is accessed by the read sys- current protection attributes for that page6, and tem call, and when a PTE is found other page attributes such as whether the map- to be referenced during the page ta- ping is dirty, referenced, or valid. ble scan performed by the swapper. Figure 1 shows the relationship between the uptodate This flag is used by the page Virtual Address Space, the mm_struct, the cache to determine whether the VMAs, the Physical Address Space, and the page’s contents are valid. It is set af- page directory. ter the page is read in. 4This is not strictly true: the shmat system call is dirty This flag is used to determine also used to create VMAs. It is, however, essentially a whether the page’s contents has been wrapper for the mmap system call. modified. It is set when the page 5This check is trivial if the mapping is anonymous. 6The pages protection attributes may change over the is written to, either by an explicit life of the mapping due to copy-on-write and reference write system call, or through a counting store instruction. Ottawa Linux Symposium 2002 576 mm_struct Virtual Memory Area mmap Virtual Address Space pgd Page Directory Page Table Physical Address Space Figure 1: Virtual Address Space data structures lru This flag is used to indicate that the Each zone uses a buddy allocator to allocate page is in the LRU list. pages, so pages of different orders can be al- located. Although a client of the allocator re- active This flag is used to indicate that quests pages from a specific list of zones and a the page is in the active list. specific page order, the pages that are returned launder This flag is used to determine can come from anywhere within the zone. This whether the page is currently under- means that a page for the slab allocator7 can going swap activity. It is set when be allocated between pages that are allocated the page is selected to be swapped for the page cache. The same can be said for out. other non-swappable pages such as task con- trol blocks and page table nodes.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    23 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us