Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmm process was incorrectly added to kata_sandbox cgroup in cgroup v2 #4886

Open
yaoyinnan opened this issue Aug 11, 2022 · 2 comments · May be fixed by #5153
Open

vmm process was incorrectly added to kata_sandbox cgroup in cgroup v2 #4886

yaoyinnan opened this issue Aug 11, 2022 · 2 comments · May be fixed by #5153
Labels
bug Incorrect behaviour needs-review Needs to be assessed by the team.

Comments

@yaoyinnan
Copy link
Member

yaoyinnan commented Aug 11, 2022

After #4397 was merged, Kata can run on systems using cgroup v2. When the system uses cgroup v2, the vmm process will be incorrectly added to kata_sandbox.

root@k8s-worker01:/opt/shell# ps -A
  34962 ?        00:00:00 containerd-shim
  34971 ?        00:00:00 virtiofsd
  34977 ?        00:00:03 qemu-system-x86
  34979 ?        00:00:00 virtiofsd
  34982 ?        00:00:00 vhost-34977
  34985 ?        00:00:00 kvm-pit/34977
  34986 ?        00:00:00 vhost-34977
  34997 pts/0    00:00:00 ps

root@k8s-worker01:/opt/shell# cat /proc/{34962,34977,34971,34979}/cgroup
0::/kata_overhead/84f329f0d35ce26872da8296b441f0474721f083e73e9c82decd971a6ce5f3da
0::/kubepods/besteffort/podf5199815-6dd7-4250-8f04-69b89527bad7/kata_84f329f0d35ce26872da8296b441f0474721f083e73e9c82decd971a6ce5f3da
0::/kata_overhead/84f329f0d35ce26872da8296b441f0474721f083e73e9c82decd971a6ce5f3da
0::/kata_overhead/84f329f0d35ce26872da8296b441f0474721f083e73e9c82decd971a6ce5f3da

root@k8s-worker01:/opt/shell# ps -eT | grep 34977
  34977   34977 ?        00:00:00 qemu-system-x86
  34977   34978 ?        00:00:00 qemu-system-x86
  34977   34983 ?        00:00:00 qemu-system-x86
  34977   34984 ?        00:00:27 qemu-system-x86
  34982   34982 ?        00:00:00 vhost-34977
  34985   34985 ?        00:00:00 kvm-pit/34977
  34986   34986 ?        00:00:00 vhost-34977

root@k8s-worker01:/opt/shell# cat /proc/{34977,34978,34983,34984}/cgroup
0::/kubepods/besteffort/podf5199815-6dd7-4250-8f04-69b89527bad7/kata_84f329f0d35ce26872da8296b441f0474721f083e73e9c82decd971a6ce5f3da
0::/kubepods/besteffort/podf5199815-6dd7-4250-8f04-69b89527bad7/kata_84f329f0d35ce26872da8296b441f0474721f083e73e9c82decd971a6ce5f3da
0::/kubepods/besteffort/podf5199815-6dd7-4250-8f04-69b89527bad7/kata_84f329f0d35ce26872da8296b441f0474721f083e73e9c82decd971a6ce5f3da
0::/kubepods/besteffort/podf5199815-6dd7-4250-8f04-69b89527bad7/kata_84f329f0d35ce26872da8296b441f0474721f083e73e9c82decd971a6ce5f3da

As expected, when using sandbox_cgroup_only = false, processes(vmm, containerd-shim, virtiofsd) other than vCPU threads should be moved to the kata_overhead cgroup for management. For detailed design content, please refer to https://github.com/kata-containers/kata-containers/blob/main/docs/design/host-cgroups.md#sandbox_cgroup_only--false-default-setting.

This problem does not exist in cgroup v1, because cgroup v1 allows processes and their child threads to be moved to different cgroups. In cgroup v2, because threads can only be added to the cgroup where the process is located or the sub-cgroup of the process, we can no longer move processes other than vCPU threads to kata_overhead according to the host cgroup design scheme.

In this case, since the vmm (qemu-system-x86) process occupies a lot of resources, especially memory resources, if they are placed in the kata_sandbox cgroup, it may cause oom.

We need to discuss how to adjust the scheme of host cgroup management. It may be discussed in the following ways:

  • The vmm process is placed in kata_sandbox.
  • The vmm process is placed in kata_overhead along with the vCPU process.
  • Or is there any other way to make processes and threads under cgroup v2 placed under different cgroups.

@sameo @liubin @snir911 Please give me some suggestion to fix this problem, thanks.

@yaoyinnan yaoyinnan added bug Incorrect behaviour needs-review Needs to be assessed by the team. labels Aug 11, 2022
@liubin
Copy link
Member

liubin commented Aug 12, 2022

One main change of cgroup v2 is the control granularity, v2 is mainly processes target but not threads. But CPU controller requires thread mode.

These are supported threaded controller:

  • cpu
  • cpuset
  • perf_event
  • pids

Cgroup v2 supports "Threaded subtree", so put overhead and sandbox cgroups into one threaded subtree may fix this issue:

image

@fidencio
Copy link
Member

cc @egernst

yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 9, 2022
The sandbox and overhead are placed in the same cgroup through thread mode to realize that the vCPU thread is placed in the sandbox and other processes are placed in the overhead.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
@yaoyinnan yaoyinnan linked a pull request Sep 9, 2022 that will close this issue
@katacontainersbot katacontainersbot moved this from To do to In progress in Issue backlog Sep 9, 2022
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 9, 2022
The sandbox and overhead are placed in the same cgroup through thread mode to realize that the vCPU thread is placed in the sandbox and other processes are placed in the overhead.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 11, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 13, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 13, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 13, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 13, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 13, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 13, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 14, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 14, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 14, 2022
Update the description that threaded mode for management in cgroupv2 in host cgroups docs

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 14, 2022
Update the description that threaded mode for management in cgroupv2 in host cgroups docs

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 15, 2022
Update the description that threaded mode for management in cgroupv2 in host cgroups docs

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 15, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 15, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 16, 2022
Update the description that threaded mode for management in cgroupv2 in host cgroups docs

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 16, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 16, 2022
Update the description that threaded mode for management in cgroupv2 in host cgroups docs

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 16, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 16, 2022
Update the description that threaded mode for management in cgroupv2 in host cgroups docs

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Sep 16, 2022
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 19, 2023
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 19, 2023
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 19, 2023
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Feb 9, 2023
Update the description that threaded mode for management in cgroupv2 in host cgroups docs

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Feb 9, 2023
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Feb 11, 2023
Update the description that threaded mode for management in cgroupv2 in host cgroups docs

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Feb 11, 2023
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 19, 2024
Update the description that threaded mode for management in cgroupv2 in host cgroups docs

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 19, 2024
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 19, 2024
Update the description that threaded mode for management in cgroupv2 in host cgroups docs

Fixes: kata-containers#4886
Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 19, 2024
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886
Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 26, 2024
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 26, 2024
Merged ValidCgroupPath method and modified unit tests.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 26, 2024
For different versions of cgroups, use different methods to delete cgroups. For cgroup v2, you need to delete the thread mode cgroup first.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 26, 2024
Because cgroups linux has modified the interface, the cgroups darwin interface has been unified.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 26, 2024
For different versions of cgroups, use different methods to delete cgroups. For cgroup v2, you need to delete the thread mode cgroup first.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 26, 2024
Because cgroups linux has modified the interface, the cgroups darwin interface has been unified.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 26, 2024
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 27, 2024
Because cgroups linux has modified the interface, the cgroups darwin interface has been unified.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 27, 2024
For different versions of cgroups, use different methods to delete cgroups. For cgroup v2, you need to delete the thread mode cgroup first.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 27, 2024
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 27, 2024
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 27, 2024
For different versions of cgroups, use different methods to delete cgroups. For cgroup v2, you need to delete the thread mode cgroup first.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 27, 2024
Retry delete and moveto operations to ensure cgroup resource recycling.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Jan 29, 2024
Retry delete and moveto operations to ensure cgroup resource recycling.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Feb 1, 2024
Update the description that threaded mode for management in cgroupv2 in host cgroups docs

Fixes: kata-containers#4886
Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Feb 1, 2024
Because cgroups linux has modified the interface, the cgroups darwin interface has been unified.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Feb 1, 2024
The sandbox and overhead are placed in the same cgroup through threaded mode.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Feb 1, 2024
For different versions of cgroups, use different methods to delete cgroups. For cgroup v2, you need to delete the thread mode cgroup first.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
yaoyinnan added a commit to yaoyinnan/kata-containers that referenced this issue Feb 1, 2024
Retry delete and moveto operations to ensure cgroup resource recycling.

Fixes: kata-containers#4886

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behaviour needs-review Needs to be assessed by the team.
Projects
Issue backlog
  
In progress
Development

Successfully merging a pull request may close this issue.

3 participants