Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions src/coreclr/gc/unix/cgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ class CGroup

static bool GetCGroupMemoryUsage(size_t *val, const char *filename, const char *inactiveFileFieldName)
{
if (s_memory_cgroup_path == nullptr)
return false;

// Use the same way to calculate memory load as popular container tools (Docker, Kubernetes, Containerd etc.)
// For cgroup v1: value of 'memory.usage_in_bytes' minus 'total_inactive_file' value of 'memory.stat'
// For cgroup v2: value of 'memory.current' minus 'inactive_file' value of 'memory.stat'
Expand All @@ -534,9 +537,6 @@ class CGroup
if (!result)
return result;

if (s_memory_cgroup_path == nullptr)
return false;

uint64_t inactiveFileValue = 0;
if (GetCGroupMemoryStatField(inactiveFileFieldName, &inactiveFileValue))
{
Expand Down
6 changes: 3 additions & 3 deletions src/mono/mono/utils/mono-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,9 @@ getCGroupMemoryLimit(size_t *val, const char *filename)
static gboolean
getCGroupMemoryUsage(size_t *val, const char *filename, const char *inactiveFileFieldName)
{
if (s_memory_cgroup_path == NULL)
return FALSE;

/*
* Use the same way to calculate memory load as popular container tools (Docker, Kubernetes, Containerd etc.)
* For cgroup v1: value of 'memory.usage_in_bytes' minus 'total_inactive_file' value of 'memory.stat'
Expand All @@ -561,9 +564,6 @@ getCGroupMemoryUsage(size_t *val, const char *filename, const char *inactiveFile
if (!result)
return result;

if (s_memory_cgroup_path == NULL)
return FALSE;

char *stat_filename = NULL;
if (asprintf (&stat_filename, "%s%s", s_memory_cgroup_path, CGROUP_MEMORY_STAT_FILENAME) < 0)
return FALSE;
Expand Down
Loading