Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Run Gentoo Portage in a cpu cgroup
PORTAGE_IONICE_COMMAND="/usr/local/sbin/portage-cgroup \${PID}"
#!/bin/sh
CGROUP_CPU_ROOT="/sys/fs/cgroup/cpu"
PORTAGE_CPU_SHARES=512
# $1 must be the portage PID
[ -n "$1" ] || exit 1
echo "/usr/local/sbin/remove-empty-cpu-cgroup" > "${CGROUP_CPU_ROOT}/release_agent"
cgroup=$(mktemp -d --tmpdir="${CGROUP_CPU_ROOT}" portage-XXXX) &&
echo $1 > "${cgroup}/tasks" &&
echo 1 > "${cgroup}/notify_on_release" &&
echo ${PORTAGE_CPU_SHARES} > "${cgroup}/cpu.shares"
#!/bin/sh
CGROUP_CPU_ROOT="/sys/fs/cgroup/cpu"
[ -n "${1}" ] || exit 1
cgroup="${CGROUP_CPU_ROOT}/${1}"
rmdir "${cgroup}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.