Skip to content

Commit 2d6f4ff

Browse files
Make sure to enable memory and cpuset cgroup in v2
1 parent 71c1de7 commit 2d6f4ff

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

doc/manual/install-judgehost.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ 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-
You have now configured the system to use cgroups. On systems with
183-
cgroups v1, you need to run::
182+
You have now configured the system to use cgroups. To create
183+
the actual cgroups that DOMjudge will use you need to run::
184184

185185
sudo systemctl enable create-cgroups --now
186186

judge/create_cgroups.in

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,27 @@
99
JUDGEHOSTUSER=@DOMJUDGE_USER@
1010
CGROUPBASE="/sys/fs/cgroup"
1111

12-
# We do not need to do any of this with cgroup v2.
13-
fs_type=$(awk '$2 == "/sys/fs/cgroup" {print $3}' /proc/mounts)
14-
if [ "$fs_type" = "cgroup2" ]; then
15-
echo "cgroup v2 detected, skipping cgroup creation" >&2
16-
exit 0
17-
fi
18-
1912
cgroup_error_and_usage () {
2013
echo "$1" >&2
2114
echo "To fix this, please make the following changes:
2215
1. In /etc/default/grub, add 'cgroup_enable=memory swapaccount=1' to GRUB_CMDLINE_LINUX_DEFAULT.
23-
On modern distros (e.g. Debian bullseye and Ubuntu Jammy Jellyfish) which have cgroup v2 enabled by default,
24-
you need to add 'systemd.unified_cgroup_hierarchy=0' as well.
2516
2. Run update-grub
2617
3. Reboot" >&2
2718
exit 1
2819
}
2920

21+
# Check whether cgroup v2 is available.
22+
fs_type=$(awk '$2 == "/sys/fs/cgroup" {print $3}' /proc/mounts)
23+
if [ "$fs_type" = "cgroup2" ]; then
24+
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."
26+
fi
27+
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."
29+
fi
30+
exit 0
31+
fi
32+
3033
for i in cpuset memory; do
3134
mkdir -p $CGROUPBASE/$i
3235
if [ ! -d $CGROUPBASE/$i/ ]; then

0 commit comments

Comments
 (0)