Section 9.7. The Anonymous Memory Layer


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.

Table 9.6. Anon Layer Functions

Function

Description

anon_alloc()

Allocates an anon slot and returns it with the lock held.

anon_copy_ptr()

Copies anon array into a given new anon array.

anon_create()

Creates the array of pointers.

anon_decref()

Decrements the reference count of an anon page.

If the reference count goes to zero, frees it and its associated page (if any).

anon_dup()

Duplicates references to size bytes worth of anon pages.

Used when duplicating a segment that contains private anon pages.

anon_free()

Frees a group of size anon pages, size in bytes, and clears the pointers to the anon enTRies.

anon_get_next_ptr()

Returns the anon pointer for the first valid entry in the anon list, starting from the given index.

anon_getpage()

Returns the kept page(s) and protections to the segment driver.

anon_get_ptr()

Returns the pointer from the list for a specified anon index.

anon_pages()

Returns a count of the number of existing anon pages in the anon array in the range.

anon_private()

Turns a reference to an object or shared anon page into a private page with a copy of the data from the original page.

anon_release()

Frees the array of pointers.

anon_resvmem()

Reserves anon space.

anon_set_ptr()

Sets list entry with a given pointer for a specified offset.

anon_unresv()

Gives back an anon reservation.

anon_zero()

Allocates a private zero-filled anon page.

anonmap_alloc()

Allocates and initializes an anon_map structure for segment associating the given swap reservation with the new anon_map.

anonmap_free()

Frees an anon map structure.

anon_map_getpages()

Allocates array of private zero-filled anon pages for empty slots and kept pages for nonempty slots within given range.

non_anon()

Returns true if the array has some empty slots.

set_anoninfo()

Is called from clock handler to sync ani_free value.





SolarisT Internals. Solaris 10 and OpenSolaris Kernel Architecture
Solaris Internals: Solaris 10 and OpenSolaris Kernel Architecture (2nd Edition)
ISBN: 0131482092
EAN: 2147483647
Year: 2004
Pages: 244

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net