Last active
February 5, 2024 10:00
-
-
Save moschlar/70d9a8375b86cd4d83dd to your computer and use it in GitHub Desktop.
Run Gentoo Portage in a cpu cgroup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PORTAGE_IONICE_COMMAND="/usr/local/sbin/portage-cgroup \${PID}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
CGROUP_CPU_ROOT="/sys/fs/cgroup/cpu" | |
[ -n "${1}" ] || exit 1 | |
cgroup="${CGROUP_CPU_ROOT}/${1}" | |
rmdir "${cgroup}" |
@hrk And more sadly, I don't even use Gentoo anymore. But when I hopefully come back to it someday, I will probably re-evaluate 😉
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
Unfortunately, this has become obsolete starting with 6.6 where EEVDF replaces CFS.
notify_on_release and release_agent have been removed as well (but I can't pinpoint exactly when).