Add support for creating subfolders in cgroupv2 #144
+57
−27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The first commit adds cgroup v2 support for
load_with_relative_paths
- sinceget_cgroups_relative_paths
already stores the path for the unified hierarchy in cgroup v2 under the empty""
key - we can look that key up inload_with_relative_paths
and prepend it to the passed path for all subsystems and for the "path" field in the Cgroup struct itself.Some other changes in
load_with_relative_paths
are:path
- to create a cgroup that represents the "current" cgroup if used with the relative paths fromget_cgroups_relative_paths
The second commit adds the ability to "create" a cgroupv2 hierarchy without enabling subtree_control. This is crucial, because in cgroupv2, due to the rule that processes can only appear in leafs, if you want to create a subdirectory of existing cgroup with a process in it you need the following order of operations:
So with the changes in this PR - the following code creates a directory "foo" under the existing cgroup, moves all processes from current cgroup into "foo" and then enables subtree_control on the parent.
If this is merged I will open another PR for Builder to expose this from builder as well.