Skip to content

Enable cgroups hierarchical memory limits support#93611

Merged
janvorli merged 7 commits into
dotnet:mainfrom
janvorli:enable-hierarchical-limits-support
Oct 19, 2023
Merged

Enable cgroups hierarchical memory limits support#93611
janvorli merged 7 commits into
dotnet:mainfrom
janvorli:enable-hierarchical-limits-support

Conversation

@janvorli

Copy link
Copy Markdown
Member

Cgroups can limit memory hierarchically. That means that ancestor cgroups can apply limits that are lower than the current cgroup's memory limit. .NET runtime is not honoring these hierarchical limits with either cgroups v1 or cgroups v2.
This change fixes it. The implementation is different for cgroups V1 and V2 because cgroups v1 provide aggregated hierarchical limit value in the memory.stat, but in cgroups v2, runtime needs to walk the cgroup hierarchy and find the lowest limit in it.

Cgroups can limit memory hierarchically. That means that ancestor
cgroups can apply limits that are lower than the current cgroup's
memory limit. .NET runtime is not honoring these hierarchical limits
with neither cgroups v1 nor cgroups v2.
This change fixes it. The implementation is different for cgroups V1
and V2 because cgroups v1 provide aggregated hierarchical limit value
in the memory.stat, but in cgroups v2, runtime needs to walk the
cgroup hierarchy and find the lowest limit in it.
@janvorli janvorli added the area-PAL-coreclr only for closed issues label Oct 17, 2023
@janvorli janvorli added this to the 9.0.0 milestone Oct 17, 2023
@janvorli
janvorli requested a review from jkotas October 17, 2023 14:45
@janvorli janvorli self-assigned this Oct 17, 2023
Comment thread src/libraries/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs Outdated
Comment thread src/coreclr/pal/src/misc/cgroup.cpp Outdated
* Remove cgroup memory related stuff from the coreclr PAL
* Real fix to the managed cgroup issue with cgroup v1 filesystem type detection
Comment thread src/libraries/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs
@jkotas

jkotas commented Oct 18, 2023

Copy link
Copy Markdown
Member

Build breaks. Lgtm otherwise.

…n/tests/DescriptionNameTests.cs

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@janvorli
janvorli merged commit e2a3a7f into dotnet:main Oct 19, 2023
@janvorli
janvorli deleted the enable-hierarchical-limits-support branch October 19, 2023 17:06
@lewing

lewing commented Oct 19, 2023

Copy link
Copy Markdown
Member

This broke the outerloop palsuite tests because of a removed symbol

https://dev.azure.com/dnceng-public/public/_build/results?buildId=444318&view=logs&jobId=efb0e688-765b-56f1-1b94-fb914f4a08b7&j=efb0e688-765b-56f1-1b94-fb914f4a08b7&t=0e66e276-1ec2-597c-a7ec-8bd834919a09

 /__w/1/s/src/coreclr/pal/tests/palsuite/miscellaneous/CGroup/test1/test.cpp:37:24: error: use of undeclared identifier 'PAL_GetRestrictedPhysicalMemoryLimit'
      size_t mem_limit = PAL_GetRestrictedPhysicalMemoryLimit();
                         ^

@janvorli

Copy link
Copy Markdown
Member Author

Ah, I am sorry for that, Iet me fix it right away.

@janvorli

Copy link
Copy Markdown
Member Author

PR with the fix is here: #93757

@ghost ghost locked as resolved and limited conversation to collaborators Nov 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-PAL-coreclr only for closed issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants