memleak in cgroup
From: Yang Yingliang
Date: Sun Apr 26 2020 - 07:22:19 EST
Hi,
When I doing the follow test in kernel-5.7-rc2, I found mem-free is
decreased
#!/bin/sh
cd /sys/fs/cgroup/memory/
for((i=0;i<45;i++))
do
ÂÂÂÂÂÂÂ for((j=0;j<60000;j++))
ÂÂÂÂÂÂÂ do
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ mkdir /sys/fs/cgroup/memory/yyl-cg$j
ÂÂÂÂÂÂÂ done
ÂÂÂÂÂÂÂ sleep 1
ÂÂÂÂÂÂÂ ls /sys/fs/cgroup/memory/ | grep yyl | xargs rmdir
done
before test the /proc/meminfo is:
MemTotal:ÂÂÂÂÂÂ 493554824 kB
MemFree:ÂÂÂÂÂÂÂ 491240912 kB
MemAvailable:ÂÂ 489424520 kB
Buffers:ÂÂÂÂÂÂÂÂÂÂÂ 4112 kB
Cached:ÂÂÂÂÂÂÂÂÂÂÂ 65400 kB
SwapCached:ÂÂÂÂÂÂÂÂÂÂÂ 0 kB
Active:ÂÂÂÂÂÂÂÂÂÂ 156016 kB
Inactive:ÂÂÂÂÂÂÂÂÂ 37720 kB
Active(anon):ÂÂÂÂ 128372 kB
Inactive(anon):ÂÂÂÂ 7188 kB
Active(file):ÂÂÂÂÂ 27644 kB
Inactive(file):ÂÂÂ 30532 kB
Unevictable:ÂÂÂÂÂÂÂÂÂÂ 0 kB
Mlocked:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 0 kB
SwapTotal:ÂÂÂÂÂÂ 4194300 kB
SwapFree:ÂÂÂÂÂÂÂ 4194300 kB
Dirty:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 112 kB
Writeback:ÂÂÂÂÂÂÂÂÂÂÂÂ 0 kB
AnonPages:ÂÂÂÂÂÂÂ 124356 kB
Mapped:ÂÂÂÂÂÂÂÂÂÂÂ 53724 kB
Shmem:ÂÂÂÂÂÂÂÂÂÂÂÂ 11036 kB
KReclaimable:ÂÂÂÂÂ 93488 kB
Slab:ÂÂÂÂÂÂÂÂÂÂÂÂ 599660 kB
SReclaimable:ÂÂÂÂÂ 93488 kB
SUnreclaim:ÂÂÂÂÂÂ 506172 kB
KernelStack:ÂÂÂÂÂÂ 23008 kB
PageTables:ÂÂÂÂÂÂÂÂ 4340 kB
NFS_Unstable:ÂÂÂÂÂÂÂÂÂ 0 kB
Bounce:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 0 kB
WritebackTmp:ÂÂÂÂÂÂÂÂÂ 0 kB
CommitLimit:ÂÂÂ 250971712 kB
Committed_AS:ÂÂÂ 1834448 kB
VmallocTotal:ÂÂ 135290159040 kB
VmallocUsed:ÂÂÂÂÂ 229284 kB
VmallocChunk:ÂÂÂÂÂÂÂÂÂ 0 kB
Percpu:ÂÂÂÂÂÂÂÂÂÂÂ 80896 kB
HardwareCorrupted:ÂÂÂÂ 0 kB
AnonHugePages:ÂÂÂÂ 43008 kB
ShmemHugePages:ÂÂÂÂÂÂÂ 0 kB
ShmemPmdMapped:ÂÂÂÂÂÂÂ 0 kB
FileHugePages:ÂÂÂÂÂÂÂÂ 0 kB
FilePmdMapped:ÂÂÂÂÂÂÂÂ 0 kB
CmaTotal:ÂÂÂÂÂÂÂÂÂ 65536 kB
CmaFree:ÂÂÂÂÂÂÂÂÂÂ 40480 kB
HugePages_Total:ÂÂÂÂÂÂ 0
HugePages_Free:ÂÂÂÂÂÂÂ 0
HugePages_Rsvd:ÂÂÂÂÂÂÂ 0
HugePages_Surp:ÂÂÂÂÂÂÂ 0
Hugepagesize:ÂÂÂÂÂÂ 2048 kB
Hugetlb:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 0 kB
after test:
MemTotal:ÂÂÂÂÂÂ 493554824 kB
MemFree:ÂÂÂÂÂÂÂ 484492920 kB
MemAvailable:ÂÂ 482801124 kB
Buffers:ÂÂÂÂÂÂÂÂÂÂ 21984 kB
Cached:ÂÂÂÂÂÂÂÂÂÂ 151380 kB
SwapCached:ÂÂÂÂÂÂÂÂÂÂÂ 0 kB
Active:ÂÂÂÂÂÂÂÂÂÂ 230000 kB
Inactive:ÂÂÂÂÂÂÂÂÂ 68068 kB
Active(anon):ÂÂÂÂ 130108 kB
Inactive(anon):ÂÂÂ 13804 kB
Active(file):ÂÂÂÂÂ 99892 kB
Inactive(file):ÂÂÂ 54264 kB
Unevictable:ÂÂÂÂÂÂÂÂÂÂ 0 kB
Mlocked:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 0 kB
SwapTotal:ÂÂÂÂÂÂ 4194300 kB
SwapFree:ÂÂÂÂÂÂÂ 4194300 kB
Dirty:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 36 kB
Writeback:ÂÂÂÂÂÂÂÂÂÂÂÂ 0 kB
AnonPages:ÂÂÂÂÂÂÂ 125080 kB
Mapped:ÂÂÂÂÂÂÂÂÂÂÂ 55520 kB
Shmem:ÂÂÂÂÂÂÂÂÂÂÂÂ 19220 kB
KReclaimable:ÂÂÂÂ 246696 kB
Slab:ÂÂÂÂÂÂÂÂÂÂÂ 5381572 kB
SReclaimable:ÂÂÂÂ 246696 kB
SUnreclaim:ÂÂÂÂÂ 5134876 kB
KernelStack:ÂÂÂÂÂÂ 27360 kB
PageTables:ÂÂÂÂÂÂÂÂ 4172 kB
NFS_Unstable:ÂÂÂÂÂÂÂÂÂ 0 kB
Bounce:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 0 kB
WritebackTmp:ÂÂÂÂÂÂÂÂÂ 0 kB
CommitLimit:ÂÂÂ 250971712 kB
Committed_AS:ÂÂÂ 1588600 kB
VmallocTotal:ÂÂ 135290159040 kB
VmallocUsed:ÂÂÂÂÂ 230836 kB
VmallocChunk:ÂÂÂÂÂÂÂÂÂ 0 kB
Percpu:ÂÂÂÂÂÂÂÂÂ 1827840 kB
HardwareCorrupted:ÂÂÂÂ 0 kB
AnonHugePages:ÂÂÂÂ 43008 kB
ShmemHugePages:ÂÂÂÂÂÂÂ 0 kB
ShmemPmdMapped:ÂÂÂÂÂÂÂ 0 kB
FileHugePages:ÂÂÂÂÂÂÂÂ 0 kB
FilePmdMapped:ÂÂÂÂÂÂÂÂ 0 kB
CmaTotal:ÂÂÂÂÂÂÂÂÂ 65536 kB
CmaFree:ÂÂÂÂÂÂÂÂÂÂ 40480 kB
HugePages_Total:ÂÂÂÂÂÂ 0
HugePages_Free:ÂÂÂÂÂÂÂ 0
HugePages_Rsvd:ÂÂÂÂÂÂÂ 0
HugePages_Surp:ÂÂÂÂÂÂÂ 0
Hugepagesize:ÂÂÂÂÂÂ 2048 kB
Hugetlb:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 0 kB
after echo 3 > /proc/sys/vm/drop_caches
MemTotal:ÂÂÂÂÂÂ 493554824 kB
MemFree:ÂÂÂÂÂÂÂ 485104048 kB
MemAvailable:ÂÂ 483358392 kB
Buffers:ÂÂÂÂÂÂÂÂÂÂÂ 6168 kB
Cached:ÂÂÂÂÂÂÂÂÂÂÂ 79904 kB
SwapCached:ÂÂÂÂÂÂÂÂÂÂÂ 0 kB
Active:ÂÂÂÂÂÂÂÂÂÂ 165348 kB
Inactive:ÂÂÂÂÂÂÂÂÂ 45780 kB
Active(anon):ÂÂÂÂ 130528 kB
Inactive(anon):ÂÂÂ 13800 kB
Active(file):ÂÂÂÂÂ 34820 kB
Inactive(file):ÂÂÂ 31980 kB
Unevictable:ÂÂÂÂÂÂÂÂÂÂ 0 kB
Mlocked:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 0 kB
SwapTotal:ÂÂÂÂÂÂ 4194300 kB
SwapFree:ÂÂÂÂÂÂÂ 4194300 kB
Dirty:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 8 kB
Writeback:ÂÂÂÂÂÂÂÂÂÂÂÂ 0 kB
AnonPages:ÂÂÂÂÂÂÂ 125236 kB
Mapped:ÂÂÂÂÂÂÂÂÂÂÂ 55516 kB
Shmem:ÂÂÂÂÂÂÂÂÂÂÂÂ 19220 kB
KReclaimable:ÂÂÂÂ 226332 kB
Slab:ÂÂÂÂÂÂÂÂÂÂÂ 5353952 kB
SReclaimable:ÂÂÂÂ 226332 kB
SUnreclaim:ÂÂÂÂÂ 5127620 kB
KernelStack:ÂÂÂÂÂÂ 23040 kB
PageTables:ÂÂÂÂÂÂÂÂ 4212 kB
NFS_Unstable:ÂÂÂÂÂÂÂÂÂ 0 kB
Bounce:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 0 kB
WritebackTmp:ÂÂÂÂÂÂÂÂÂ 0 kB
CommitLimit:ÂÂÂ 250971712 kB
Committed_AS:ÂÂÂ 1672424 kB
VmallocTotal:ÂÂ 135290159040 kB
VmallocUsed:ÂÂÂÂÂ 230436 kB
VmallocChunk:ÂÂÂÂÂÂÂÂÂ 0 kB
Percpu:ÂÂÂÂÂÂÂÂÂ 1379840 kB
HardwareCorrupted:ÂÂÂÂ 0 kB
AnonHugePages:ÂÂÂÂ 43008 kB
ShmemHugePages:ÂÂÂÂÂÂÂ 0 kB
ShmemPmdMapped:ÂÂÂÂÂÂÂ 0 kB
FileHugePages:ÂÂÂÂÂÂÂÂ 0 kB
FilePmdMapped:ÂÂÂÂÂÂÂÂ 0 kB
CmaTotal:ÂÂÂÂÂÂÂÂÂ 65536 kB
CmaFree:ÂÂÂÂÂÂÂÂÂÂ 40480 kB
HugePages_Total:ÂÂÂÂÂÂ 0
HugePages_Free:ÂÂÂÂÂÂÂ 0
HugePages_Rsvd:ÂÂÂÂÂÂÂ 0
HugePages_Surp:ÂÂÂÂÂÂÂ 0
Hugepagesize:ÂÂÂÂÂÂ 2048 kB
Hugetlb:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 0 kB
after test and drop caches, the /proc/cgroups is:
#subsys_nameÂÂÂ hierarchyÂÂÂÂÂÂ num_cgroupsÂÂÂÂ enabled
cpuset 11 1 1
cpuÂÂÂÂ 2ÂÂÂÂÂÂ 1ÂÂÂÂÂÂ 1
cpuacct 2ÂÂÂÂÂÂ 1ÂÂÂÂÂÂ 1
blkioÂÂ 8ÂÂÂÂÂÂ 1ÂÂÂÂÂÂ 1
memory 5 83 1
devices 3ÂÂÂÂÂÂ 41ÂÂÂÂÂ 1
freezer 6ÂÂÂÂÂÂ 1ÂÂÂÂÂÂ 1
net_cls 9ÂÂÂÂÂÂ 1ÂÂÂÂÂÂ 1
perf_eventÂÂÂÂÂ 10ÂÂÂÂÂ 1ÂÂÂÂÂÂ 1
net_prioÂÂÂÂÂÂÂ 9ÂÂÂÂÂÂ 1ÂÂÂÂÂÂ 1
hugetlb 4ÂÂÂÂÂÂ 1ÂÂÂÂÂÂ 1
pidsÂÂÂ 7ÂÂÂÂÂÂ 51ÂÂÂÂÂ 1
rdmaÂÂÂ 12ÂÂÂÂÂ 1ÂÂÂÂÂÂ 1
All the dir that created by the script is already removed, but I got:
Â- MemFree is decreased about 6.7G
Â- SUnreclaim is increased about 4.6G
Â- Percpu is increased about 1.7G
It seems we have memory leak in cgroup ?