Last active
July 19, 2019 19:57
-
-
Save jcvenegas/a1a09b756896de40b25e32e8931a9daa to your computer and use it in GitHub Desktop.
Calculating Cgroup memory usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create runc container | |
ef10581a552ca4bc529be8789e63acb662501f78fbc1856d5c42a29c8b364a61 | |
cgroup info: runc-1/ef10581a552ca4bc529be8789e63acb662501f78fbc1856d5c42a29c8b364a61 | |
type: memory | |
procs: | |
process:bash� | |
pid: 4083 | |
tasks: | |
process:bash� | |
pid: 4083 | |
create kata container | |
f27b0617c6ccc26812e9536c73749a78a63c101e6ab1084322123fc536a9f3f1 | |
Memory stats beore move hypervisor to runc cgroup | |
sleep 10s to wait cgroup refresh | |
/kata-1 24 - 5.5M - - | |
/kata-1/kata-sandbox 24 - 5.5M - - | |
/runc-1 1 - 1.4M - - | |
/runc-1/ef10581a552ca4bc529be8789e63acb662501f78fbc1856d5c42a29c8b364a61 1 - 1.4M - - | |
Directory /sys/fs/cgroup/memory/runc-1: | |
└─ef10581a552ca4bc529be8789e63acb662501f78fbc1856d5c42a29c8b364a61 | |
└─4083 bash | |
Directory /sys/fs/cgroup/memory/kata-1: | |
└─kata-sandbox | |
├─4194 /opt/kata/bin/qemu-system-x86_64 -name sandbox-f27b0617c6ccc26812e95... | |
├─4201 /opt/kata/libexec/kata-containers/kata-proxy -listen-socket unix:///... | |
└─4220 /opt/kata/libexec/kata-containers/kata-shim -agent unix:///run/vc/sb... | |
check again memory cgroup tasks | |
cgroup info: runc-1/ef10581a552ca4bc529be8789e63acb662501f78fbc1856d5c42a29c8b364a61 | |
type: memory | |
procs: | |
process:bash� | |
pid: 4083 | |
tasks: | |
process:bash� | |
pid: 4083 | |
memory.usage_in_bytes: | |
1568768 | |
memory.stat: | |
cache 0 | |
rss 561152 | |
rss_huge 0 | |
shmem 0 | |
mapped_file 0 | |
dirty 0 | |
writeback 0 | |
swap 0 | |
pgpgin 1386 | |
pgpgout 1306 | |
pgfault 1221 | |
pgmajfault 0 | |
inactive_anon 0 | |
active_anon 417792 | |
inactive_file 0 | |
active_file 0 | |
unevictable 0 | |
hierarchical_memory_limit 2147483648 | |
hierarchical_memsw_limit 4294967296 | |
total_cache 0 | |
total_rss 561152 | |
total_rss_huge 0 | |
total_shmem 0 | |
total_mapped_file 0 | |
total_dirty 0 | |
total_writeback 0 | |
total_swap 0 | |
total_pgpgin 1386 | |
total_pgpgout 1306 | |
total_pgfault 1221 | |
total_pgmajfault 0 | |
total_inactive_anon 0 | |
total_active_anon 417792 | |
total_inactive_file 0 | |
total_active_file 0 | |
total_unevictable 0 | |
recent_rotated_anon 1023 | |
recent_rotated_file 0 | |
recent_scanned_anon 1692 | |
recent_scanned_file 0 | |
Move qemu process to runc memory cgroup | |
Memory stats after move hypervisor to runc cgroup | |
sleep 10s to wait cgroup refresh | |
/kata-1 24 - 5.7M - - | |
/kata-1/kata-sandbox 24 - 5.7M - - | |
/runc-1 1 - 1.5M - - | |
/runc-1/ef10581a552ca4bc529be8789e63acb662501f78fbc1856d5c42a29c8b364a61 1 - 1.5M - - | |
Directory /sys/fs/cgroup/memory/runc-1: | |
└─ef10581a552ca4bc529be8789e63acb662501f78fbc1856d5c42a29c8b364a61 | |
├─4083 bash | |
└─4194 /opt/kata/bin/qemu-system-x86_64 -name sandbox-f27b0617c6ccc26812e95... | |
Directory /sys/fs/cgroup/memory/kata-1: | |
└─kata-sandbox | |
├─4201 /opt/kata/libexec/kata-containers/kata-proxy -listen-socket unix:///... | |
└─4220 /opt/kata/libexec/kata-containers/kata-shim -agent unix:///run/vc/sb... | |
check again memory cgroup tasks | |
cgroup info: runc-1/ef10581a552ca4bc529be8789e63acb662501f78fbc1856d5c42a29c8b364a61 | |
type: memory | |
procs: | |
process:bash� | |
pid: 4083 | |
process:/opt/kata/bin/qemu | |
pid: 4194 | |
tasks: | |
process:bash� | |
pid: 4083 | |
process:/opt/kata/bin/qemu | |
pid: 4194 | |
process:/opt/kata/bin/qemu | |
pid: 4195 | |
process:/opt/kata/bin/qemu | |
pid: 4198 | |
process:/opt/kata/bin/qemu | |
pid: 4199 | |
process:/opt/kata/bin/qemu | |
pid: 4215 | |
process:/opt/kata/bin/qemu | |
pid: 4216 | |
memory.usage_in_bytes: | |
1581056 | |
memory.stat: | |
cache 0 | |
rss 561152 | |
rss_huge 0 | |
shmem 0 | |
mapped_file 0 | |
dirty 0 | |
writeback 0 | |
swap 0 | |
pgpgin 1386 | |
pgpgout 1306 | |
pgfault 1221 | |
pgmajfault 0 | |
inactive_anon 0 | |
active_anon 417792 | |
inactive_file 0 | |
active_file 0 | |
unevictable 0 | |
hierarchical_memory_limit 2147483648 | |
hierarchical_memsw_limit 4294967296 | |
total_cache 0 | |
total_rss 561152 | |
total_rss_huge 0 | |
total_shmem 0 | |
total_mapped_file 0 | |
total_dirty 0 | |
total_writeback 0 | |
total_swap 0 | |
total_pgpgin 1386 | |
total_pgpgout 1306 | |
total_pgfault 1221 | |
total_pgmajfault 0 | |
total_inactive_anon 0 | |
total_active_anon 417792 | |
total_inactive_file 0 | |
total_active_file 0 | |
total_unevictable 0 | |
recent_rotated_anon 1023 | |
recent_rotated_file 0 | |
recent_scanned_anon 1692 | |
recent_scanned_file 0 | |
to monitor the runc cgroup run: | |
systemd-cgtop /runc-1 | |
systemd-cgls /sys/fs/cgroup/memory/runc-1 --no-pager | |
stress VM memory | |
0% [Working] | |
0% [Waiting for headers] [Waiting for headers] | |
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] | |
0% [Waiting for headers] [1 InRelease 0 B/88.7 kB 0%] | |
Get:2 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB] | |
0% [2 InRelease 0 B/242 kB 0%] [1 InRelease 3652 B/88.7 kB 4%] | |
0% [2 InRelease 46.8 kB/242 kB 19%] [1 InRelease 83.2 kB/88.7 kB 94%] | |
0% [2 InRelease 64.3 kB/242 kB 27%] | |
0% [1 InRelease gpgv 88.7 kB] [2 InRelease 64.3 kB/242 kB 27%] | |
0% [1 InRelease gpgv 88.7 kB] | |
0% [Waiting for headers] | |
0% [2 InRelease gpgv 242 kB] [Waiting for headers] | |
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] | |
0% [2 InRelease gpgv 242 kB] [3 InRelease 0 B/88.7 kB 0%] [Waiting for headers] | |
Get:4 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [5436 B] | |
0% [2 InRelease gpgv 242 kB] [3 InRelease 42.9 kB/88.7 kB 48%] [4 Packages 5436 | |
0% [2 InRelease gpgv 242 kB] [3 InRelease 55.0 kB/88.7 kB 62%] | |
0% [4 Packages store 0 B] [2 InRelease gpgv 242 kB] [3 InRelease 59.1 kB/88.7 k | |
0% [2 InRelease gpgv 242 kB] [3 InRelease 60.4 kB/88.7 kB 68%] [Waiting for hea | |
0% [2 InRelease gpgv 242 kB] [Waiting for headers] | |
Get:5 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [4172 B] | |
0% [2 InRelease gpgv 242 kB] [Waiting for headers] [5 Packages 4172 B/4172 B 10 | |
0% [2 InRelease gpgv 242 kB] [Waiting for headers] [Waiting for headers] | |
0% [5 Packages store 0 B] [2 InRelease gpgv 242 kB] [Waiting for headers] [Wait | |
0% [2 InRelease gpgv 242 kB] [Waiting for headers] [Waiting for headers] | |
Get:6 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB] | |
0% [2 InRelease gpgv 242 kB] [6 InRelease 7839 B/74.6 kB 11%] [Waiting for head | |
Get:7 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [725 kB] | |
0% [2 InRelease gpgv 242 kB] [6 InRelease 33.5 kB/74.6 kB 45%] [7 Packages 0 B/ | |
0% [2 InRelease gpgv 242 kB] [7 Packages 28.1 kB/725 kB 4%] | |
0% [7 Packages 60.5 kB/725 kB 8%] | |
0% [3 InRelease gpgv 88.7 kB] [7 Packages 60.5 kB/725 kB 8%] | |
Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1344 kB] | |
0% [3 InRelease gpgv 88.7 kB] [8 Packages 6565 B/1344 kB 0%] [7 Packages 191 kB | |
0% [8 Packages 760 kB/1344 kB 57%] [7 Packages 654 kB/725 kB 90%] | |
0% [6 InRelease gpgv 74.6 kB] [8 Packages 760 kB/1344 kB 57%] [7 Packages 654 k | |
0% [6 InRelease gpgv 74.6 kB] [8 Packages 780 kB/1344 kB 58%] [Waiting for head | |
Get:9 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [580 kB] | |
0% [6 InRelease gpgv 74.6 kB] [8 Packages 780 kB/1344 kB 58%] [9 Packages 55.1 | |
0% [7 Packages store 0 B] [6 InRelease gpgv 74.6 kB] [8 Packages 780 kB/1344 kB | |
0% [7 Packages store 0 B] [6 InRelease gpgv 74.6 kB] [9 Packages 198 kB/580 kB | |
0% [6 InRelease gpgv 74.6 kB] [Waiting for headers] [9 Packages 361 kB/580 kB 6 | |
0% [8 Packages store 0 B] [6 InRelease gpgv 74.6 kB] [Waiting for headers] [9 P | |
0% [8 Packages store 0 B] [6 InRelease gpgv 74.6 kB] [Waiting for headers] | |
Get:10 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [13.5 kB] | |
0% [8 Packages store 0 B] [6 InRelease gpgv 74.6 kB] [10 Packages 6561 B/13.5 k | |
0% [8 Packages store 0 B] [6 InRelease gpgv 74.6 kB] | |
0% [6 InRelease gpgv 74.6 kB] [Waiting for headers] | |
0% [9 Packages store 0 B] [6 InRelease gpgv 74.6 kB] [Waiting for headers] | |
Get:11 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [186 kB] | |
0% [9 Packages store 0 B] [6 InRelease gpgv 74.6 kB] [11 Packages 6559 B/186 kB | |
0% [9 Packages store 0 B] [6 InRelease gpgv 74.6 kB] [Waiting for headers] | |
0% [6 InRelease gpgv 74.6 kB] [Waiting for headers] | |
0% [10 Packages store 0 B] [6 InRelease gpgv 74.6 kB] [Waiting for headers] | |
0% [6 InRelease gpgv 74.6 kB] [Waiting for headers] | |
0% [11 Packages store 0 B] [6 InRelease gpgv 74.6 kB] [Waiting for headers] | |
0% [6 InRelease gpgv 74.6 kB] [Waiting for headers] | |
32% [Waiting for headers] | |
Get:12 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB] | |
32% [12 Packages 0 B/11.3 MB 0%] | |
44% [12 Packages 2429 kB/11.3 MB 21%] | |
59% [12 Packages 5722 kB/11.3 MB 50%] | |
81% [12 Packages 10.3 MB/11.3 MB 91%] | |
86% [Working] | |
86% [12 Packages store 0 B] [Waiting for headers] | |
Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [10.8 kB] | |
86% [12 Packages store 0 B] [13 Packages 0 B/10.8 kB 0%] | |
86% [12 Packages store 0 B] | |
Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [7235 B] | |
86% [12 Packages store 0 B] [14 Packages 0 B/7235 B 0%] | |
86% [12 Packages store 0 B] | |
Get:15 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1245 kB] | |
86% [12 Packages store 0 B] [15 Packages 0 B/1245 kB 0%] 2430 kB/s 0s | |
92% [12 Packages store 0 B] 2430 kB/s 0s | |
Get:16 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [889 kB] | |
92% [12 Packages store 0 B] [16 Packages 0 B/889 kB 0%] 2430 kB/s 0s | |
96% [12 Packages store 0 B] 2430 kB/s 0s | |
Get:17 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [3927 B] | |
96% [12 Packages store 0 B] [17 Packages 0 B/3927 B 0%] 2430 kB/s 0s | |
96% [12 Packages store 0 B] 2430 kB/s 0s | |
Get:18 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [2496 B] | |
96% [12 Packages store 0 B] [18 Packages 0 B/2496 B 0%] 2430 kB/s 0s | |
96% [12 Packages store 0 B] 2430 kB/s 0s | |
97% [Working] 2430 kB/s 0s | |
97% [13 Packages store 0 B] 2430 kB/s 0s | |
97% [Working] 2430 kB/s 0s | |
97% [14 Packages store 0 B] 2430 kB/s 0s | |
98% [Working] 2430 kB/s 0s | |
98% [15 Packages store 0 B] 2430 kB/s 0s | |
98% [Working] 2430 kB/s 0s | |
98% [16 Packages store 0 B] 2430 kB/s 0s | |
99% [Working] 2430 kB/s 0s | |
99% [17 Packages store 0 B] 2430 kB/s 0s | |
99% [Working] 2430 kB/s 0s | |
99% [18 Packages store 0 B] 2430 kB/s 0s | |
100% [Working] 2430 kB/s 0s | |
Fetched 16.9 MB in 7s (2284 kB/s) | |
Reading package lists... 0% | |
Reading package lists... 0% | |
Reading package lists... 0% | |
Reading package lists... 7% | |
Reading package lists... 7% | |
Reading package lists... 8% | |
Reading package lists... 8% | |
Reading package lists... 24% | |
Reading package lists... 73% | |
Reading package lists... 73% | |
Reading package lists... 74% | |
Reading package lists... 74% | |
Reading package lists... 74% | |
Reading package lists... 80% | |
Reading package lists... 80% | |
Reading package lists... 80% | |
Reading package lists... 80% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 94% | |
Reading package lists... 94% | |
Reading package lists... 94% | |
Reading package lists... 94% | |
Reading package lists... 99% | |
Reading package lists... 99% | |
Reading package lists... 99% | |
Reading package lists... 99% | |
Reading package lists... Done | |
Reading package lists... 0% | |
Reading package lists... 0% | |
Reading package lists... 0% | |
Reading package lists... 7% | |
Reading package lists... 7% | |
Reading package lists... 8% | |
Reading package lists... 8% | |
Reading package lists... 34% | |
Reading package lists... 73% | |
Reading package lists... 73% | |
Reading package lists... 74% | |
Reading package lists... 74% | |
Reading package lists... 80% | |
Reading package lists... 80% | |
Reading package lists... 80% | |
Reading package lists... 80% | |
Reading package lists... 88% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 90% | |
Reading package lists... 94% | |
Reading package lists... 94% | |
Reading package lists... 94% | |
Reading package lists... 94% | |
Reading package lists... 99% | |
Reading package lists... 99% | |
Reading package lists... 99% | |
Reading package lists... 99% | |
Reading package lists... Done | |
Building dependency tree... 0% | |
Building dependency tree... 0% | |
Building dependency tree... 50% | |
Building dependency tree... 50% | |
Building dependency tree | |
Reading state information... 0% | |
Reading state information... 0% | |
Reading state information... Done | |
The following additional packages will be installed: | |
libaio1 libapparmor1 libbsd0 libsctp1 | |
Suggested packages: | |
lksctp-tools | |
The following NEW packages will be installed: | |
libaio1 libapparmor1 libbsd0 libsctp1 stress-ng | |
0 upgraded, 5 newly installed, 0 to remove and 9 not upgraded. | |
Need to get 1674 kB of archives. | |
After this operation, 4397 kB of additional disk space will be used. | |
0% [Working] | |
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libapparmor1 amd64 2.12-4ubuntu5.1 [31.3 kB] | |
0% [1 libapparmor1 0 B/31.3 kB 0%] | |
5% [Working] | |
Get:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 libbsd0 amd64 0.8.7-1 [41.5 kB] | |
5% [2 libbsd0 0 B/41.5 kB 0%] | |
11% [Waiting for headers] | |
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libaio1 amd64 0.3.110-5ubuntu0.1 [6476 B] | |
12% [3 libaio1 1133 B/6476 B 17%] | |
16% [Working] | |
Get:4 http://archive.ubuntu.com/ubuntu bionic/main amd64 libsctp1 amd64 1.0.17+dfsg-2 [8008 B] | |
16% [4 libsctp1 0 B/8008 B 0%] | |
20% [Working] | |
Get:5 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 stress-ng amd64 0.09.25-1ubuntu2 [1586 kB] | |
20% [5 stress-ng 0 B/1586 kB 0%] | |
30% [5 stress-ng 207 kB/1586 kB 13%] | |
49% [5 stress-ng 594 kB/1586 kB 37%] | |
77% [5 stress-ng 1181 kB/1586 kB 74%] | |
100% [Working] | |
Fetched 1674 kB in 3s (527 kB/s) | |
debconf: delaying package configuration, since apt-utils is not installed | |
Selecting previously unselected package libapparmor1:amd64. | |
(Reading database ... | |
(Reading database ... 5% | |
(Reading database ... 10% | |
(Reading database ... 15% | |
(Reading database ... 20% | |
(Reading database ... 25% | |
(Reading database ... 30% | |
(Reading database ... 35% | |
(Reading database ... 40% | |
(Reading database ... 45% | |
(Reading database ... 50% | |
(Reading database ... 55% | |
(Reading database ... 60% | |
(Reading database ... 65% | |
(Reading database ... 70% | |
(Reading database ... 75% | |
(Reading database ... 80% | |
(Reading database ... 85% | |
(Reading database ... 90% | |
(Reading database ... 95% | |
(Reading database ... 100% | |
(Reading database ... 4040 files and directories currently installed.) | |
Preparing to unpack .../libapparmor1_2.12-4ubuntu5.1_amd64.deb ... | |
Unpacking libapparmor1:amd64 (2.12-4ubuntu5.1) ... | |
Selecting previously unselected package libbsd0:amd64. | |
Preparing to unpack .../libbsd0_0.8.7-1_amd64.deb ... | |
Unpacking libbsd0:amd64 (0.8.7-1) ... | |
Selecting previously unselected package libaio1:amd64. | |
Preparing to unpack .../libaio1_0.3.110-5ubuntu0.1_amd64.deb ... | |
Unpacking libaio1:amd64 (0.3.110-5ubuntu0.1) ... | |
Selecting previously unselected package libsctp1:amd64. | |
Preparing to unpack .../libsctp1_1.0.17+dfsg-2_amd64.deb ... | |
Unpacking libsctp1:amd64 (1.0.17+dfsg-2) ... | |
Selecting previously unselected package stress-ng. | |
Preparing to unpack .../stress-ng_0.09.25-1ubuntu2_amd64.deb ... | |
Unpacking stress-ng (0.09.25-1ubuntu2) ... | |
Setting up libsctp1:amd64 (1.0.17+dfsg-2) ... | |
Setting up libbsd0:amd64 (0.8.7-1) ... | |
Processing triggers for libc-bin (2.27-3ubuntu1) ... | |
Setting up libaio1:amd64 (0.3.110-5ubuntu0.1) ... | |
Setting up libapparmor1:amd64 (2.12-4ubuntu5.1) ... | |
Setting up stress-ng (0.09.25-1ubuntu2) ... | |
Processing triggers for libc-bin (2.27-3ubuntu1) ... | |
stress-ng: info: [306] dispatching hogs: 2 cpu, 1 io, 1 vm | |
stress-ng: info: [306] successful run completed in 10.03s | |
sleep 10s to wait cgroup refresh | |
/kata-1 25 - 5.9M - - | |
/kata-1/kata-sandbox 25 - 5.9M - - | |
/runc-1 1 - 1.0G - - | |
/runc-1/ef10581a552ca4bc529be8789e63acb662501f78fbc1856d5c42a29c8b364a61 1 - 1.0G - - | |
Directory /sys/fs/cgroup/memory/runc-1: | |
└─ef10581a552ca4bc529be8789e63acb662501f78fbc1856d5c42a29c8b364a61 | |
├─4083 bash | |
└─4194 /opt/kata/bin/qemu-system-x86_64 -name sandbox-f27b0617c6ccc26812e95... | |
Directory /sys/fs/cgroup/memory/kata-1: | |
└─kata-sandbox | |
├─4201 /opt/kata/libexec/kata-containers/kata-proxy -listen-socket unix:///... | |
└─4220 /opt/kata/libexec/kata-containers/kata-shim -agent unix:///run/vc/sb... | |
check again memory cgroup tasks | |
cgroup info: runc-1/ef10581a552ca4bc529be8789e63acb662501f78fbc1856d5c42a29c8b364a61 | |
type: memory | |
procs: | |
process:bash� | |
pid: 4083 | |
process:/opt/kata/bin/qemu | |
pid: 4194 | |
tasks: | |
process:bash� | |
pid: 4083 | |
process:/opt/kata/bin/qemu | |
pid: 4194 | |
process:/opt/kata/bin/qemu | |
pid: 4195 | |
process:/opt/kata/bin/qemu | |
pid: 4198 | |
process:/opt/kata/bin/qemu | |
pid: 4199 | |
process:/opt/kata/bin/qemu | |
pid: 4215 | |
process:/opt/kata/bin/qemu | |
pid: 4216 | |
memory.usage_in_bytes: | |
1128476672 | |
memory.stat: | |
cache 53997568 | |
rss 1068036096 | |
rss_huge 1067450368 | |
shmem 0 | |
mapped_file 0 | |
dirty 4460544 | |
writeback 0 | |
swap 0 | |
pgpgin 20625 | |
pgpgout 6782 | |
pgfault 1782 | |
pgmajfault 0 | |
inactive_anon 0 | |
active_anon 1068036096 | |
inactive_file 13090816 | |
active_file 40972288 | |
unevictable 0 | |
hierarchical_memory_limit 2147483648 | |
hierarchical_memsw_limit 4294967296 | |
total_cache 53997568 | |
total_rss 1068036096 | |
total_rss_huge 1067450368 | |
total_shmem 0 | |
total_mapped_file 0 | |
total_dirty 4460544 | |
total_writeback 0 | |
total_swap 0 | |
total_pgpgin 20625 | |
total_pgpgout 6782 | |
total_pgfault 1782 | |
total_pgmajfault 0 | |
total_inactive_anon 0 | |
total_active_anon 1068036096 | |
total_inactive_file 13090816 | |
total_active_file 40972288 | |
total_unevictable 0 | |
recent_rotated_anon 1573 | |
recent_rotated_file 10026 | |
recent_scanned_anon 2242 | |
recent_scanned_file 28742 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
set -o errtrace | |
get_memory_cgroup_tasks() { | |
cgroup="${1}" | |
echo "cgroup info: ${cgroup}" | |
echo "type: memory" | |
echo "procs:" | |
for p in $(cat "/sys/fs/cgroup/memory/${cgroup}/cgroup.procs"); do | |
if [ "${p}" != "" ]; then | |
printf " process:" | |
cat /proc/${p}/cmdline | awk '{print $1}' | cut -d- -f1 | |
printf " pid: %s\n " "${p}" | |
fi | |
done | |
echo "tasks:" | |
for p in $(cat "/sys/fs/cgroup/memory/${cgroup}/tasks"); do | |
if [ "${p}" != "" ]; then | |
printf " process:" | |
cat /proc/${p}/cmdline | awk '{print $1}' | cut -d- -f1 | |
printf " pid: %s\n " "${p}" | |
fi | |
done | |
} | |
show_stats() { | |
echo "sleep 10s to wait cgroup refresh" | |
sleep 10s | |
systemd-cgtop -1 /kata-1 | |
systemd-cgtop -1 /runc-1 | |
systemd-cgls "/sys/fs/cgroup/memory/runc-1" --no-pager | |
systemd-cgls "/sys/fs/cgroup/memory/kata-1" --no-pager | |
echo "check again memory cgroup tasks" | |
get_memory_cgroup_tasks "runc-1/${runc_container_id}" | |
echo "memory.usage_in_bytes:" | |
usage_in_bytes=$(cat "/sys/fs/cgroup/memory/runc-1/${runc_container_id}/memory.usage_in_bytes") | |
echo "${usage_in_bytes}" | |
echo "memory.stat:" | |
cat "/sys/fs/cgroup/memory/runc-1/${runc_container_id}/memory.stat" | |
} | |
docker rm -f $(docker ps -aq) >>/dev/null || true | |
cgdelete -r memory:/kata-1 || true | |
cgdelete -r memory:/runc-1 || true | |
echo "create runc container" | |
docker run --cpus 2 --memory 2G --cgroup-parent /runc-1 -dti --rm --runtime runc ubuntu bash | |
runc_container_id=$(docker ps -l -q --no-trunc) | |
get_memory_cgroup_tasks "runc-1/${runc_container_id}" | |
echo "create kata container" | |
docker run --cpus 2 --memory 2G --cgroup-parent /kata-1 -dti --rm --runtime kata-runtime ubuntu bash | |
kata_container_id=$(docker ps -l -q --no-trunc) | |
echo "Memory stats beore move hypervisor to runc cgroup" | |
show_stats | |
qemu_pid=$(pgrep qemu) | |
echo "Move qemu process to runc memory cgroup" | |
echo "${qemu_pid}" >>"/sys/fs/cgroup/memory/runc-1/${runc_container_id}/cgroup.procs" | |
echo "Memory stats after move hypervisor to runc cgroup" | |
show_stats | |
echo "to monitor the runc cgroup run:" | |
echo "systemd-cgtop /runc-1" | |
echo "systemd-cgls "/sys/fs/cgroup/memory/runc-1" --no-pager" | |
echo "stress VM memory" | |
docker exec -ti "${kata_container_id}" bash -c "apt-get update" | |
docker exec -ti "${kata_container_id}" bash -c "apt-get install -y stress-ng" | |
docker exec -ti "${kata_container_id}" bash -c "stress-ng -c 2 -i 1 -m 1 --vm-bytes 1024M -t 10s" | |
show_stats |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment