Библиотека сайта rus-linux.net
The book is available and called simply "Understanding The Linux Virtual Memory Manager". There is a lot of additional material in the book that is not available here, including details on later 2.4 kernels, introductions to 2.6, a whole new chapter on the shared memory filesystem, coverage of TLB management, a lot more code commentary, countless other additions and clarifications and a CD with lots of cool stuff on it. This material (although now dated and lacking in comparison to the book) will remain available although I obviously encourge you to buy the book from your favourite book store :-) . As the book is under the Bruce Perens Open Book Series, it will be available 90 days after appearing on the book shelves which means it is not available right now. When it is available, it will be downloadable from http://www.phptr.com/perens so check there for more information.
To be fully clear, this webpage is not the actual book.
Next: 5.1 Linear Address Space Up: understand-html Previous: 4.7 Mapping addresses to   Contents   Index
One of the principal advantages of virtual memory is that each process has its own virtual address space, which is mapped to physical memory by the operating system. In this chapter we will discuss the process address space and how Linux manages it.
The kernel treats the userspace portion of the address space very differently to the kernel portion. For example, allocations for the kernel are satisfied immediately5.1 and are visible globally no matter what process is on the CPU. With a process, space is simply reserved in the linear address space by pointing a page table entry to a read-only globally visible page filled with zeros. On writing, a page fault is triggered which results in a new page being allocated, filled with zeros5.2, placed in the page table entry and marked writable.
The userspace portion is not trusted or presumed to be constant. After each context switch, the userspace portion of the linear address space can potentially change except when a lazy Translation Lookaside Buffer (TLB) switch is used as discussed later in Section 5.3. As a result of this, the kernel must be prepared to catch all exception and addressing errors raised from userspace. This is discussed in Section 5.5.
This chapter begins with how the linear address space is broken up and what the purpose of each section is. We then cover the structures maintained to describe each process, how they are allocated, initialised and then destroyed. Next, we will cover how individual regions within the process space are created and all the various functions associated with them. That will bring us to exception handling related to the process address space, page faulting and the various cases that occur to satisfy a page fault. Finally, we will cover how the kernel safely copies information to and from userspace.
- ... immediately5.1
vmalloc()is partially an exception as a minor page fault may occur to update the process page tables, but the page will still be allocated immediately upon request.
- ... zeros5.2
- It is filled with zeros so that the new page will appear exactly the same as the global zero filled page to userspace
- 5.1 Linear Address Space
- 5.2 Managing the Address Space
- 5.3 Process Address Space Descriptor
- 5.4 Memory Regions
- 5.4.1 File/Device backed memory regions
- 5.4.2 Creating A Memory Region
- 5.4.3 Finding a Mapped Memory Region
- 5.4.4 Finding a Free Memory Region
- 5.4.5 Inserting a memory region
- 5.4.6 Merging contiguous regions
- 5.4.7 Remapping and moving a memory region
- 5.4.8 Locking a Memory Region
- 5.4.9 Unlocking the region
- 5.4.10 Fixing up regions after locking
- 5.4.11 Deleting a memory region
- 5.4.12 Deleting all memory regions
- 5.5 Exception Handling
- 5.6 Page Faulting
- 5.6.1 Handling a Page Fault
- 5.6.2 Demand Allocation
- 5.6.3 Demand Paging
- 5.6.4 Copy On Write (COW) Pages
- 5.7 Copying To/From Userspace
Next: 5.1 Linear Address Space Up: understand-html Previous: 4.7 Mapping addresses to   Contents   Index Mel 2004-02-15