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 Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 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