/proc/swaps is incorrect in LXC (Bug?)

denos

Well-Known Member
Jul 27, 2015
83
41
58
We've noticed that in recent versions of Proxmox, that /proc/swaps is wrong. It boils down to this inside the container:

Code:
# free -m
              total        used        free      shared  buff/cache   available
Mem:          64738         118       64610           7           8       64619
Swap:         16384           0       16384

That is correctly reporting 16384 free. Here's /proc/meminfo on the same container which is also correct:
Code:
# cat /proc/meminfo
MemTotal:       66291712 kB
MemFree:        66161292 kB
MemAvailable:   66170268 kB
Buffers:               0 kB
Cached:             8976 kB
SwapCached:            0 kB
Active:           100056 kB
Inactive:           8976 kB
Active(anon):     100056 kB
Inactive(anon):     8184 kB
Active(file):          0 kB
Inactive(file):      792 kB
Unevictable:           0 kB
Mlocked:           21992 kB
SwapTotal:      16777216 kB
SwapFree:       16777216 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:        100056 kB
Mapped:             4488 kB
Shmem:              8184 kB
KReclaimable:    5051688 kB
Slab:               0 kB
SReclaimable:          0 kB
SUnreclaim:            0 kB
KernelStack:       36816 kB
PageTables:       113164 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    859064848 kB
Committed_AS:   74072316 kB
VmallocTotal:   34359738367 kB
VmallocUsed:    13546056 kB
VmallocChunk:          0 kB
Percpu:           142400 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:    18957800 kB
DirectMap2M:    202948608 kB
DirectMap1G:    1389363200 kB

But here's the problem, /proc/swaps shows all of the swap as used:
Code:
# cat /proc/swaps
Filename                Type        Size    Used    Priority
none                                    virtual        16777216    16777216    0

Proxmox host details:
Code:
# pveversion --verbose
proxmox-ve: 6.2-2 (running kernel: 5.4.73-1-pve)
pve-manager: 6.2-15 (running version: 6.2-15/48bd51b6)
pve-kernel-5.4: 6.3-1
pve-kernel-helper: 6.3-1
pve-kernel-5.4.73-1-pve: 5.4.73-1
pve-kernel-5.4.34-1-pve: 5.4.34-2
ceph-fuse: 12.2.11+dfsg1-2.1+b1
corosync: 3.0.4-pve1
criu: 3.11-3
glusterfs-client: 5.5-3
ifupdown: 0.8.35+pve1
ksm-control-daemon: 1.3-1
libjs-extjs: 6.0.1-10
libknet1: 1.16-pve1
libproxmox-acme-perl: 1.0.5
libpve-access-control: 6.1-3
libpve-apiclient-perl: 3.0-3
libpve-common-perl: 6.2-4
libpve-guest-common-perl: 3.1-3
libpve-http-server-perl: 3.0-6
libpve-storage-perl: 6.2-10
libqb0: 1.0.5-1
libspice-server1: 0.14.2-4~pve6+1
lvm2: 2.03.02-pve4
lxc-pve: 4.0.3-1
lxcfs: 4.0.3-pve3
novnc-pve: 1.1.0-1
proxmox-backup-client: 1.0.1-1
proxmox-mini-journalreader: 1.1-1
proxmox-widget-toolkit: 2.3-10
pve-cluster: 6.2-1
pve-container: 3.2-3
pve-docs: 6.2-6
pve-edk2-firmware: 2.20200531-1
pve-firewall: 4.1-3
pve-firmware: 3.1-3
pve-ha-manager: 3.1-1
pve-i18n: 2.2-2
pve-qemu-kvm: 5.1.0-6
pve-xtermjs: 4.7.0-2
qemu-server: 6.2-20
smartmontools: 7.1-pve2
spiceterm: 3.1-1
vncterm: 1.6-2
zfsutils-linux: 0.8.5-pve1

Here's /proc/swaps on the hypervisor (correct):

Code:
# cat /proc/swaps
Filename                Type        Size    Used    Priority
/dev/zd16                               partition    67108860    0    -2

Any ideas?
 
I traced the bug to lxcfs:
Working: 4.0.3-pve2
Broken: 4.0.3-pve3

I think help is needed from a Proxmox team member on this one.
 

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!