[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

System Management Concepts:
Operating System and Devices

Paging Space Overview

A paging space is a type of logical volume with allocated disk space that stores information which is resident in virtual memory but is not currently being accessed. This logical volume has an attribute type equal to paging, and is usually simply referred to as paging space or swap space. When the amount of free RAM in the system is low, programs or data that have not been used recently are moved from memory to paging space to release memory for other activities.

Another type of paging space is available that can be accessed through a device that uses an NFS server for paging-space storage. For an NFS client to access this paging space, the NFS server must have a file created and exported to that client. The file size represents the paging space size for the client.

The amount of paging space required depends on the type of activities performed on the system. If paging space runs low, processes can be lost, and if paging space runs out, the system can panic. When a paging-space low condition is detected, define additional paging space. For instructions, see Paging Space Troubleshooting in AIX 5L Version 5.2 System Management Guide: Operating System and Devices.

The logical volume paging space is defined by making a new paging-space logical volume or by increasing the size of existing paging-space logical volumes. To increase the size of an NFS paging space, the file that resides on the server must be increased by the correct actions on the server.

The total space available to the system for paging is the sum of the sizes of all active paging-space logical volumes.

The following sections provide more information about paging spaces:

Paging Space Allocation Policies

AIX uses two modes for paging space allocation. The PSALLOC environment variable determines which paging space allocation algorithm is used: late or early. The default is late. You can switch to an early paging space allocation mode by changing the value of the PSALLOC environment variable, but there are several factors to consider before making such a change. When using the early allocation algorithm, in a worst-case scenario, it is possible to crash the system by using up all available paging space.

Comparing Late and Early Paging Space Allocation

The operating system uses the PSALLOC environment variable to determine the mechanism used for memory and paging space allocation. If the PSALLOC environment variable is not set, is set to null, or is set to any value other than early, the system uses the default late allocation algorithm.

The late allocation algorithm assists in the efficient use of disk resources and supports applications that prefer a sparse allocation algorithm for resource management. This algorithm does not reserve paging space when a memory request is made; it approves the request and assigns paging space when pages are touched. Some programs allocate large amounts of virtual memory and then use only a fraction of the memory. Examples of such programs are technical applications that use sparse vectors or matrices as data structures. The late allocation algorithm is also more efficient for a real-time, demand-paged kernel such as the one in the operating system.

However, this paging space might never be used, especially on systems with large real memory where paging is rare. Therefore, the late algorithm further delays allocation of paging space until it is necessary to page out the page, which results in no wasted paging space allocation. This does result, however, in additional overcommitment of paging space.

It is possible to overcommit resources when using the late allocation algorithm for paging space allocation. In this case, when one process gets the resource before another, a failure results. The operating system attempts to avoid complete system failure by killing processes affected by the resource overcommitment. The SIGDANGER signal is sent to notify processes that the amount of free paging space is low. If the paging space situation reaches an even more critical state, selected processes that did not receive the SIGDANGER signal are sent a SIGKILL signal.

You can use the PSALLOC environment variable to switch to an early allocation algorithm, which allocates paging space for the executing process at the time the memory is requested. If there is insufficient paging space available at the time of the request, the early allocation mechanism fails the memory request.

If the PSALLOC environment variable is set to early, then every program started in that environment from that point on, but not including currently running processes, runs in the early allocation environment. In the early allocation environment, interfaces such as the malloc subroutine and the brk subroutine will fail if sufficient paging space cannot be reserved when the request is made.

Processes run in the early allocation environment mode are not sent the SIGKILL signal if a low paging space condition occur.

There are different ways to change the PSALLOC environment variable to early, depending on how broadly you want to apply the change. (See Setting the PSALLOC Environment Variable for Early Allocation Mode in AIX 5L Version 5.2 System Management Guide: Operating System and Devices.)

The following memory allocation interface subroutines are affected by a switch to an early allocation environment:

Early Allocation Mode Considerations

The early allocation algorithm guarantees as much paging space as requested by a memory allocation request. Thus, correct paging space allocation on the system disk is important for efficient operations. When available paging space drops below a certain threshold, new processes cannot be started and currently running processes might not be able to get more memory. Any processes running under the default late allocation mode become highly vulnerable to the SIGKILL signal mechanism. In addition, because the operating system kernel sometimes requires memory allocation, it is possible to crash the system by using up all available paging space.

Before you use the early allocation mode throughout the system, it is very important to define an adequate amount of paging space for the system. The paging space required for early allocation mode is almost always greater than the paging space required for the default late allocation mode. How much paging space to define depends on how your system is used and what programs you run. A good starting point for determining the right mix for your system is to define a paging space four times greater than the amount of physical memory.

Certain applications can use extreme amounts of paging space if they are run in early allocation mode. The AIXwindows server currently requires more than 250 MB of paging space when the application runs in early allocation mode. The paging space required for any application depends on how the application is written and how it is run.

All commands and subroutines that show paging space and process memory use include paging space allocated under early allocation mode. The lsps command uses the -s flag to display total paging space allocation, including paging space allocated under early allocation mode.

Programming Interface

The programming interface that controls the paging space allocation mode uses the PSALLOC environment variable. To ensure that an application always runs under the desired mode (with or without early paging space allocation), do the following:

  1. Use the getenv subroutine to examine the current state of the PSALLOC environment variable.
  2. If the value of the PSALLOC environment variable is not the value required by the application, use the setenv subroutine to alter the value of the environment variable. Because only the execve subroutine examines the state of the PSALLOC environment variable, call the execve subroutine with the same set of parameters and environment received by the application. When the application reexamines the state of the PSALLOC environment variable and finds the correct value, the application continues normally.
  3. If the getenv subroutine reveals that the current state of the PSALLOC environment variable is correct, no modification is needed. The application continues normally.

Paging Space Default Size

The default paging space size is determined during the system customization phase of AIX installation according to the following standards:

Paging Space File, Commands, and Options

The /etc/swapspaces file specifies the paging-space devices that are activated by the swapon -a command. A paging space is added to this file when it is created by the mkps -a command, removed from the file when it is deleted by the rmps command, and added or removed by the chps -a command. If the paging space size is too large, you can subtract logical partitions from the paging space without rebooting using the chps -d command.

The following commands are used to manage paging space:

chps Changes the attributes of a paging space.
lsps Displays the characteristics of a paging space.
mkps Adds an additional paging space. The mkps command uses the mklv command with a specific set of options when creating a paging space logical volume. To create NFS paging spaces, the mkps command uses the mkdev command with a different set of options. For NFS paging spaces, the mkps command needs the host name of the NFS server and the path name of the file that is exported from the server.
rmps Removes an inactive paging space.
swapoff Deactivates one or more paging space without rebooting the system. Information in the paging space is moved to other active paging space areas. The deactivated paging space can then be removed using the rmps command.
swapon Activates a paging space. The swapon command is used during early system initialization to activate the initial paging-space device. During a later phase of initialization, when other devices become available, the swapon command is used to activate additional paging spaces so that paging activity occurs across several devices.

Some of the following options are required for all logical volume paging spaces:

The following options are used to maximize paging performance with a logical volume:

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]