Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions judge/create_cgroups.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cgroup_error_and_usage () {
exit 1
}

# Check whether cgroup v2 is available.
# Check whether cgroup v2 is enabled.
fs_type=$(awk '$2 == "/sys/fs/cgroup" {print $3}' /proc/mounts)
if [ "$fs_type" = "cgroup2" ]; then
kernel_version=$(uname -r)
Expand All @@ -34,25 +34,26 @@ You can try using cgroup V1 by adding systemd.unified_cgroup_hierarchy=0 to the
if ! echo "+cpuset" >> /sys/fs/cgroup/cgroup.subtree_control; then
cgroup_error_and_usage "Error: Cannot add +cpuset to cgroup.subtree_control; check kernel params. Unable to continue."
fi
fi

# Trying cgroup V1:
else # Trying cgroup V1:

for i in cpuset memory; do
mkdir -p $CGROUPBASE/$i
if [ ! -d $CGROUPBASE/$i/ ]; then
if ! mount -t cgroup -o$i $i $CGROUPBASE/$i/; then
cgroup_error_and_usage "Error: Can not mount $i cgroup. Probably cgroup support is missing from running kernel. Unable to continue."
for i in cpuset memory; do
mkdir -p $CGROUPBASE/$i
if [ ! -d $CGROUPBASE/$i/ ]; then
if ! mount -t cgroup -o$i $i $CGROUPBASE/$i/; then
cgroup_error_and_usage "Error: Can not mount $i cgroup. Probably cgroup support is missing from running kernel. Unable to continue."
fi
fi
mkdir -p $CGROUPBASE/$i/domjudge
done

if [ ! -f $CGROUPBASE/memory/memory.limit_in_bytes ] || [ ! -f $CGROUPBASE/memory/memory.memsw.limit_in_bytes ]; then
cgroup_error_and_usage "Error: cgroup support missing memory features in running kernel. Unable to continue."
fi
mkdir -p $CGROUPBASE/$i/domjudge
done

if [ ! -f $CGROUPBASE/memory/memory.limit_in_bytes ] || [ ! -f $CGROUPBASE/memory/memory.memsw.limit_in_bytes ]; then
cgroup_error_and_usage "Error: cgroup support missing memory features in running kernel. Unable to continue."
fi
chown -R $JUDGEHOSTUSER $CGROUPBASE/*/domjudge

chown -R $JUDGEHOSTUSER $CGROUPBASE/*/domjudge
cat $CGROUPBASE/cpuset/cpuset.cpus > $CGROUPBASE/cpuset/domjudge/cpuset.cpus
cat $CGROUPBASE/cpuset/cpuset.mems > $CGROUPBASE/cpuset/domjudge/cpuset.mems

cat $CGROUPBASE/cpuset/cpuset.cpus > $CGROUPBASE/cpuset/domjudge/cpuset.cpus
cat $CGROUPBASE/cpuset/cpuset.mems > $CGROUPBASE/cpuset/domjudge/cpuset.mems
fi # cgroup V1
Loading