Skip to content

Commit

Permalink
Merge pull request #184 from black-dragon74/legacy-cgroups
Browse files Browse the repository at this point in the history
[centos] Add support for setting legacy cgroup pids
  • Loading branch information
black-dragon74 authored Jul 13, 2022
2 parents ea4ffcd + 86c1391 commit c98eefc
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions CentOS/update-params.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,42 @@
: ${TCMU_LOCKDIR:=/var/run/lock}

set_cgroup_pids() {
# Check if system is using unified cgroups i.e. v2
# We can cat /proc/filesystems, it'll have an entry for cgroups v2
# But systemd already does this for us, so we can just query it.
cgroupVer=$(systemctl show -all | grep -o "default-hierarchy.*" | cut -d '=' -f2)

# Call relevant functions, v2 is for unified, v1 is for legacy cgroups
if [[ "${cgroupVer}" == "unified" ]]
then
echo "Systemd is using unified cgroups(v2)"
set_cgroup_pids_v2 $1
else
echo "Systemd is using legacy cgroups(v1)"
set_cgroup_pids_v1 $1
fi
}

set_cgroup_pids_v1() {
local ret=0
local pids=$1
local cgroup max

cgroup=$(awk -F: '/:pids:/{print $3}' /proc/self/cgroup)

max=$(cat /sys/fs/cgroup/pids/"${cgroup}"/pids.max)
echo "maximum number of pids configured in cgroups: ${max}"

echo "${pids}" > /sys/fs/cgroup/pids/"${cgroup}"/pids.max
ret=$?

max=$(cat /sys/fs/cgroup/pids/"${cgroup}"/pids.max)
echo "maximum number of pids configured in cgroups (reconfigured): ${max}"

return ${ret}
}

set_cgroup_pids_v2() {
local ret=0
local pids=$1
local cgroup max
Expand Down

0 comments on commit c98eefc

Please sign in to comment.