The AIX Virtual Memory Manager (VMM)


Contents

About this document
VMM overview
Real-Memory management
Free list
Persistent vs. memory segments
Paging space and virtual memory
VMM memory load control facility
VMSTAT's avm field
VMSTAT's fre field
How the system is using memory
Explanation of svmon output

About this document

This document addresses how RAM and paging space are used. This information applies to AIX Version 4.x.


VMM overview

The Virtual Memory Manager (VMM) services memory requests from the system and its applications. Virtual-memory segments are partitioned in units called pages; each page is either located in physical memory (RAM) or stored on disk until it is needed. AIX uses virtual memory in order to address more memory than is physically available in the system. The management of memory pages in RAM or on disk is handled by the VMM.


Real-Memory management

In AIX, virtual-memory segments are partitioned into 4096-byte units called pages. Real memory is divided into 4096-byte page frames. The VMM has two major functions: 1) manage the allocation of page frames, and 2) resolve references to virtual-memory pages that are not currently in RAM (stored in paging space) or do not yet exist.

In order to accomplish its task, the VMM maintains a free list of available page frames. The VMM also uses a page-replacement algorithm to determine which virtual-memory pages currently in RAM will have their page frames reassigned to the free list. The page-replacement algorithm takes into account the existence of persistent vs. working segments, repaging, and VMM thresholds.


Free list

The VMM maintains a list of free page frames that it uses to satisfy page faults. The free list is made up of unallocated page frames. AIX tries to use all of RAM all of the time, except for a small amount which it maintains on the free list. To maintain this small amount of unallocated pages the VMM will use Page Outs and Page Steals to free up space and reassign those page frames to the free list. The virtual-memory pages whose page frames are to be reassigned are selected via the VMM's page-replacement algorithm.


Persistent vs. working memory segments

AIX distinguishes between different types of memory segments, and to understand the Virtual Memory Manager, it is important to understand the difference between working and persistent segments. A persistent segment has a permanent storage location on disk. Files containing data or executable programs are mapped to persistent segments. When a Journaled File System (JFS) file is opened and accessed the file data is copied into RAM. VMM parameters control when physical memory frames allocated to persistent pages should be overwritten and used to store other data.

Working segments are transitory and exist only during their use by a process, and have no permanent disk storage location. Process stack and data regions are mapped to working segments and shared library text segments. Pages of working segments must also have disk storage locations to occupy when they cannot be kept in real memory. The disk paging space is used for this purpose. When a program exits, all of its working pages are placed back on the free list immediately.


Paging space and virtual memory

Working pages in RAM that can be modified and paged out are assigned a corresponding slot in paging space. The allocated paging space will only be used if the page needs to be paged out. However, an allocated page in paging space cannot be used by another page. It remains reserved for a particular page for as long as it exists in virtual-memory. Since persistent pages are paged out to their location on disk from which they came, paging space does not need to be allocated for persistent pages residing in RAM.

The VMM has three modes for allocating paging space: early paging space allocation, late paging space allocation and deferred paging space allocation. Early allocation policy reserves paging space whenever a memory request for a working page is made. Late allocation policy only assigns paging space when the working page is referenced. AIX Versions 4.3.2 and later implement a deferred paging space allocation policy. With deferred paging space policy, paging space blocks are not allocated until the working pages are actually paged out of memory. This significantly reduces the paging space requirements of the system.


VMM memory load control facility

When a process references a virtual-memory page that is on disk, because it either has been paged out or has never been read, the referenced page must be paged in, and this may cause one or more pages to be paged out if the number of available free page frames is low. The VMM attempts to steal page frames that have not been recently referenced, and thus unlikely to be referenced in the near future, via the page-replacement algorithm.

A successful page-replacement keeps the memory pages of all currently active processes in RAM, while the memory pages of inactive processes are paged out. However, when RAM is over-committed, it becomes difficult to choose pages for page out because they will be referenced in the near future by currently running processes. The result is that pages that will soon be referenced still get paged out and then paged in again later. When this happens, continuous paging in and paging out may occur if RAM is over-committed. This condition is called thrashing. The system spends most of its time paging in and paging out instead of executing useful instructions, and none of the active processes make any significant progress. The VMM has a memory load control algorithm that detects when the system is thrashing and then attempts to correct the condition.


VMSTAT'S avm field

avm stands for "Active Virtual Memory" and not "Available Memory". The avm value in VMSTAT indicates the number of virtual-memory pages that have been accessed but not necessarily paged out. With the previous policy of late page space allocation, avm had the same definition but since the VMM would allocate paging space disk blocks for each working page that was accessed, then the paging space blocks were equal to the avm. With deferred policy, the page space disk blocks are only allocated for the pages that need to be paged out. The avm number will grow as more processes get started and/or existing processes use more working storage. Likewise, the number will shrink as processes exit and/or free working storage.


VMSTAT'S fre field

fre is the number of 4K pages that are currently on the free list. When an application terminates, all of its working pages are immediately returned to the free list. Its persistent pages, however, remain in RAM and are not added back to the free list until they are stolen by the VMM for other programs. Persistent pages are also freed if the corresponding file is deleted.

For this reason, the fre value may not indicate all the real memory that can be readily available for use by processes. If a page frame is needed, then persistent pages related to terminated applications are among the first to be handed over to another program.

The minimum number of pages that the Virtual Memory Manager keeps on the free list is determined by the minfree parameter of vmtune. If the number of pages on the free list drops below minfree, the Virtual Memory Manager will steal pages until the free list has been restored to the maxfree value.


How the system is using memory

The svmon command can be used to determine roughly how much memory the system is using.

NOTE: PAIDE/6000 must be installed in order to use svmon. Check to see if this is installed, by executing the following command:

   $ lslpp -l perfagent.tools.

If you are at AIX Version 4.3.0 or higher, then this file can be found on the AIX Base Operating System media. Otherwise, to order PAIDE/6000, call IBM DIRECT 1-800-426-2255 or contact your local IBM representative.

As root, type svmon. Under the pgspace heading, the inuse field is the number of working pages that are in use in all of virtual memory.


Explanation of svmon output

memory:

SIZE total size of memory in 4K pages

INUSE number of pages in RAM that are in use by a process plus the number of persistent pages that belonged to a terminated process and are still resident in RAM. This value is the total size of memory minus the number of pages on the free list.

FREE number of pages on free list.

PIN number of pages pinned in RAM (a pinned page is a page that is always resident in RAM and cannot be paged out)

in use:

WORK number of working pages in RAM

PERS number of persistent pages in RAM

CLNT number of client pages in RAM (client page is a remote file page)

pin:

WORK number of working pages pinned in RAM

PERS number of persistent pages pinned in RAM

CLNT number of client pages pinned in RAM

pgspace:

SIZE total size of paging space in 4K pages

INUSE total number of allocated slots. (See explanation above on allocation of paging space).

To find out how much memory a process is using, type

$ svmon -P PID      (for one process)
                         or
$ svmon -Pau | more      (for all processes)

To see the number of working pages unique to this process' private stack and data use in all of virtual memory, look at the work type and description private. The svmon output may also list several shared segments. For a complete picture, determine which segments are unique to an individual process and which are shared with other programs. Multiply the values by 4096 to get the number of bytes in memory the process is using. The number 4096 comes from the fact that each page is 4KB in size. You can also divide the number of pages by 256 in order to get megabytes.


[ Doc Ref: 90605226714706     Publish Date: May. 05, 2000     4FAX Ref: 2449 ]