Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/coreclr/gc/unix/cgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Module Name:
#define SIZE_T_MAX (~(size_t)0)
#endif

#if defined(TARGET_LINUX) || defined(TARGET_ANDROID)
Comment thread
jkotas marked this conversation as resolved.
Outdated

#define CGROUP2_SUPER_MAGIC 0x63677270

#define PROC_MOUNTINFO_FILENAME "/proc/self/mountinfo"
Expand Down Expand Up @@ -619,13 +621,13 @@ size_t GetRestrictedPhysicalMemoryLimit()

bool GetPhysicalMemoryUsed(size_t* val)
{
if (val == nullptr)
return false;

bool result = false;
size_t linelen;
char* line = nullptr;

if (val == nullptr)
Comment thread
jkotas marked this conversation as resolved.
return false;

// Linux uses cgroup usage to trigger oom kills.
if (CGroup::GetPhysicalMemoryUsage(val))
return true;
Expand Down Expand Up @@ -656,3 +658,25 @@ bool GetPhysicalMemoryUsed(size_t* val)
free(line);
return result;
}

#else // !(TARGET_LINUX || TARGET_ANDROID)

void InitializeCGroup()
{
}

void CleanupCGroup()
{
}

size_t GetRestrictedPhysicalMemoryLimit()
{
return 0;
}

bool GetPhysicalMemoryUsed(size_t* val)
{
Comment thread
jkotas marked this conversation as resolved.
return false;
}

#endif // TARGET_LINUX || TARGET_ANDROID
15 changes: 15 additions & 0 deletions src/coreclr/nativeaot/Runtime/unix/cgroupcpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Module Name:

#include "cgroupcpu.h"

#if defined(TARGET_LINUX) || defined(TARGET_ANDROID)

#define CGROUP2_SUPER_MAGIC 0x63677270

#define BASE_TEN 10
Expand Down Expand Up @@ -510,3 +512,16 @@ bool GetCpuLimit(uint32_t* val)

return CGroup::GetCpuLimit(val);
}

#else // !(TARGET_LINUX || TARGET_ANDROID)

void InitializeCpuCGroup()
{
}

bool GetCpuLimit(uint32_t* val)
{
Comment thread
jkotas marked this conversation as resolved.
return false;
}

#endif // TARGET_LINUX || TARGET_ANDROID
21 changes: 21 additions & 0 deletions src/coreclr/pal/src/misc/cgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ SET_DEFAULT_DEBUG_CHANNEL(MISC);
#include <sys/vfs.h>
#endif

#if defined(TARGET_LINUX) || defined(TARGET_ANDROID)

#define CGROUP2_SUPER_MAGIC 0x63677270

#define BASE_TEN 10
Expand Down Expand Up @@ -525,3 +527,22 @@ PAL_GetCpuLimit(UINT* val)

return CGroup::GetCpuLimit(val);
}

#else // !(TARGET_LINUX || TARGET_ANDROID)

void InitializeCGroup()
{
}

void CleanupCGroup()
{
}

BOOL
PALAPI
Comment thread
jkotas marked this conversation as resolved.
PAL_GetCpuLimit(UINT* val)
{
Comment thread
jkotas marked this conversation as resolved.
return FALSE;
}

#endif // TARGET_LINUX || TARGET_ANDROID
Loading