Skip to content

Commit 8f8f4c0

Browse files
committed
Emit warning if memory.peak cannot be be captured with cgroup v2.
Note that this is only about memory high watermark reporting, not about whether the submission is killed. Fixes #2763.
1 parent 0aa38df commit 8f8f4c0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

judge/create_cgroups.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ cgroup_error_and_usage () {
2121
# Check whether cgroup v2 is available.
2222
fs_type=$(awk '$2 == "/sys/fs/cgroup" {print $3}' /proc/mounts)
2323
if [ "$fs_type" = "cgroup2" ]; then
24+
kernel_version=$(uname -r)
25+
major=$(echo "$kernel_version" | cut -d '.' -f 1)
26+
minor=$(echo "$kernel_version" | cut -d '.' -f 2)
27+
if [ "$major" -lt 5 ] || { [ "$major" -eq 5 ] && [ "$minor" -lt 19 ]; }; then
28+
echo "WARNING: Kernel ($kernel_version) is too old to record peak RAM usage" >&2
29+
fi
2430
if ! echo "+memory" >> /sys/fs/cgroup/cgroup.subtree_control; then
25-
cgroup_error_and_usage "Error: Cannot add +memory to cgroup.subtree_control; check kernel params. Unable to continue."
31+
cgroup_error_and_usage "Error: Cannot add +memory to cgroup.subtree_control; check kernel params. Unable to continue."
2632
fi
2733
if ! echo "+cpuset" >> /sys/fs/cgroup/cgroup.subtree_control; then
28-
cgroup_error_and_usage "Error: Cannot add +cpuset to cgroup.subtree_control; check kernel params. Unable to continue."
34+
cgroup_error_and_usage "Error: Cannot add +cpuset to cgroup.subtree_control; check kernel params. Unable to continue."
2935
fi
3036
exit 0
3137
fi

0 commit comments

Comments
 (0)