From 4104eb5b7a43642abe3cf1769201a752c6883f4d Mon Sep 17 00:00:00 2001 From: Zonghang Li Date: Mon, 9 Dec 2024 13:36:53 +0400 Subject: [PATCH] fix std::max val type --- common/profiler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/profiler.cpp b/common/profiler.cpp index 0d00703a..6c2dc2fa 100644 --- a/common/profiler.cpp +++ b/common/profiler.cpp @@ -558,7 +558,7 @@ static uint64_t device_cgroup_physical_memory(bool available) { inactive_file = stats["inactive_file"]; } - uint64_t available_memory = std::max(mem_max - mem_current, 0); + uint64_t available_memory = mem_max - mem_current > 0 ? mem_max - mem_current : 0; available_memory += slab_reclaimable; available_memory += inactive_file; return available_memory; @@ -566,7 +566,7 @@ static uint64_t device_cgroup_physical_memory(bool available) { LOG_WRN("Using cgroup v1, the available memory could be error, will be addressed later\n"); uint64_t mem_limit = read_value_from_file("/sys/fs/cgroup/memory/memory.limit_in_bytes"); uint64_t mem_usage = read_value_from_file("/sys/fs/cgroup/memory/memory.usage_in_bytes"); - return std::max(mem_limit - mem_usage, 0); + return mem_limit - mem_usage > 0 ? mem_limit - mem_usage : 0; } } }