HP-UX 11i v3 Memory Management Subsystem

23
Allocation of Pseudo-Swap Space
Approximately
7
/
8
of available system memory is available as pseudo-swap space. Pseudo-swap is
tracked in the global pseudo-swap reservation counters
swapmem_max (enabled pseudo-swap) and
swapmem_cnt (currently available pseudo-swap). If physical swap space is exhausted and no
additional file system swap can be acquired, pseudo-swap space is reserved for the process by
decrementing
swapmem_cnt.
For example, on a 4 GB system, swapmem_max and swapmem_cnt track approximately 3.5 GB of
pseudo-swap space, the remainder tracked by the global
sys_mem, which represents the number of
pages reserved for system use only.
Once both device swap and pseudo-swap are exhausted (that is, swapspc_cnt==0 and
swapmem_cnt==0), attempts at process creation or growth will fail.
Processes track the number of pseudo-swap pages allocated to them by incrementing a per-region
counter
r_swapmem. Once a process no longer needs its allocated pseudo-swap space,
swapmem_cnt is incremented by the amount released and r_swapmem is updated.
Pseudo-swap consumes memory that could otherwise be used for other purposes, so it is used
sparingly. The operating system periodically checks to see if physical swap space has been recently
freed. If it has, the system attempts to migrate processes using pseudo-swap only to use the available
physical swap.
swapspc_cnt is decremented by the r_swapmem value for each region on the list
until either
swapspc_cnt drops to zero or no other regions utilize pseudo-swap. swapmem_cnt is
then incremented by the amount of pseudo-swap successfully migrated.
Pseudo-Swap and Kernel Memory
Pseudo-Swap competes with the kernel for the use of system memory. Initially,
1
/
8
of available
memory (
sys_mem pages) is made unavailable for pseudo-swap use; however, this is usually not
enough to handle both kernel dynamic memory and buffer cache space. Instead, the kernel borrows
memory from pseudo-swap for these purposes, decrementing
swapmem_cnt when it borrows a
page; once
swapmem_cnt reaches zero, it starts taking pages from sys_mem until that too reaches
zero.
When borrowed pseudo-swap is returned, the amount being released is first added to sys_mem.
Once
sys_mem grows to its maximum value (maxmem - swapmem_max), any additional pages
returned are used to increase
swapmem_cnt.
Pseudo-Swap and Lockable Memory
Because pseudo-swap is related to system memory usage, the swap reservation scheme reflects
lockable memory policies. Although the system is not necessarily allocating additional memory when
a process locks itself into memory, locked pages are no longer available for general use. This causes
swapmem_cnt to be decremented to account for the pages. swapmem_cnt is also decremented by
the size of the entire process if that process gets
plocked in memory.
How Swap Space is Prioritized
All swap devices and file systems enabled for swap have an associated priority, ranging from 0
(highest priority) to 10 (lowest priority), indicating the order that swap space from a device or file
system is used. System administrators can specify swap space priority using a parameter of the
swapon(1M) command.
Swapping rotates among both devices and file systems of equal priority. Given equal priority,
however, devices are swapped to by the operating system before file systems, because devices make
more efficient use of processor time.
We recommend that you assign the same priority to most swap devices, unless some device is
significantly slower than the rest. Assigning equal priorities limits disk head movement, which
improves paging performance.