Swappiness and recycle cache

From Wikipedia, the free encyclopedia
Swappiness is a Linux kernel parameter that controls the relative weight given to swapping out runtime memory, as opposed to dropping pages from the system page cache. Swappiness can be set to values between 0 and 100 inclusive. A low value causes the kernel to avoid swapping, a higher value causes the kernel to try to use swap space. The default value is 60, and for most desktop systems, setting it to 100 may affect the overall performance, whereas setting it lower (even 0) may decrease response latency.
Value Strategy
vm.swappiness = 0 Version 3.5 and over: disables swapping
Prior to version 3.5: The kernel will swap only to avoid an out of memory condition.
vm.swappiness = 1 Version 3.5 and over: Minimum swappiness without disabling it entirely
vm.swappiness = 60 The default value.
vm.swappiness = 100 The kernel will swap aggressively.
To temporarily set the swappiness in Linux, write the desired value (e.g. 10) to /proc/sys/vm/swappiness using the following command, running as root user:
# Set the swappiness value as root
echo 10 > /proc/sys/vm/swappiness
# Alternatively, run this as a non-root user
sudo sysctl -w vm.swappiness=10
# Verify the change
cat /proc/sys/vm/swappiness
# Alternatively, verify the change
sysctl vm.swappiness
vm.swappiness = 1
Permanent changes are made in /etc/sysctl.conf via the following configuration line (inserted, if not present):

vm.swappiness = 1

Writing to this will cause the kernel to drop clean caches, as well as
reclaimable slab objects like dentries and inodes.  Once dropped, their
memory becomes free.
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free reclaimable slab objects (includes dentries and inodes):
echo 2 > /proc/sys/vm/drop_caches
To free slab objects and pagecache:
echo 3 > /proc/sys/vm/drop_caches
see https://www.kernel.org/doc/Documentation/sysctl/vm.txt

发布于: 2014, 点击数:

GoSense v0.2.4 驱动! RSS