Dissertation Acceptance
Total Page:16
File Type:pdf, Size:1020Kb
SEVER INSTITUTE OF TECHNOLOGY DOCTOR OF SCIENCE DEGREE DISSERTATION ACCEPTANCE (To be the first page of each copy of the dissertation) DATE: July 24, 1998 STUDENT’S NAME: Charles D. Cranor This student’s dissertation, entitled Design and Implementation of the UVM Virtual Memory System has been examined by the undersigned committee of five faculty members and has received full approval for acceptance in partial fulfillment of the requirements for the degree Doctor of Science. APPROVAL: Chairman Short Title: Design and Implementation of UVM Cranor, D.Sc. 1998 WASHINGTON UNIVERSITY SEVER INSTITUTE OF TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE DESIGN AND IMPLEMENTATION OF THE UVM VIRTUAL MEMORY SYSTEM by Charles D. Cranor, M.S. Prepared under the direction of Professor Gurudatta M. Parulkar A dissertation presented to the Sever Institute of Washington University in partial fulfillment of the requirements for the degree of Doctor of Science August, 1998 Saint Louis, Missouri WASHINGTON UNIVERSITY SEVER INSTITUTE OF TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE ABSTRACT DESIGN AND IMPLEMENTATION OF THE UVM VIRTUAL MEMORY SYSTEM by Charles D. Cranor ADVISOR: Professor Gurudatta M. Parulkar August, 1998 Saint Louis, Missouri We introduce UVM, a new virtual memory subsystem for 4.4BSD that makes better use of existing hardware memory management features to reduce overhead and improve performance. Our novel approach focuses on allowing processes to pass memory to and from other processes and the kernel, and to share memory. This approach reduces or elim- inates the need to copy data thus reducing the time spent within the kernel and freeing up cycles for application processing. Unlike the approaches that focus exclusively on the networking and inter-process communications (IPC) subsystems, our approach provides a general framework for solutions that can improve efficiency of the entire I/O subsystem. Our primary objective in creating UVM was to produce a virtual memory system that provides a Unix-like operating system kernel’s I/O and IPC subsystems with efficient VM-based data movement facilities that have less overhead than a traditional data copy. Our work seeks to: allow a process to safely let a shared copy-on-write copy of its memory be used either by other processes, the I/O system, or the IPC system; allow pages of memory from the I/O system, the IPC system, or from other processes to be inserted easily into a process’ address space; and allow processes and the kernel to exchange large chunks of their virtual address spaces using the VM system’s higher-level memory mapping data structures. UVM allows processes to exchange and share memory through three innovative new mechanisms: page loanout, page transfer, and map entry passing. We present test results that show that our new VM-based data movement mechanisms are more efficient than data copying. UVM is implemented entirely within the framework of BSD and thus maintains all the features and standard parts of the traditional Unix environment that programmers have come to expect. The first release of UVM in NetBSD runs on several platforms including I386-PC, DEC Alpha, Sun Sparc, Motorola m68k, and DEC VAX systems. It is already being used on systems around the world. to my family, especially Lorrie Contents List of Tables ¡¢¡£¡¢¡£¡¢¡¢¡£¡¤¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡£¡¢¡¤¡£¡¢¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡¤¡£¡¢¡£¡¢¡¢¡ xi List of Figures ¡£¡¢¡£¡¢¡¢¡£¡¤¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡£¡¢¡¤¡£¡¢¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡¤¡£¡¢¡£¡¢¡¢¡ xii Acknowledgments ¡£¡¢¡¢¡£¡¤¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡£¡¢¡¤¡£¡¢¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡¤¡£¡¢¡£¡¢¡¢¡ xv 1 Introduction ¡£¡¢¡£¡¢¡¢¡£¡¤¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡£¡¢¡¤¡£¡¢¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡¤¡£¡¢¡£¡¢¡¢¡ 1 2 Background ¡£¡¢¡£¡¢¡¢¡£¡¤¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡£¡¢¡¤¡£¡¢¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡¤¡£¡¢¡£¡¢¡¢¡ 7 2.1 The Role of the VM System . 7 2.2 The VM System and Process Life Cycle . 10 2.2.1 Process Start-up . 10 2.2.2 Running Processes and Page Faults . 13 2.2.3 Forking and Exiting . 14 2.2.4 VM Operations . 16 2.3 The Evolution of the VM System In BSD . 17 2.4 Design Overview of the BSD VM System . 19 2.4.1 Layering in the BSD VM System . 19 2.4.2 The Machine-Dependent Layer . 19 2.4.3 The Machine-Independent Layer . 21 2.4.4 Copy-on-write and Object Chaining . 27 2.4.5 Page Fault Handling . 33 2.4.6 Memory Sharing . 35 2.5 Summary . 35 3 UVM Overview and Related Work ¡£¡¢¡£¡¢¡¤¡£¡¢¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡¤¡£¡¢¡£¡¢¡¢¡ 36 3.1 Goals . 37 3.2 UVM Features . 39 iv 3.2.1 New Features . 39 3.2.2 Improved Features . 41 3.3 High-Level Design Overview . 43 3.3.1 UVM’s Machine-Independent Layer . 43 3.3.2 Data Structure Locking . 45 3.3.3 VM Maps . 48 3.3.4 UVM Objects . 50 3.3.5 Anonymous Memory Structures . 50 3.3.6 Pager Operations . 52 3.3.7 Pages . 52 3.4 Related Work . 57 3.4.1 Other Virtual Memory Systems . 57 3.4.2 I/O and IPC Subsystems That Use VM Features . 69 3.5 Summary . 74 4 Anonymous Memory Handling ¡¢¡¢¡£¡¢¡£¡¢¡¤¡£¡¢¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡¤¡£¡¢¡£¡¢¡¢¡ 76 4.1 Anonymous Memory Overview . 76 4.2 Amap Interface . 77 4.3 Amap Implementation Options . 79 4.3.1 UVM Reference Amap Implementation . 81 4.3.2 Partial Unmap of an Amap . 82 4.4 Accessing Anonymous Backing Store . 85 4.5 The Effects of Amaps on Pages and Objects . 87 4.6 The Effect of Amaps on Forking and Copy-on-write . 88 4.6.1 Copy-on-write . 88 4.6.2 Forking . 90 4.7 Inheritance and Forking . 95 4.7.1 Share Inheritance when Needs-copy is True . 95 4.7.2 Copy Inheritance when the Amap is Shared . 96 4.7.3 Copy Inheritance of a Shared Mapping . 99 4.7.4 Copy Inheritance when the Map Entry is Wired . 99 4.8 Summary . 99 5 Handling Page Faults ¡£¡¤¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡£¡¢¡¤¡£¡¢¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡¤¡£¡¢¡£¡¢¡¢¡ 100 5.1 Page Fault Overview . 100 5.1.1 Calling uvm fault . 101 v 5.1.2 Fault Address Lookup . 102 5.1.3 Post-lookup Checks . 104 5.1.4 Establishing Fault Range . 105 5.1.5 Mapping Neighboring Resident Pages . 106 5.1.6 Anon Faults . 106 5.1.7 Object Faults . 109 5.1.8 Summary . 111 5.2 Error Recovery . 111 5.2.1 Invalid Virtual Addresses . 111 5.2.2 Protection Violations . 112 5.2.3 Null Mappings . 113 5.2.4 Out of Physical Memory . 113 5.2.5 Out of Anonymous Virtual Memory . 113 5.2.6 Failure To Relock Data Structures . 114 5.2.7 I/O Errors . 114 5.2.8 Released Pages . 115 5.3 BSD VM Fault vs. UVM Fault . 115 5.3.1 Map Lookup . 115 5.3.2 Object Chaining vs. Two-Level Mappings . 116 5.3.3 Mapping Neighboring Resident Pages . 117 5.4 Summary . 117 6 Pager Interface ¡£¡¢¡¢¡£¡¤¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡£¡¢¡¤¡£¡¢¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡¤¡£¡¢¡£¡¢¡¢¡ 118 6.1 The Role of the Pager . 118 6.2 Pager Operations . 119 6.2.1 The Init Operation . 119 6.2.2 The Attach Operation . 120 6.2.3 The Reference Operation . 120 6.2.4 The Detach Operation . 120 6.2.5 The Get Operation . 121 6.2.6 The Asyncget Operation . 123 6.2.7 The Fault Operation . 123 6.2.8 The Put Operation . 124 6.2.9 The Flush Operation . 124 6.2.10 The Cluster Operation . 126 vi 6.2.11 The Make Put Cluster Operation . 126 6.2.12 The Share Protect Operation . 127 6.2.13 The Async I/O Done Operation . 127 6.2.14 The Release Page Operation . 128 6.3 BSD VM Pager vs. UVM Pager . 129 6.3.1 Data Structure Layout . 129 6.3.2 Page Access . 130 6.3.3 Other Minor Differences . 132 6.4 Summary . 133 7 Using UVM to Move Data ¡£¡¢¡£¡¢¡¢¡£¡¢¡£¡¢¡¤¡£¡¢¡¢¡£¡¢¡£¡¢¡¢¡£¡¢¡¤¡£¡¢¡£¡¢¡¢¡ 134 7.1 Page Loanout . 135 7.1.1 Loan Types and Attributes . 136 7.1.2 Loaning and Locking . 138 7.1.3 Loanout Data Structures and Functions . 139 7.1.4 Anonget and Loaned Pages . 139 7.1.5 Loanout Procedure . 140 7.1.6 Dropping and Freeing Loaned-Out Pages . 142 7.1.7 The Pagedaemon and Loaned Out Pages . 143 7.1.8 Faulting on a uvm object with Loaned-Out Pages . 144 7.1.9 Faulting on an Anon With Loaned-Out Pages . 144 7.1.10 Using Page Loanout . 145 7.2 Page Transfer . 146 7.2.1 Kernel Page Transfer . ..