You are previewing Understanding the Linux® Virtual Memory Manager.
O'Reilly logo
Understanding the Linux® Virtual Memory Manager

Book Description

Finally, a comprehensive guide to the Linux VM!

VM's behavior affects every Linux kernel subsystem and dramatically impacts overall performance. But until now, there was only one way to understand VM: study the poorly documented source one line at a time. Now there's an easier, faster alternative. This book describes VM in unprecedented detail, presenting both theoretical foundations and a line-by-line source code commentary. It systematically covers everything from physical memory description to out-of-memory management. Coverage includes:

  • Linux VM 2.4 architecture in depth-with diagrams and call graphs

  • Physical memory description, page tables, address spaces, and memory allocation

  • High memory, swapping, shared memory, and much more

  • Expert guidance for analyzing the code of any open source project

  • New Linux 2.6 kernel features in every chapter

  • Well organized and superbly written, Understanding the Linux Virtual Memory Manager will be indispensable to every kernel programmer and researcher.

    CD-ROM INCLUDED

    Complete VM Learning Lab! Contains the author's new toolkit for exploring VM, including a browsable version of kernel source, CodeViz call graph generator; and VMRegress for analyzing and benchmarking VM. Also includes all code commentary in HTML, PDF, and plain text formats.

    Table of Contents

    1. Copyright
      1. Dedication
    2. Bruce Perens’ Open Source Series
    3. About Prentice Hall Professional Technical Reference
    4. Preface
      1. The Intended Audience
      2. Book Overview
      3. What’s New in 2.6
      4. Companion CD
      5. Typographic Conventions
      6. Acknowledgments
    5. 1. Introduction
      1. 1.1. Getting Started
        1. 1.1.1. Configuration and Building
        2. 1.1.2. Sources of Information
      2. 1.2. Managing the Source
        1. 1.2.1. Diff and Patch
        2. 1.2.2. Basic Source Management With PatchSet
      3. 1.3. Browsing the Code
        1. 1.3.1. Analyzing Code Flow
        2. 1.3.2. Simple Graph Generation
      4. 1.4. Reading the Code
      5. 1.5. Submitting Patches
    6. 2. Describing Physical Memory
      1. 2.1. Nodes
      2. 2.2. Zones
        1. 2.2.1. Zone Watermarks
        2. 2.2.2. Calculating the Size of Zones
        3. 2.2.3. Zone Wait Queue Table
      3. 2.3. Zone Initialization
      4. 2.4. Initializing mem_map
      5. 2.5. Pages
      6. 2.6. Mapping Pages to Zones
      7. 2.7. High Memory
      8. 2.8. What’s New in 2.6
    7. 3. Page Table Management
      1. 3.1. Describing the Page Directory
      2. 3.2. Describing a Page Table Entry
      3. 3.3. Using Page Table Entries
      4. 3.4. Translating and Setting Page Table Entries
      5. 3.5. Allocating and Freeing Page Tables
      6. 3.6. Kernel Page Tables
        1. 3.6.1. Bootstrapping
        2. 3.6.2. Finalizing
      7. 3.7. Mapping Addresses to a struct page
        1. 3.7.1. Mapping Physical to Virtual Kernel Addresses
        2. 3.7.2. Mapping struct pages to Physical Addresses
      8. 3.8. Translation Lookaside Buffer (TLB)
      9. 3.9. Level 1 CPU Cache Management
      10. 3.10. What’s New in 2.6
    8. 4. Process Address Space
      1. 4.1. Linear Address Space
      2. 4.2. Managing the Address Space
      3. 4.3. Process Address Space Descriptor
        1. 4.3.1. Allocating a Descriptor
        2. 4.3.2. Initializing a Descriptor
        3. 4.3.3. Destroying a Descriptor
      4. 4.4. Memory Regions
        1. 4.4.1. Memory Region Operations
        2. 4.4.2. File/Device-Backed Memory Regions
        3. 4.4.3. Creating a Memory Region
        4. 4.4.4. Finding a Mapped Memory Region
        5. 4.4.5. Finding a Free Memory Region
        6. 4.4.6. Inserting a Memory Region
        7. 4.4.7. Merging Contiguous Regions
        8. 4.4.8. Remapping and Moving a Memory Region
        9. 4.4.9. Locking a Memory Region
        10. 4.4.10. Unlocking the Region
        11. 4.4.11. Fixing Up Regions After Locking
        12. 4.4.12. Deleting a Memory Region
        13. 4.4.13. Deleting All Memory Regions
      5. 4.5. Exception Handling
      6. 4.6. Page Faulting
        1. 4.6.1. Handling a Page Fault
        2. 4.6.2. Demand Allocation
        3. 4.6.3. Demand Paging
        4. 4.6.4. COW Pages
      7. 4.7. Copying to/from Userspace
      8. 4.8. What’s New in 2.6
    9. 5. Boot Memory Allocator
      1. 5.1. Representing the Boot Map
      2. 5.2. Initializing the Boot Memory Allocator
      3. 5.3. Initializing bootmem_data
      4. 5.4. Allocating Memory
      5. 5.5. Freeing Memory
      6. 5.6. Retiring the Boot Memory Allocator
      7. 5.7. What’s New in 2.6
    10. 6. Physical Page Allocation
      1. 6.1. Managing Free Blocks
      2. 6.2. Allocating Pages
      3. 6.3. Free Pages
      4. 6.4. Get Free Page (GFP) Flags
      5. 6.5. Process Flags
      6. 6.6. Avoiding Fragmentation
      7. 6.7. What’s New in 2.6
    11. 7. Noncontiguous Memory Allocation
      1. 7.1. Describing Virtual Memory Areas
      2. 7.2. Allocating a Noncontiguous Area
      3. 7.3. Freeing a Noncontiguous Area
      4. 7.4. What’s New in 2.6
    12. 8. Slab Allocator
      1. 8.1. Caches
        1. 8.1.1. Cache Descriptor
        2. 8.1.2. Cache Static Flags
        3. 8.1.3. Cache Dynamic Flags
        4. 8.1.4. Cache Allocation Flags
        5. 8.1.5. Cache Coloring
        6. 8.1.6. Cache Creation
        7. 8.1.7. Cache Reaping
        8. 8.1.8. Cache Shrinking
        9. 8.1.9. Cache Destroying
      2. 8.2. Slabs
        1. 8.2.1. Storing the Slab Descriptor
        2. 8.2.2. Slab Creation
        3. 8.2.3. Tracking Free Objects
        4. 8.2.4. Initializing the kmem_bufctl_t Array
        5. 8.2.5. Finding the Next Free Object
        6. 8.2.6. Updating kmem_bufctl_t
        7. 8.2.7. Calculating the Number of Objects on a Slab
        8. 8.2.8. Slab Destroying
      3. 8.3. Objects
        1. 8.3.1. Initializing Objects in a Slab
        2. 8.3.2. Object Allocation
        3. 8.3.3. Object Freeing
      4. 8.4. Sizes Cache
        1. 8.4.1. kmalloc()
        2. 8.4.2. kfree()
      5. 8.5. Per-CPU Object Cache
        1. 8.5.1. Describing the Per-CPU Object Cache
        2. 8.5.2. Adding/Removing Objects From the Per-CPU Cache
        3. 8.5.3. Enabling Per-CPU Caches
        4. 8.5.4. Updating Per-CPU Information
        5. 8.5.5. Draining a Per-CPU Cache
      6. 8.6. Slab Allocator Initialization
      7. 8.7. Interfacing With the Buddy Allocator
      8. 8.8. What’s New in 2.6
    13. 9. High Memory Management
      1. 9.1. Managing the PKMap Address Space
      2. 9.2. Mapping High Memory Pages
      3. 9.3. Unmapping Pages
      4. 9.4. Mapping High Memory Pages Atomically
      5. 9.5. Bounce Buffers
        1. 9.5.1. Disk Buffering
        2. 9.5.2. Creating Bounce Buffers
        3. 9.5.3. Copying via Bounce Buffers
      6. 9.6. Emergency Pools
      7. 9.7. What’s New in 2.6
    14. 10. Page Frame Reclamation
      1. 10.1. Page Replacement Policy
      2. 10.2. Page Cache
        1. 10.2.1. Page Cache Hash Table
        2. 10.2.2. Inode Queue
        3. 10.2.3. Adding Pages to the Page Cache
      3. 10.3. LRU Lists
        1. 10.3.1. Refilling inactive_list
        2. 10.3.2. Reclaiming Pages From the LRU Lists
      4. 10.4. Shrinking All Caches
      5. 10.5. Swapping Out Process Pages
      6. 10.6. Pageout Daemon (kswapd)
      7. 10.7. What’s New in 2.6
    15. 11. Swap Management
      1. 11.1. Describing the Swap Area
      2. 11.2. Mapping Page Table Entries to Swap Entries
      3. 11.3. Allocating a Swap Slot
      4. 11.4. Swap Cache
      5. 11.5. Reading Pages From Backing Storage
      6. 11.6. Writing Pages to Backing Storage
      7. 11.7. Reading/Writing Swap Area Blocks
      8. 11.8. Activating a Swap Area
      9. 11.9. Deactivating a Swap Area
      10. 11.10. What’s New in 2.6
    16. 12. Shared Memory Virtual Filesystem
      1. 12.1. Initializing the Virtual Filesystem
      2. 12.2. Using shmem Functions
      3. 12.3. Creating Files in tmpfs
      4. 12.4. Page Faulting Within a Virtual File
        1. 12.4.1. Locating Swapped Pages
        2. 12.4.2. Writing Pages to Swap
      5. 12.5. File Operations in tmpfs
      6. 12.6. Inode Operations in tmpfs
      7. 12.7. Setting Up Shared Regions
      8. 12.8. System V IPC
      9. 12.9. What’s New in 2.6
    17. 13. Out of Memory Management
      1. 13.1. Checking Available Memory
      2. 13.2. Determining OOM Status
      3. 13.3. Selecting a Process
      4. 13.4. Killing the Selected Process
      5. 13.5. Is That It?
      6. 13.6. What’s New in 2.6
    18. 14. The Final Word
    19. A. Introduction
    20. B. Describing Physical Memory
      1. B.1. Initializing Zones
        1. B.1.1. Function: setup_memory() (arch/i386/kernel/setup.c)
        2. B.1.2. Function: zone_sizes_init() (arch/i386/mm/init.c)
        3. B.1.3. Function: free_area_init() (mm/page_alloc.c)
        4. B.1.4. Function: free_area_init_node() (mm/numa.c)
        5. B.1.5. Function: free_area_init_core() (mm/page_alloc.c)
        6. B.1.6. Function: build_zonelists() (mm/page_alloc.c)
      2. B.2. Page Operations
        1. B.2.1. Locking Pages
          1. B.2.1.1. Function: lock_page() (mm/filemap.c)
          2. B.2.1.2. Function: __lock_page() (mm/filemap.c)
          3. B.2.1.3. Function: sync_page() (mm/filemap.c)
        2. B.2.2. Unlocking Pages
          1. B.2.2.1. Function: unlock_page() (mm/filemap.c)
        3. B.2.3. Waiting on Pages
          1. B.2.3.1. Function: wait_on_page() (include/linux/pagemap.h)
          2. B.2.3.2. Function: ___wait_on_page() (mm/filemap.c)
    21. C. Page Table Management
      1. C.1. Page Table Initialization
        1. C.1.1. Function: paging_init() (arch/i386/mm/init.c)
        2. C.1.2. Function: pagetable_init() (arch/i386/mm/init.c)
        3. C.1.3. Function: fixrange_init() (arch/i386/mm/init.c)
        4. C.1.4. Function: kmap_init() (arch/i386/mm/init.c)
      2. C.2. Page Table Walking
        1. C.2.1. Function: follow_page() (mm/memory.c)
    22. D. Process Address Space
      1. D.1. Process Memory Descriptors
        1. D.1.1. Initializing a Descriptor
        2. D.1.2. Copying a Descriptor
          1. D.1.2.1. Function: copy_mm() (kernel/fork.c)
          2. D.1.2.2. Function: mm_init() (kernel/fork.c)
        3. D.1.3. Allocating a Descriptor
          1. D.1.3.1. Function: allocate_mm() (kernel/fork.c)
          2. D.1.3.2. Function: mm_alloc() (kernel/fork.c)
        4. D.1.4. Destroying a Descriptor
          1. D.1.4.1. Function: mmput() (kernel/fork.c)
          2. D.1.4.2. Function: mmdrop() (include/linux/sched.h)
          3. D.1.4.3. Function: __mmdrop() (kernel/fork.c)
      2. D.2. Creating Memory Regions
        1. D.2.1. Creating a Memory Region
          1. D.2.1.1. Function: do_mmap() (include/linux/mm.h)
          2. D.2.1.2. Function: do_mmap_pgoff() (mm/mmap.c)
        2. D.2.2. Inserting a Memory Region
          1. D.2.2.1. Function: __insert_vm_struct() (mm/mmap.c)
          2. D.2.2.2. Function: find_vma_prepare() (mm/mmap.c)
          3. D.2.2.3. Function: vma_link() (mm/mmap.c)
          4. D.2.2.4. Function: __vma_link() (mm/mmap.c)
          5. D.2.2.5. Function: __vma_link_list() (mm/mmap.c)
          6. D.2.2.6. Function: __vma_link_rb() (mm/mmap.c)
          7. D.2.2.7. Function: __vma_link_file() (mm/mmap.c)
        3. D.2.3. Merging Contiguous Regions
          1. D.2.3.1. Function: vma_merge() (mm/mmap.c)
          2. D.2.3.2. Function: can_vma_merge() (include/linux/mm.h)
        4. D.2.4. Remapping and Moving a Memory Region
          1. D.2.4.1. Function: sys_mremap() (mm/mremap.c)
          2. D.2.4.2. Function: do_mremap() (mm/mremap.c)
          3. D.2.4.3. Function: move_vma() (mm/mremap.c)
          4. D.2.4.4. Function: make_pages_present() (mm/memory.c)
          5. D.2.4.5. Function: get_user_pages() (mm/memory.c)
          6. D.2.4.6. Function: move_page_tables() (mm/mremap.c)
          7. D.2.4.7. Function: move_one_page() (mm/mremap.c)
          8. D.2.4.8. Function: get_one_pte() (mm/mremap.c)
          9. D.2.4.9. Function: alloc_one_pte() (mm/mremap.c)
          10. D.2.4.10. Function: copy_one_pte() (mm/mremap.c)
        5. D.2.5. Deleting a Memory Region
          1. D.2.5.1. Function: do_munmap() (mm/mmap.c)
          2. D.2.5.2. Function: unmap_fixup() (mm/mmap.c)
        6. D.2.6. Deleting All Memory Regions
          1. D.2.6.1. Function: exit_mmap() (mm/mmap.c)
          2. D.2.6.2. Function: clear_page_tables() (mm/memory.c)
          3. D.2.6.3. Function: free_one_pgd() (mm/memory.c)
          4. D.2.6.4. Function: free_one_pmd() (mm/memory.c)
      3. D.3. Searching Memory Regions
        1. D.3.1. Finding a Mapped Memory Region
          1. D.3.1.1. Function: find_vma() (mm/mmap.c)
          2. D.3.1.2. Function: find_vma_prev() (mm/mmap.c)
          3. D.3.1.3. Function: find_vma_intersection() (include/linux/mm.h)
        2. D.3.2. Finding a Free Memory Region
          1. D.3.2.1. Function: get_unmapped_area() (mm/mmap.c)
          2. D.3.2.2. Function: arch_get_unmapped_area() (mm/mmap.c)
      4. D.4. Locking and Unlocking Memory Regions
        1. D.4.1. Locking a Memory Region
          1. D.4.1.1. Function: sys_mlock() (mm/mlock.c)
          2. D.4.1.2. Function: sys_mlockall() (mm/mlock.c)
          3. D.4.1.3. Function: do_mlockall() (mm/mlock.c)
          4. D.4.1.4. Function: do_mlock() (mm/mlock.c)
        2. D.4.2. Unlocking the Region
          1. D.4.2.1. Function: sys_munlock() (mm/mlock.c)
          2. D.4.2.2. Function: sys_munlockall() (mm/mlock.c)
        3. D.4.3. Fixing Up Regions After Locking/Unlocking
          1. D.4.3.1. Function: mlock_fixup() (mm/mlock.c)
          2. D.4.3.2. Function: mlock_fixup_all() (mm/mlock.c)
          3. D.4.3.3. Function: mlock_fixup_start() (mm/mlock.c)
          4. D.4.3.4. Function: mlock_fixup_end() (mm/mlock.c)
          5. D.4.3.5. Function: mlock_fixup_middle() (mm/mlock.c)
      5. D.5. Page Faulting
        1. D.5.1. x86 Page Fault Handler
          1. D.5.1.1. Function: do_page_fault() (arch/i386/mm/fault.c)
        2. D.5.2. Expanding the Stack
          1. D.5.2.1. Function: expand_stack() (include/linux/mm.h)
        3. D.5.3. Architecture-Independent Page Fault Handler
          1. D.5.3.1. Function: handle_mm_fault() (mm/memory.c)
          2. D.5.3.2. Function: handle_pte_fault() (mm/memory.c)
        4. D.5.4. Demand Allocation
          1. D.5.4.1. Function: do_no_page() (mm/memory.c)
          2. D.5.4.2. Function: do_anonymous_page() (mm/memory.c)
        5. D.5.5. Demand Paging
          1. D.5.5.1. Function: do_swap_page() (mm/memory.c)
          2. D.5.5.2. Function: can_share_swap_page() (mm/swapfile.c)
          3. D.5.5.3. Function: exclusive_swap_page() (mm/swapfile.c)
        6. D.5.6. Copy On Write (COW) Pages
          1. D.5.6.1. Function: do_wp_page() (mm/memory.c)
      6. D.6. Page-Related Disk I/O
        1. D.6.1. Generic File Reading
          1. D.6.1.1. Function: generic_file_read() (mm/filemap.c)
          2. D.6.1.2. Function: do_generic_file_read() (mm/filemap.c)
          3. D.6.1.3. Function: generic_file_readahead() (mm/filemap.c)
        2. D.6.2. Generic File mmap()
          1. D.6.2.1. Function: generic_file_mmap() (mm/filemap.c)
        3. D.6.3. Generic File Truncation
          1. D.6.3.1. Function: vmtruncate() (mm/memory.c)
          2. D.6.3.2. Function: vmtruncate_list() (mm/memory.c)
          3. D.6.3.3. Function: zap_page_range() (mm/memory.c)
          4. D.6.3.4. Function: zap_pmd_range() (mm/memory.c)
          5. D.6.3.5. Function: zap_pte_range() (mm/memory.c)
          6. D.6.3.6. Function: truncate_inode_pages() (mm/filemap.c)
          7. D.6.3.7. Function: truncate_list_pages() (mm/filemap.c)
          8. D.6.3.8. Function: truncate_complete_page() (mm/filemap.c)
          9. D.6.3.9. Function: do_flushpage() (mm/filemap.c)
          10. D.6.3.10. Function: truncate_partial_page() (mm/filemap.c)
        4. D.6.4. Reading Pages for the Page Cache
          1. D.6.4.1. Function: filemap_nopage() (mm/filemap.c)
          2. D.6.4.2. Function: page_cache_read() (mm/filemap.c)
        5. D.6.5. File Readahead for nopage()
          1. D.6.5.1. Function: nopage_sequential_readahead() (mm/filemap.c)
          2. D.6.5.2. Function: read_cluster_nonblocking() (mm/filemap.c)
        6. D.6.6. Swap-Related Read-Ahead
          1. D.6.6.1. Function: swapin_readahead() (mm/memory.c)
          2. D.6.6.2. Function: valid_swaphandles() (mm/swapfile.c)
    23. E. Boot Memory Allocator
      1. E.1. Initializing the Boot Memory Allocator
        1. E.1.1. Function: init_bootmem() (mm/bootmem.c)
        2. E.1.2. Function: init_bootmem_node() (mm/bootmem.c)
        3. E.1.3. Function: init_bootmem_core() (mm/bootmem.c)
      2. E.2. Allocating Memory
        1. E.2.1. Reserving Large Regions of Memory
          1. E.2.1.1. Function: reserve_bootmem() (mm/bootmem.c)
          2. E.2.1.2. Function: reserve_bootmem_node() (mm/bootmem.c)
          3. E.2.1.3. Function: reserve_bootmem_core() (mm/bootmem.c)
        2. E.2.2. Allocating Memory at Boot Time
          1. E.2.2.1. Function: alloc_bootmem() (mm/bootmem.c)
          2. E.2.2.2. Function: __alloc_bootmem() (mm/bootmem.c)
          3. E.2.2.3. Function: alloc_bootmem_node() (mm/bootmem.c)
          4. E.2.2.4. Function: __alloc_bootmem_node() (mm/bootmem.c)
          5. E.2.2.5. Function: __alloc_bootmem_core() (mm/bootmem.c)
      3. E.3. Freeing Memory
        1. E.3.1. Function: free_bootmem() (mm/bootmem.c)
        2. E.3.2. Function: free_bootmem_core() (mm/bootmem.c)
      4. E.4. Retiring the Boot Memory Allocator
        1. E.4.1. Function: mem_init() (arch/i386/mm/init.c)
        2. E.4.2. Function: free_pages_init() (arch/i386/mm/init.c)
        3. E.4.3. Function: one_highpage_init() (arch/i386/mm/init.c)
        4. E.4.4. Function: free_all_bootmem() (mm/bootmem.c)
        5. E.4.5. Function: free_all_bootmem_core() (mm/bootmem.c)
    24. F. Physical Page Allocation
      1. F.1. Allocating Pages
        1. F.1.1. Function: alloc_pages() (include/linux/mm.h)
        2. F.1.2. Function: _alloc_pages() (mm/page_alloc.c)
        3. F.1.3. Function: __alloc_pages() (mm/page_alloc.c)
        4. F.1.4. Function: rmqueue() (mm/page_alloc.c)
        5. F.1.5. Function: expand() (mm/page_alloc.c)
        6. F.1.6. Function: balance_classzone() (mm/page_alloc.c)
      2. F.2. Allocation Helper Functions
        1. F.2.1. Function: alloc_page() (include/linux/mm.h)
        2. F.2.2. Function: __get_free_page() (include/linux/mm.h)
        3. F.2.3. Function: __get_free_pages() (mm/page_alloc.c)
        4. F.2.4. Function: __get_dma_pages() (include/linux/mm.h)
        5. F.2.5. Function: get_zeroed_page() (mm/page_alloc.c)
      3. F.3. Free Pages
        1. F.3.1. Function: __free_pages() (mm/page_alloc.c)
        2. F.3.2. Function: __free_pages_ok() (mm/page_alloc.c)
      4. F.4. Free Helper Functions
        1. F.4.1. Function: free_pages() (mm/page_alloc.c)
        2. F.4.2. Function: __free_page() (include/linux/mm.h)
        3. F.4.3. Function: free_page() (include/linux/mm.h)
    25. G. Noncontiguous Memory Allocation
      1. G.1. Allocating a Noncontiguous Area
        1. G.1.1. Function: vmalloc() (include/linux/vmalloc.h)
        2. G.1.2. Function: __vmalloc() (mm/vmalloc.c)
        3. G.1.3. Function: get_vm_area() (mm/vmalloc.c)
        4. G.1.4. Function: vmalloc_area_pages() (mm/vmalloc.c)
        5. G.1.5. Function: __vmalloc_area_pages() (mm/vmalloc.c)
        6. G.1.6. Function: alloc_area_pmd() (mm/vmalloc.c)
        7. G.1.7. Function: alloc_area_pte() (mm/vmalloc.c)
        8. G.1.8. Function: vmap() (mm/vmalloc.c)
      2. G.2. Freeing a Noncontiguous Area
        1. G.2.1. Function: vfree() (mm/vmalloc.c)
        2. G.2.2. Function: vmfree_area_pages() (mm/vmalloc.c)
        3. G.2.3. Function: free_area_pmd() (mm/vmalloc.c)
        4. G.2.4. Function: free_area_pte() (mm/vmalloc.c)
    26. H. Slab Allocator
      1. H.1. Cache Manipulation
        1. H.1.1. Cache Creation
          1. H.1.1.1. Function: kmem_cache_create() (mm/slab/c)
        2. H.1.2. Calculating the Number of Objects on a Slab
          1. H.1.2.1. Function: kmem_cache_estimate() (mm/slab.c)
        3. H.1.3. Cache Shrinking
          1. H.1.3.1. Function: kmem_cache_shrink() (mm/slab.c)
          2. H.1.3.2. Function: __kmem_cache_shrink() (mm/slab.c)
          3. H.1.3.3. Function: __kmem_cache_shrink_locked() (mm/slab.c)
        4. H.1.4. Cache Destroying
          1. H.1.4.1. Function: kmem_cache_destroy() (mm/slab.c)
        5. H.1.5. Cache Reaping
          1. H.1.5.1. Function: kmem_cache_reap() (mm/slab.c)
      2. H.2. Slabs
        1. H.2.1. Storing the Slab Descriptor
          1. H.2.1.1. Function: kmem_cache_slabmgmt() (mm/slab.c)
          2. H.2.1.2. Function: kmem_find_general_cachep() (mm/slab.c)
        2. H.2.2. Slab Creation
          1. H.2.2.1. Function: kmem_cache_grow() (mm/slab.c)
        3. H.2.3. Slab Destroying
          1. H.2.3.1. Function: kmem_slab_destroy() (mm/slab.c)
      3. H.3. Objects
        1. H.3.1. Initializing Objects in a Slab
          1. H.3.1.1. Function: kmem_cache_init_objs() (mm/slab.c)
        2. H.3.2. Object Allocation
          1. H.3.2.1. Function: kmem_cache_alloc() (mm/slab.c)
          2. H.3.2.2. Function: __kmem_cache_alloc (UP Case)() (mm/slab.c)
          3. H.3.2.3. Function: __kmem_cache_alloc (SMP Case)() (mm/slab.c)
          4. H.3.2.4. Function: kmem_cache_alloc_head() (mm/slab.c)
          5. H.3.2.5. Function: kmem_cache_alloc_one() (mm/slab.c)
          6. H.3.2.6. Function: kmem_cache_alloc_one_tail() (mm/slab.c)
          7. H.3.2.7. Function: kmem_cache_alloc_batch() (mm/slab.c)
        3. H.3.3. Object Freeing
          1. H.3.3.1. Function: kmem_cache_free() (mm/slab.c)
          2. H.3.3.2. Function: __kmem_cache_free (UP Case)() (mm/slab.c)
          3. H.3.3.3. Function: __kmem_cache_free (SMP Case)() (mm/slab.c)
          4. H.3.3.4. Function: kmem_cache_free_one() (mm/slab.c)
          5. H.3.3.5. Function: free_block() (mm/slab.c)
          6. H.3.3.6. Function: __free_block() (mm/slab.c)
      4. H.4. Sizes Cache
        1. H.4.1. Initializing the Sizes Cache
          1. H.4.1.1. Function: kmem_cache_sizes_init() (mm/slab.c)
        2. H.4.2. kmalloc()
          1. H.4.2.1. Function: kmalloc() (mm/slab.c)
        3. H.4.3. kfree()
          1. H.4.3.1. Function: kfree() (mm/slab.c)
      5. H.5. Per-CPU Object Cache
        1. H.5.1. Enabling Per-CPU Caches
          1. H.5.1.1. Function: enable_all_cpucaches() (mm/slab.c)
          2. H.5.1.2. Function: enable_cpucache() (mm/slab.c)
          3. H.5.1.3. Function: kmem_tune_cpucache() (mm/slab.c)
        2. H.5.2. Updating Per-CPU Information
          1. H.5.2.1. Function: smp_call_function_all_cpus() (mm/slab.c)
          2. H.5.2.2. Function: do_ccupdate_local() (mm/slab.c)
        3. H.5.3. Draining a Per-CPU Cache
          1. H.5.3.1. Function: drain_cpu_caches() (mm/slab.c)
      6. H.6. Slab Allocator Initialization
        1. H.6.1.1. Function: kmem_cache_init() (mm/slab.c)
      7. H.7. Interfacing with the Buddy Allocator
        1. H.7.1.1. Function: kmem_getpages() (mm/slab.c)
        2. H.7.1.2. Function: kmem_freepages() (mm/slab.c)
    27. I. High Memory Management
      1. I.1. Mapping High Memory Pages
        1. I.1.1. Function: kmap() (include/asm-i386/highmem.c)
        2. I.1.2. Function: kmap_nonblock() (include/asm-i386/highmem.c)
        3. I.1.3. Function: __kmap() (include/asm-i386/highmem.h)
        4. I.1.4. Function: kmap_high() (mm/highmem.c)
        5. I.1.5. Function: map_new_virtual() (mm/highmem.c)
        6. I.1.6. Function: flush_all_zero_pkmaps() (mm/highmem.c)
      2. I.2. Mapping High Memory Pages Atomically
        1. I.2.1. Function: kmap_atomic() (include/asm-i386/highmem.h)
      3. I.3. Unmapping Pages
        1. I.3.1. Function: kunmap() (include/asm-i386/highmem.h)
        2. I.3.2. Function: kunmap_high() (mm/highmem.c)
      4. I.4. Unmapping High Memory Pages Atomically
        1. I.4.1. Function: kunmap_atomic() (include/asm-i386/highmem.h)
      5. I.5. Bounce Buffers
        1. I.5.1. Creating Bounce Buffers
          1. I.5.1.1. Function: create_bounce() (mm/highmem.c)
          2. I.5.1.2. Function: alloc_bounce_bh() (mm/highmem.c)
          3. I.5.1.3. Function: alloc_bounce_page() (mm/highmem.c)
        2. I.5.2. Copying Using Bounce Buffers
          1. I.5.2.1. Function: bounce_end_io_write() (mm/highmem.c)
          2. I.5.2.2. Function: bounce_end_io_read() (mm/highmem.c)
          3. I.5.2.3. Function: copy_from_high_bh() (mm/highmem.c)
          4. I.5.2.4. Function: copy_to_high_bh_irq() (mm/highmem.c)
          5. I.5.2.5. Function: bounce_end_io() (mm/highmem.c)
      6. I.6. Emergency Pools
        1. I.6.1. Function: init_emergency_pool() (mm/highmem.c)
    28. J. Page Frame Reclamation
      1. J.1. Page Cache Operations
        1. J.1.1. Adding Pages to the Page Cache
          1. J.1.1.1. Function: add_to_page_cache() (mm/filemap.c)
          2. J.1.1.2. Function: add_to_page_cache_unique() (mm/filemap.c)
          3. J.1.1.3. Function: __add_to_page_cache() (mm/filemap.c)
          4. J.1.1.4. Function: add_page_to_inode_queue() (mm/filemap.c)
          5. J.1.1.5. Function: add_page_to_hash_queue() (mm/filemap.c)
        2. J.1.2. Deleting Pages From the Page Cache
          1. J.1.2.1. Function: remove_inode_page() (mm/filemap.c)
          2. J.1.2.2. Function: __remove_inode_page() (mm/filemap.c)
          3. J.1.2.3. Function:remove_page_from_inode_queue() (mm/filemap.c)
          4. J.1.2.4. Function: remove_page_from_hash_queue() (mm/filemap.c)
        3. J.1.3. Acquiring/Releasing Page Cache Pages
          1. J.1.3.1. Function: page_cache_get() (include/linux/pagemap.h)
          2. J.1.3.2. Function: page_cache_release() (include/linux/pagemap.h)
        4. J.1.4. Searching the Page Cache
          1. J.1.4.1. Function: find_get_page() (include/linux/pagemap.h)
          2. J.1.4.2. Function: __find_get_page() (mm/filemap.c)
          3. J.1.4.3. Function: __find_page_nolock() (mm/filemap.c)
          4. J.1.4.4. Function: find_lock_page() (include/linux/pagemap.h)
          5. J.1.4.5. Function: __find_lock_page() (mm/filemap.c)
          6. J.1.4.6. Function: __find_lock_page_helper() (mm/filemap.c)
      2. J.2. LRU List Operations
        1. J.2.1. Adding Pages to the LRU Lists
          1. J.2.1.1. Function: lru_cache_add() (mm/swap.c)
          2. J.2.1.2. Function: add_page_to_active_list() (include/linux/swap.h)
          3. J.2.1.3. Function: add_page_to_inactive_list() (include/linux/swap.h)
        2. J.2.2. Deleting Pages From the LRU Lists
          1. J.2.2.1. Function: lru_cache_del() (mm/swap.c)
          2. J.2.2.2. Function: __lru_cache_del() (mm/swap.c)
          3. J.2.2.3. Function: del_page_from_active_list() (include/linux/swap.h)
          4. J.2.2.4. Function: del_page_from_inactive_list() (include/linux/swap.h)
        3. J.2.3. Activating Pages
          1. J.2.3.1. Function: mark_page_accessed() (mm/filemap.c)
          2. J.2.3.2. Function: activate_lock() (mm/swap.c)
          3. J.2.3.3. Function: activate_page_nolock() (mm/swap.c)
      3. J.3. Refilling inactive_list
        1. J.3.1. Function: refill_inactive() (mm/vmscan.c)
      4. J.4. Reclaiming Pages From the LRU Lists
        1. J.4.1. Function: shrink_cache() (mm/vmscan.c)
      5. J.5. Shrinking All Caches
        1. J.5.1. Function: shrink_caches() (mm/vmscan.c)
        2. J.5.2. Function: try_to_free_pages() (mm/vmscan.c)
        3. J.5.3. Function: try_to_free_pages_zone() (mm/vmscan.c)
      6. J.6. Swapping Out Process Pages
        1. J.6.1. Function: swap_out() (mm/vmscan.c)
        2. J.6.2. Function: swap_out_mm() (mm/vmscan.c)
        3. J.6.3. Function: swap_out_vma() (mm/vmscan.c)
        4. J.6.4. Function: swap_out_pgd() (mm/vmscan.c)
        5. J.6.5. Function: swap_out_pmd() (mm/vmscan.c)
        6. J.6.6. Function: try_to_swap_out() (mm/vmscan.c)
      7. J.7. Page Swap Daemon
        1. J.7.1. Initializing kswapd
          1. J.7.1.1. Function: kswapd_init() (mm/vmscan.c)
        2. J.7.2. kswapd Daemon
          1. J.7.2.1. Function: kswapd() (mm/vmscan.c)
          2. J.7.2.2. Function: kswapd_can_sleep() (mm/vmscan.c)
          3. J.7.2.3. Function: kswapd_can_sleep_pgdat() (mm/vmscan.c)
          4. J.7.2.4. Function: kswapd_balance() (mm/vmscan.c)
          5. J.7.2.5. Function: kswapd_balance_pgdat() (mm/vmscan.c)
    29. K. Swap Management
      1. K.1. Scanning for Free Entries
        1. K.1.1. Function: get_swap_page() (mm/swapfile.c)
        2. K.1.2. Function: scan_swap_map() (mm/swapfile.c)
      2. K.2. Swap Cache
        1. K.2.1. Adding Pages to the Swap Cache
          1. K.2.1.1. Function: add_to_swap_cache() (mm/swap_state.c)
          2. K.2.1.2. Function: swap_duplicate() (mm/swapfile.c)
        2. K.2.2. Deleting Pages From the Swap Cache
          1. K.2.2.1. Function: swap_free() (mm/swapfile.c)
          2. K.2.2.2. Function: swap_entry_free() (mm/swapfile.c)
        3. K.2.3. Acquiring/Releasing Swap Cache Pages
          1. K.2.3.1. Function: swap_info_get() (mm/swapfile.c)
          2. K.2.3.2. Function: swap_info_put() (mm/swapfile.c)
        4. K.2.4. Searching the Swap Cache
          1. K.2.4.1. Function: lookup_swap_cache() (mm/swap_state.c)
      3. K.3. Swap Area I/O
        1. K.3.1. Reading Backing Storage
          1. K.3.1.1. Function: read_swap_cache_async() (mm/swap_state.c)
        2. K.3.2. Writing Backing Storage
          1. K.3.2.1. Function: swap_writepage() (mm/swap_state.c)
          2. K.3.2.2. Function: remove_exclusive_swap_page() (mm/swapfile.c)
          3. K.3.2.3. Function: free_swap_and_cache() (mm/swapfile.c)
        3. K.3.3. Block I/O
          1. K.3.3.1. Function: rw_swap_page() (mm/page_io.c)
          2. K.3.3.2. Function: rw_swap_page_base() (mm/page_io.c)
          3. K.3.3.3. Function: get_swaphandle_info() (mm/swapfile.c)
      4. K.4. Activating a Swap Area
        1. K.4.1. Function: sys_swapon() (mm/swapfile.c)
        2. K.4.2. Function: swap_setup() (mm/swap.c)
      5. K.5. Deactivating a Swap Area
        1. K.5.1. Function: sys_swapoff() (mm/swapfile.c)
        2. K.5.2. Function: try_to_unuse() (mm/swapfile.c)
        3. K.5.3. Function: unuse_process() (mm/swapfile.c)
        4. K.5.4. Function: unuse_vma() (mm/swapfile.c)
        5. K.5.5. Function: unuse_pgd() (mm/swapfile.c)
        6. K.5.6. Function: unuse_pmd() (mm/swapfile.c)
        7. K.5.7. Function: unuse_pte() (mm/swapfile.c)
    30. L. Shared Memory Virtual Filesystem
      1. L.1. Initializing shmfs
        1. L.1.1. Function: init_tmpfs() (mm/shmem.c)
        2. L.1.2. Function: shmem_read_super() (mm/shmem.c)
        3. L.1.3. Function: shmem_set_size() (mm/shmem.c)
      2. L.2. Creating Files in tmpfs
        1. L.2.1. Function: shmem_create() (mm/shmem.c)
        2. L.2.2. Function: shmem_mknod() (mm/shmem.c)
        3. L.2.3. Function: shmem_get_inode() (mm/shmem.c)
      3. L.3. File Operations in tmpfs
        1. L.3.1. Memory Mapping
          1. L.3.1.1. Function: shmem_mmap() (mm/shmem.c)
        2. L.3.2. Reading Files
          1. L.3.2.1. Function: shmem_file_read() (mm/shmem.c)
          2. L.3.2.2. Function: do_shmem_file_read() (mm/shmem.c)
          3. L.3.2.3. Function: file_read_actor() (mm/filemap.c)
        3. L.3.3. Writing
          1. L.3.3.1. Function: shmem_file_write() (mm/shmem.c)
        4. L.3.4. Symbolic Linking
          1. L.3.4.1. Function: shmem_symlink() (mm/shmem.c)
          2. L.3.4.2. Function: shmem_readlink_inline() (mm/shmem.c)
          3. L.3.4.3. Function: shmem_follow_link_inline() (mm/shmem.c)
          4. L.3.4.4. Function: shmem_readlink() (mm/shmem.c)
        5. L.3.5. Synchronizing
          1. L.3.5.1. Function: shmem_sync_file() (mm/shmem.c)
      4. L.4. Inode Operations in tmpfs
        1. L.4.1. Truncating
          1. L.4.1.1. Function: shmem_truncate() (mm/shmem.c)
          2. L.4.1.2. Function: shmem_truncate_indirect() (mm/shmem.c)
          3. L.4.1.3. Function: shmem_truncate_direct() (mm/shmem.c)
          4. L.4.1.4. Function: shmem_free_swp() (mm/shmem.c)
        2. L.4.2. Linking
          1. L.4.2.1. Function: shmem_link() (mm/shmem.c)
        3. L.4.3. Unlinking
          1. L.4.3.1. Function: shmem_unlink() (mm/shmem.c)
        4. L.4.4. Making Directories
          1. L.4.4.1. Function: shmem_mkdir() (mm/shmem.c)
        5. L.4.5. Removing Directories
          1. L.4.5.1. Function: shmem_rmdir() (mm/shmem.c)
          2. L.4.5.2. Function: shmem_empty() (mm/shmem.c)
          3. L.4.5.3. Function: shmem_positive() (mm/shmem.c)
      5. L.5. Page Faulting Within a Virtual File
        1. L.5.1. Reading Pages During Page Fault
          1. L.5.1.1. Function: shmem_nopage() (mm/shmem.c)
          2. L.5.1.2. Function: shmem_getpage() (mm/shmem.c)
        2. L.5.2. Locating Swapped Pages
          1. L.5.2.1. Function: shmem_alloc_entry() (mm/shmem.c)
          2. L.5.2.2. Function: shmem_swp_entry() (mm/shmem.c)
      6. L.6. Swap Space Interaction
        1. L.6.1. Function: shmem_writepage()(mm/shmem.c)
        2. L.6.2. Function: shmem_unuse()(mm/shmem.c)
        3. L.6.3. Function: shmem_unuse_inode()(mm/shmem.c)
        4. L.6.4. Function: shmem_find_swp()(mm/shmem.c)
      7. L.7. Setting Up Shared Regions
        1. L.7.1. Function: shmem_zero_setup()(mm/shmem.c)
        2. L.7.2. Function: shmem_file_setup()(mm/shmem.c)
      8. L.8. System V IPC
        1. L.8.1. Creating a SYSV Shared Region
          1. L.8.1.1. Function: sys_shmget() (ipc/shm.c)
          2. L.8.1.2. Function: newseg() (ipc/shm.c)
        2. L.8.2. Attaching a SYSV Shared Region
          1. L.8.2.1. Function: sys_shmat() (ipc/shm.c)
    31. M. Out of Memory Management
      1. M.1. Determining Available Memory
        1. M.1.1. Function: vm_enough_memory() (mm/mmap.c)
      2. M.2. Detecting and Recovering From OOM
        1. M.2.1. Function: out_of_memory() (mm/oom_kill.c)
        2. M.2.2. Function: oom_kill() (mm/oom_kill.c)
        3. M.2.3. Function: select_bad_process() (mm/oom_kill.c)
        4. M.2.4. Function: badness() (mm/oom_kill.c)
        5. M.2.5. Function: oom_kill_task() (mm/oom_kill.c)
    32. References
    33. About the Author
    34. About the CD-ROM
      1. License Agreement
      2. Technical Support