Once we have decided how much swap space we need, we need to decide how to configure it. In the event that we do start paging, like other IO to disk, it would be best if we can spread the load over multiple physical disks. HP-UX uses swap device priorities to select the next device to swap to. Disks and volumes that are configured as swap device have a default priority of 1. A higher number means a lower priority. The virtual memory system will use devices with the highest priority first and then move on to devices with a lower priority. With a default priority = 1, this means that the virtual memory system will interleave evenly across all configured swap devices with the same priority. As such, it's a good idea if we can try to make all swap devices the same size, configured on different physical disks, and all with the same (default) priority. Being the same size means they will fill up at the same rate, maintaining our interleaving behavior. Device swap areas (except primary swap which must be strictly contiguous) do not need to be of any special volume configuration, although it does make sense to mirror swap volumes if possible. Filesystem swap comes next but should be avoided at all costs; the virtual memory system will be competing with the filesystem for IO as well as disk space. In fact, even if a filesystem swap area has a lower priority, it will not be used until all device swap areas are full. Use filesystem swap as a last resort. Before we go headlong into the swapon command, there are some kernel parameters that affect how much swap space we can configure: -
maxswapchunks : To total the number of swap chunks allowed on the system. This parameter will size a kernel table known as the swap table ( swaptab ) that lists all of the chunks of swap space available on all device/filesystem swap areas. The maximum for the parameter is 16,384. NOTE: At the time of this writing, this parameter was still a configurable parameter in HP-UX on the PA-RISC platform. This situation may have changed by the time you read this. -
swchunk : The size of a chunk of allocated swap space (default = 2048, 1K blocks = 2MB). Together with maxswapchunks , we can work out how the maximum amount of swap space that can be configured on a system: 16384 ( maxswapchunks ) x 2048 ( swchunk = 2MB) = 32GB If we need to increase that maximum amount of swap space available on a system, we can consider retuning maxswapchunks and/or swchunk . If we exceed the maximum allowed value, we will receive an error message whenever we use the swapon command. -
nswapdev : The total number of disk/volume device swap areas allowed (10 by default). -
nswapfs : The total of filesystem swap areas allowed (10 by default). -
remote_nfs_swap : Enable this only if you have an NFS diskless server. Swapping across the network doesn't even bear thinking about. -
swapmem_on : Whether or not to use pseudo-swap . The default is 1 (ON) for good reason. All these kernel parameters will require a reboot if you need to change them. Below, a VxVM volume is added to the list of swap devices. root@hpeos003[] vxprint -g ora1 dump3 TY NAME ASSOC KSTATE LENGTH PLOFFS STATE TUTIL0 PUTIL0 v dump3 fsgen ENABLED 204800 - ACTIVE - - pl dump3-01 dump3 ENABLED 204800 - ACTIVE - - sd ora_disk2-02 dump3-01 ENABLED 204800 0 - - - root@hpeos003[] swapon /dev/vx/dsk/ora1/dump3 root@hpeos003[] swapinfo Kb Kb Kb PCT START/ Kb TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME dev 2097152 0 2097152 0% 0 - 1 /dev/vg00/lvol2 dev 204800 0 204800 0% 0 - 1 /dev/vx/dsk/ora1/dump3 reserve - 120396 -120396 memory 743024 25132 717892 3% root@hpeos003[] We should all be aware of the format of the swapinfo command. The lines to note are the reserve line and the memory line. The reserve line details the data currently in memory that has had swap space put on hold (reserved) in case the data needs to be paged-out. The memory line lists the amount of pseudo-swap configured. Also note that the usage on the memory line includes usage by other kernel subsystems and not just pseudo-swap. Finally, remember to add an appropriate entry to the /etc/fstab file to ensure that your additional swap areas are activated after reboot. |