Proxmox using swap, the everlasting thread ...

skraw

Well-Known Member
Aug 13, 2019
77
1
48
57
Hello all,

We are using kernels 5.0.15-1-pve and set swappiness globally to 0 by sysctl and in all processes by using this script

#! /bin/bash
#
# set swappiness to
SW=0

/usr/sbin/sysctl vm.swappiness=${SW}
# fix for proxmox kernel swappiness problem, yes, it must be executed twice
for i in `/usr/bin/find /sys /var/lib 2>/dev/null | /bin/grep slice | /bin/grep swappiness` ; do /bin/echo ${SW} >"${i}" ; done
for i in `/usr/bin/find /sys /var/lib 2>/dev/null | /bin/grep slice | /bin/grep swappiness` ; do /bin/echo ${SW} >"${i}" ; done

exit 0
(Taken from another thread around this topic)

On a host with few kvms this works as expected, (h)top shows zero used swap.
But on a host with around 20 kvms things are different. (h)top shows a small amount of swap used (around 9,3 M), but /proc shows this:

# grep VmSwap /proc/*/status | grep -v " 0 kB" | sort -k 2 -n -r
/proc/6552/status:VmSwap: 178924 kB
/proc/14203/status:VmSwap: 48212 kB
/proc/29332/status:VmSwap: 38884 kB
/proc/23862/status:VmSwap: 30824 kB
/proc/2143/status:VmSwap: 17904 kB
/proc/42786/status:VmSwap: 15084 kB
/proc/29740/status:VmSwap: 12092 kB
/proc/31301/status:VmSwap: 7840 kB
/proc/18264/status:VmSwap: 7692 kB
/proc/34265/status:VmSwap: 6440 kB
/proc/9954/status:VmSwap: 6392 kB
/proc/35872/status:VmSwap: 5908 kB
/proc/27786/status:VmSwap: 5744 kB
/proc/7013/status:VmSwap: 5548 kB
/proc/39290/status:VmSwap: 5340 kB
/proc/36510/status:VmSwap: 2272 kB
/proc/1772/status:VmSwap: 1932 kB
/proc/17836/status:VmSwap: 1436 kB
/proc/12571/status:VmSwap: 1396 kB
/proc/38452/status:VmSwap: 1144 kB
/proc/35166/status:VmSwap: 1012 kB
/proc/5010/status:VmSwap: 848 kB
/proc/15672/status:VmSwap: 652 kB
/proc/25142/status:VmSwap: 616 kB
/proc/4832/status:VmSwap: 496 kB
/proc/9891/status:VmSwap: 440 kB
/proc/3561/status:VmSwap: 404 kB
/proc/12441/status:VmSwap: 400 kB
/proc/2142/status:VmSwap: 364 kB
/proc/26728/status:VmSwap: 328 kB
/proc/22863/status:VmSwap: 272 kB
/proc/2144/status:VmSwap: 148 kB
/proc/15585/status:VmSwap: 80 kB

These are almost all kvms. According to my understanding this adds up to a lot more than 9M.
Here is top:

top - 14:18:42 up 148 days, 20:20, 6 users, load average: 3.41, 2.93, 3.08
Tasks: 678 total, 1 running, 677 sleeping, 0 stopped, 0 zombie
%Cpu(s): 6.5 us, 4.2 sy, 0.0 ni, 88.8 id, 0.0 wa, 0.0 hi, 0.4 si, 0.0 st
MiB Mem : 128880.3 total, 58718.4 free, 68338.0 used, 1823.8 buff/cache
MiB Swap: 7168.0 total, 7158.7 free, 9.3 used. 58613.9 avail Mem

As you can see there is no reason for swapping as almost half the mem is free.
If I cannot tune this with swappiness, what else can we do?
--
Regards
Stephan
 
Hi,

swappiness=0 does not mean you disable swap.
If you like to disable swap you have to remove the swap partition

Code:
swappiness
==========

This control is used to define how aggressive the kernel will swap
memory pages.  Higher values will increase aggressiveness, lower values
decrease the amount of swap.  A value of 0 instructs the kernel not to
initiate swap until the amount of free and file-backed pages is less
than the high water mark in a zone.

The default value is 60.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!