Centos – Unable to swapoff but enough physical memory is available

centoslinuxmemoryswapvirtual-memory

I have a weird problem with turning off the swap.
The server has 192 GB of memory, 154 GB free.

It's a Hypervisor running a number of Linux KVM Virtual Machines.

When trying to:

# swapoff -a
swapoff: /dev/sda2: swapoff failed: Cannot allocate memory

but memory is free:

# cat /proc/meminfo
MemTotal:       197805748 kB
MemFree:        162274264 kB
MemAvailable:   162388912 kB
Buffers:             432 kB
Cached:           353524 kB
SwapCached:       221828 kB
Active:         28253440 kB
Inactive:        5349056 kB
Active(anon):   28159204 kB
Inactive(anon):  5289320 kB
Active(file):      94236 kB
Inactive(file):    59736 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:      124999676 kB
SwapFree:       124534724 kB
Dirty:               796 kB
Writeback:             0 kB
AnonPages:      33063024 kB
Mapped:            59236 kB
Shmem:            199984 kB
Slab:             313264 kB
SReclaimable:     206596 kB
SUnreclaim:       106668 kB
KernelStack:       10784 kB
PageTables:        94012 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    223902548 kB
Committed_AS:   43094824 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      794656 kB
VmallocChunk:   34358685284 kB
HardwareCorrupted:     0 kB
AnonHugePages:  32186368 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      136564 kB
DirectMap2M:     8136704 kB
DirectMap1G:    195035136 kB

Does anyone has any idea what could be the cause ?

Best Answer

Try it:

sync ; echo 3 > /proc/sys/vm/drop_caches

and then

swapoff

Or temporary add new swap file

Related Question