diff options
author | Neale Ferguson <neale@sinenomine.net> | 2022-01-25 20:29:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-25 20:29:02 +0300 |
commit | 04859508c54a7ac25547bc5bcf4a019f0517aa0b (patch) | |
tree | 5cf0e785602867159040b5b2ce0bcabb7edf596f /mono/metadata/icall.c | |
parent | 95229aaa2ec642449aea4eba44fc717ca74786ab (diff) |
Determine any memory/CPU limitations from sysfs cgroup (#21280)
Add capability to interrogate cgroup limitations when determining CP and memory limits
This code has been adapted from coreCLR. It has been modified from C++ but uses the same naming conventions in the event of a unified mechanism that can be shared between both runtimes being developed. The code has been tested on Ubuntu 20.04 and CentOS 7 with cgroupv1 and cgroupv2.
This code is required in the event of running mono in a container as the current limitations being discovered by mono are purely for the machine and not in a container which may have lower quotas.
* mono/utils/Makefile.am
- Add new file to build
* mono/utils/memfuncs.c
- Call `getRestrictedPhysicalMemoryLimit()` or `getPhyscalMemoryAvail()`
* mono/utils/memfuncs.h
- Add prototypes for the new APIs
* mono/utils/mono-cgroup.c
- Code adapted from coreCLR to interrogate sysfs to determine any limitations on memory or CPU
* mono/utils/mono-proclib.c
- Add call to `getCpuLimit()`
* mono/utils/mono-proclib.h
- Add prototype for the new API
Diffstat (limited to 'mono/metadata/icall.c')
-rw-r--r-- | mono/metadata/icall.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index 786c1099a07..08304a3c90d 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -9182,7 +9182,7 @@ ves_icall_System_Threading_Thread_YieldInternal (void) gint32 ves_icall_System_Environment_get_ProcessorCount (void) { - return mono_cpu_count (); + return mono_cpu_limit (); } #if defined(ENABLE_MONODROID) |