Skip to content

Commit b3a8dda

Browse files
committed
Fall back to cgroup V1 if kernel does not support memory.peak in V2
and document kernel version requirement for cgroup V2.
1 parent c27e007 commit b3a8dda

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

doc/manual/install-judgehost.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ Optionally the timings can be made more stable by not letting the OS schedule
179179
any other tasks on the same CPU core the judgedaemon is using:
180180
``GRUB_CMDLINE_LINUX_DEFAULT="quiet cgroup_enable=memory swapaccount=1 isolcpus=2"``
181181

182+
On modern systems where cgroup v2 is available, DOMjudge will try to
183+
use that. This requires kernel versions 5.20 or 6.0 or later to
184+
support reporting peak memory usage. If not found, the system will try
185+
to fall back to cgroup v1, but this might require you to add
186+
``systemd.unified_cgroup_hierarchy=0`` to the boot options as well.
187+
182188
You have now configured the system to use cgroups. To create
183189
the actual cgroups that DOMjudge will use you need to run::
184190

judge/create_cgroups.in

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,30 @@ cgroup_error_and_usage () {
1919
}
2020

2121
# Check whether cgroup v2 is available.
22+
cgroupv2_available=''
2223
fs_type=$(awk '$2 == "/sys/fs/cgroup" {print $3}' /proc/mounts)
2324
if [ "$fs_type" = "cgroup2" ]; then
2425
kernel_version=$(uname -r)
2526
major=$(echo "$kernel_version" | cut -d '.' -f 1)
2627
minor=$(echo "$kernel_version" | cut -d '.' -f 2)
2728
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+
echo "Kernel ($kernel_version) is too old to record peak RAM usage with cgroup V2, trying cgroup V1" >&2
30+
else
31+
cgroupv2_available=1
2932
fi
33+
fi
34+
35+
if [ -n "$cgroupv2_available" ]; then
3036
if ! echo "+memory" >> /sys/fs/cgroup/cgroup.subtree_control; then
3137
cgroup_error_and_usage "Error: Cannot add +memory to cgroup.subtree_control; check kernel params. Unable to continue."
3238
fi
3339
if ! echo "+cpuset" >> /sys/fs/cgroup/cgroup.subtree_control; then
3440
cgroup_error_and_usage "Error: Cannot add +cpuset to cgroup.subtree_control; check kernel params. Unable to continue."
3541
fi
36-
exit 0
3742
fi
3843

44+
# Trying cgroup V1:
45+
3946
for i in cpuset memory; do
4047
mkdir -p $CGROUPBASE/$i
4148
if [ ! -d $CGROUPBASE/$i/ ]; then

0 commit comments

Comments
 (0)