Read without ads and support Scribd by becoming a Scribd Premium Reader.
 
1
Understanding TheLinux Virtual Memory Manager
Mel Gorman
14th July 2003
 
Contents
List of Figures 5List of Tables 7Acknowledgements 91 Introduction 11
1.1 General Kernel Literature . . . . . . . . . . . . . . . . . . . . . . . . 121.2 Thesis Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.3 Typographic Conventions . . . . . . . . . . . . . . . . . . . . . . . . 131.4 About this Document . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.5 Companion CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2 Code Management 16
2.1 Managing the Source . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.2 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222.3 Submitting Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3 Describing Physical Memory 25
3.1 Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.2 Zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283.3 Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303.4 High Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4 Page Table Management 35
4.1 Describing the Page Directory . . . . . . . . . . . . . . . . . . . . . . 364.2 Describing a Page Table Entry . . . . . . . . . . . . . . . . . . . . . . 374.3 Using Page Table Entries . . . . . . . . . . . . . . . . . . . . . . . . . 384.4 Translating and Setting Page Table Entries . . . . . . . . . . . . . . . 414.5 Allocating and Freeing Page Tables . . . . . . . . . . . . . . . . . . . 414.6 Kernel Page Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424.7 Mapping addresses to
struct page
s . . . . . . . . . . . . . . . . . . 43
5 Process Address Space 46
5.1 Linear Address Space . . . . . . . . . . . . . . . . . . . . . . . . . . . 475.2 Managing the Address Space . . . . . . . . . . . . . . . . . . . . . . . 482
 
CONTENTS 
35.3 Process Address Space Descriptor . . . . . . . . . . . . . . . . . . . . 495.4 Memory Regions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545.5 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695.6 Page Faulting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705.7 Copying To/From Userspace . . . . . . . . . . . . . . . . . . . . . . . 76
6 Boot Memory Allocator 79
6.1 Representing the Boot Map . . . . . . . . . . . . . . . . . . . . . . . 806.2 Initialising the Boot Memory Allocator . . . . . . . . . . . . . . . . . 806.3 Allocating Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826.4 Freeing Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 846.5 Retiring the Boot Memory Allocator . . . . . . . . . . . . . . . . . . 84
7 Physical Page Allocation 89
7.1 Managing Free Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . 897.2 Allocating Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907.3 Free Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 937.4 Get Free Page (GFP) Flags . . . . . . . . . . . . . . . . . . . . . . . 947.5 Avoiding Fragmentation . . . . . . . . . . . . . . . . . . . . . . . . . 96
8 Non-Contiguous Memory Allocation 99
8.1 Describing Virtual Memory Areas . . . . . . . . . . . . . . . . . . . . 998.2 Allocating A Non-Contiguous Area . . . . . . . . . . . . . . . . . . . 1008.3 Freeing A Non-Contiguous Area . . . . . . . . . . . . . . . . . . . . . 101
9 Slab Allocator 103
9.1 Caches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1059.2 Slabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1159.3 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1219.4 Sizes Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1229.5 Per-CPU Object Cache . . . . . . . . . . . . . . . . . . . . . . . . . . 1249.6 Slab Allocator Initialisation . . . . . . . . . . . . . . . . . . . . . . . 1279.7 Interfacing with the Buddy Allocator . . . . . . . . . . . . . . . . . . 127
10 High Memory Management 129
10.1 Managing the PKMap Address Space . . . . . . . . . . . . . . . . . . 12910.2 Mapping High Memory Pages . . . . . . . . . . . . . . . . . . . . . . 13010.3 Mapping High Memory Pages Atomically . . . . . . . . . . . . . . . . 13210.4 Bounce Buers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13310.5 Emergency Pools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
11 Page Frame Reclamation 137
11.1 Pageout Daemon (kswapd) . . . . . . . . . . . . . . . . . . . . . . . . 13811.2 Page Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13911.3 Manipulating the Page Cache . . . . . . . . . . . . . . . . . . . . . . 14011.4 Shrinking all caches . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Search History:
Searching...
Result 00 of 00
00 results for result for
  • p.
  • Notes
    Load more