summaryrefslogtreecommitdiff
path: root/src/gc/unix/cgroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gc/unix/cgroup.cpp')
-rw-r--r--src/gc/unix/cgroup.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/gc/unix/cgroup.cpp b/src/gc/unix/cgroup.cpp
index 10b9b869ca..f81f14deb4 100644
--- a/src/gc/unix/cgroup.cpp
+++ b/src/gc/unix/cgroup.cpp
@@ -118,17 +118,10 @@ public:
*val = 1;
return true;
}
-
- cpu_count = (double) quota / period;
- if (cpu_count < UINT32_MAX - 1)
- {
- // round up
- *val = (uint32_t)(cpu_count + 0.999999999);
- }
- else
- {
- *val = UINT32_MAX;
- }
+
+ // Calculate cpu count based on quota and round it up
+ cpu_count = (double) quota / period + 0.999999999;
+ *val = (cpu_count < UINT32_MAX) ? (uint32_t)cpu_count : UINT32_MAX;
return true;
}