Responsiveness

From openSUSE

Linux systems can use a swap partition or file to augment the available physical ram, allowing more memory to be used for programs or data than would be possible with ram alone.


There is a lengthy debate on the subject of tuning swappiness in the 2.6 kernel branch. Some people believe that it is good for computers with very little ram to have a high swappiness value which means that process memory will be swapped out of physical memory to be paged on the disk. They also believe that on a system with plenty of physical ram (over 512mb) it is not desirable for memory to be paged to disk.

The other side of the debate which includes -mm kernel branch maintainer Andrew Morten states, "My point is that decreasing the tendency of the kernel to swap stuff out is wrong. You really don't want hundreds of megabytes of BloatyApp's untouched memory floating about in the machine. Get it out on the disk, use the memory for something useful." See article on swappiness


The Linux kernel can adjust the amount of swap used through the /proc kernel interface. The location of this setting is /proc/sys/vm/swappiness, for the 2.6.x kernel the value can be 0 to 100, higher numbers use more swap.


To adjust this setting you must have administrator privileges. For most users Sudo will be the easiest way to do this, however if your user account has not been setup with Sudo you must either use Su or login as root.


This document will assume the user has logged in as root or used su to change to root, to change this setting using Sudo, prefix all commands with the "sudo" command. This document also assumes you intend to change this value to 100, to change to a different value alter the number used in these commands.

Change directory to /proc/sys/vm:

    cd /proc/sys/vm

Change the value of swapiness to a 100:

    echo "100" > swappiness

Then exit from the root account if you used su or logged in as root, if you used sudo this is not required:

    exit

Note that any /proc settings changed directly will be reset when the system is powered off. To change this value permanently enter the following command by prefixing with the "sudo" command, or while logged in as root:

echo "vm.swappiness = 100" >> /etc/sysctl.conf