Skip to content

Instantly share code, notes, and snippets.

@moschlar
Last active February 5, 2024 10:00
Show Gist options
  • Save moschlar/70d9a8375b86cd4d83dd to your computer and use it in GitHub Desktop.
Save moschlar/70d9a8375b86cd4d83dd to your computer and use it in GitHub Desktop.
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}"
@hrk
Copy link

hrk commented Feb 5, 2024

Hoping to see you back someday ;-) The script was very useful and gentoo is always in my heart (and computers alike)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment