cgroupv2: don't enable threaded mode by default#2390
Conversation
|
@AkihiroSuda PTAL |
|
I'm not sure I understand why we're putting cgroupv2 into threaded mode -- @AkihiroSuda is this to work around some odd permission issue (and why does it fix an |
| // Otherwise ENOTSUP may happen. | ||
| cgType := filepath.Join(current, "cgroup.type") | ||
| _ = ioutil.WriteFile(cgType, []byte("threaded"), 0644) | ||
| if rootless { |
There was a problem hiding this comment.
cgType := filepath.Join(current, "cgroup.type")
cgTypeB, _ := ioutil.ReadFile(cgType)
if strings.TrimSpace(string(cgTypeB)) == "domain invalid" {
_ = ioutil.WriteFile(cgType, []byte("threaded"), 0644)
}|
@cyphar $ sudo podman run -it --rm --privileged --runtime=crun alpine
/ # cd /sys/fs/cgroup/
/sys/fs/cgroup # cat cgroup.controllers
cpuset cpu io memory pids
/sys/fs/cgroup # cat cgroup.subtree_control
/sys/fs/cgroup # echo +cpu > cgroup.subtree_control
/sys/fs/cgroup # mkdir foo
/sys/fs/cgroup # cat foo/cgroup.type
domain invalid |
|
Okay, but "domain invalid" means that the cgroup is in an invalid state (meaning that one of the cgroup rules has been violated -- most likely the no-internal-processes rule). Putting a cgroup into threaded mode doesn't fix that -- it switches it into an alternative mode which only allows controllers which are thread-aware to be enabled (such as cpu). This is why we can't enable the memory controller -- it isn't thread-aware. IMHO, a more complete solution would be to figure out how to deal with the parent cgroup having child processes (which is a bit dodgy if we're going to move other programs on the system between cgroups) or to simply give an error if we hit |
Personally, I prefer this one. @AkihiroSuda WDYT? Because in man7 cgroups: |
|
SGTM, but when no domain controller is enabled, we can write "threaded" without retuning error |
fd7d8a4 to
eea6058
Compare
106fdd8 to
7ca4d5a
Compare
| if strings.TrimSpace(string(cgType)) == "domain invalid" { | ||
| cgTypeParentFile := filepath.Join(current, "../cgroup.type") | ||
| cgTypeParent, _ := ioutil.ReadFile(cgTypeParentFile) | ||
| if bytes.HasPrefix(cgTypeParent, []byte("domain")) { |
There was a problem hiding this comment.
IIUC we don't need to check parent, we just need to check whether the current config contains domain controller
1e97975 to
757bb65
Compare
|
Line 103 in 1d14356 I think rootless doesn't need threaded mode in default?I don't know whether my opinion is right or not. @AkihiroSuda |
|
Let's check invalid cgroup.type and set threaded conditionally |
757bb65 to
e0c9737
Compare
| if grep -qw invalid "$CGROUP_MOUNT/$CGROUP_PATH/cgroup.type"; then | ||
| echo threaded > "$CGROUP_MOUNT/$CGROUP_PATH/cgroup.type" | ||
| fi | ||
| # Make sure cgroup.type doesn't contain "invalid". Otherwise write ops will fail with ENOTSUP. |
There was a problem hiding this comment.
This has been removed before LGTM.
I think we should keep these comments to let other people know why we need to write threaded to cgroups.type.
There was a problem hiding this comment.
Is the echo threaded > still needed? Seems a bit odd to run the entire test suite under threaded.
e0c9737 to
2aefa92
Compare
kolyshkin
left a comment
There was a problem hiding this comment.
a few minor fixes, otherwise good
2aefa92 to
d6a76d9
Compare
|
@kolyshkin LGTY? |
Because in threaded mode, we can't enable the memory controller -- it isn't thread-aware. Signed-off-by: lifubang <lifubang@acmcoder.com>
d6a76d9 to
fe0669b
Compare
|
@AkihiroSuda @kolyshkin PTAL |
After this commit: 60c647e
Runc enable
threadedmode in cgroup v2 by default.If the cgroupPath is set to a absolute path like
/docker/********, the memory subsystem can't be used by this mode.So, I think we should use
domainmode by default.Signed-off-by: lifubang lifubang@acmcoder.com