Desativando a troca por apenas um processo com cgroups?

14

Eu gostaria de desativar a troca por apenas um processo. O swap deve funcionar normalmente para os outros processos.

Como posso implementar isso com cgroups?

    
por iNode 02.06.2013 / 11:50

1 resposta

9

De a documentação do kernel sobre memory.swappiness:

5.3 swappiness

Similar to /proc/sys/vm/swappiness, but affecting a hierarchy of groups only.

Following cgroups' swappiness can't be changed.
- root cgroup (uses /proc/sys/vm/swappiness).
- a cgroup which uses hierarchy and it has other cgroup(s) below it.
- a cgroup which uses hierarchy and not the root of hierarchy.

Do Portal do Cliente Red Hat:

memory.swappiness

sets the tendency of the kernel to swap out process memory used by tasks in this cgroup instead of reclaiming pages from the page cache. This is the same tendency, calculated the same way, as set in /proc/sys/vm/swappiness for the system as a whole. The default value is 60. Values lower than 60 decrease the kernel's tendency to swap out process memory, values greater than 60 increase the kernel's tendency to swap out process memory, and values greater than 100 permit the kernel to swap out pages that are part of the address space of the processes in this cgroup.

Note that a value of 0 does not prevent process memory being swapped out; swap out might still happen when there is a shortage of system memory because the global virtual memory management logic does not read the cgroup value. To lock pages completely, use mlock() instead of cgroups.

:: You cannot change the swappiness of the following groups:
* the root cgroup, which uses the swappiness set in /proc/sys/vm/swappiness.
* a cgroup that has child groups below it.

EDITAR: Se você estiver interessado em saber exatamente como configurá-lo, defina-o exatamente como a maioria dos outros atributos do cgroup:

 # cd /mnt/cgroup/<cgroupName>
 # cat memory.swappiness
 60
 # echo "59 " > memory.swappiness
 # cat memory.swappiness
 59
    
por 02.06.2013 / 17:56