Solaris Internals: Solaris 10 and OpenSolaris Kernel Architecture (2nd Edition)
9.7. The Anonymous Memory Layer
Anonymous pages are created through the anon layer interfaces. The first time a segment receives a page fault, it allocates an anon map structure (which describes where to find the anon header) and puts a pointer to the anon header into the ahp field of the anonymous map. It then allocates the slot array, big enough to hold the number of potential pages in the segment. The slot array is either a single or double indirection list, depending on how many slots are required. 32-bit systems require double indirection for segments larger than 16 Mbytes; 64-bit systems, because of larger pointer sizes, require double indirection for segments larger than 8 Mbytes. When we use single indirection, the anon header array_chunk directly references the anon slot array. When we use double indirection, the array is broken into chunks: 2,048 slot chunks for 32-bit systems and 1,024 slot chunks for 64-bit systems. An additional array of pointers is referenced by the array_chunk field pointing to each chunk. Figure 9.11 shows the single and double indirection arrays. This allocation process is handled by the anon layer interface, anon_create. The anon slot is shown below. struct anon { struct vnode *an_vp; /* vnode of anon page */ struct vnode *an_pvp; /* vnode of physical backing store */ anoff_t an_off; /* offset of anon page */ anoff_t an_poff; /* offset in vnode */ struct anon *an_hash; /* hash table of anon slots */ int an_refcnt; /* # of people sharing slot */ }; See vm/anon.h Each anon slot points to an anon structure, which describes the virtual page of memory corresponding to the page-sized area in the address space. SVR4 implementations simply had a page structure for each slot that had a physical page associated with it, or NULL if there was no physical page in memory. However, the Solaris implementation does things differently. Recall that all physical pages have a vnode and offset. The Solaris kernel identifies that physical page, which points to the swap vnode, and offset assigned to the page. Note that this is not the swap device actual vnode and offset; rather, it's a vnode and offset pointing to the swapfs file system (which we'll discuss shortly). The anon structure also contains space for other information of interest to swapfs. The anon layer functions are listed alphabetically in Table 9.6.
|
Категории