Skip to content

Instantly share code, notes, and snippets.

@paoloantinori
Last active December 15, 2017 15:18
Show Gist options
  • Save paoloantinori/4e395bead94f0c1b2844cc52a4caf102 to your computer and use it in GitHub Desktop.
Save paoloantinori/4e395bead94f0c1b2844cc52a4caf102 to your computer and use it in GitHub Desktop.
Cgroups for java on Fedora
export MY_CGROUP_NAME="java_build"
export MY_SUBSYSTEMS="cpu,cpuacct"
sudo cgcreate -t $USER:$USER -a $USER:$USER -g $MY_SUBSYSTEMS:$MY_CGROUP_NAME
sudo cgset -r cpu.cfs_period_us=1000 $MY_CGROUP_NAME
sudo cgset -r cpu.cfs_quota_us=1000 $MY_CGROUP_NAME
# ls -al /sys/fs/cgroup/$MY_SUBSYSTEMS/$MY_CGROUP_NAME/
# cgexec seems not to work for me, so we are going to create explicitely a subshell and assign a cgroup to that process
bash
cgclassify -g $MY_SUBSYSTEMS:$MY_CGROUP_NAME $BASHPID
# verify it's working checking
# cat /proc/$BASHPID/cgroup
# if you want to delete the group (ignore the error)
cgdelete -g $MY_SUBSYSTEMS:$MY_CGROUP_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment