This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.
Please visit our production wiki at https://wiki.gentoo.org
Talk:OpenRC/CGroups
Example: limit memory and I/O for cron jobs
Running rsnapshot could use up a large amount of the system's pagecache, which can cause significant latencies for regular operations like launching new processes / allocating memory (as shown by sys-process/latencytop). To limit the impact of such background jobs on system latency you can limit the amount of memory used by all cron jobs: including the memory used for the file system cache.
https://github.com/Feh/nocache#alternate-approaches shows how to this can be done from the backup script itself.
However using OpenRC you can automatically apply this to all jobs launched from cron. Here is an example if you are using sys-process/cronie:
# Settings for the CRON daemon. # CRONDARGS= : any extra command-line startup arguments for crond CRONDARGS= rc_cgroup_memory="memory.limit_in_bytes 512M" rc_cgroup_blkio="blkio.weight 100" # if you want to kill all running cron jobs when stopping or restarting the cron daemon # then uncomment the follow line # rc_cgroup_cleanup="yes"
root #
service cronie restart
To check that it worked:
root #
cat /sys/fs/cgroup/memory/openrc_cronie/memory.limit_in_bytes
root #
cat /sys/fs/cgroup/memory/openrc_cronie/tasks; pidof crond
--Edwintorok (talk) 12:24, 9 October 2016 (UTC)
CGroups version 2 and enabled controllers by default?
How does OpenRC enable cgroups version 2? On my Gentoo, the file /sys/fs/cgroup/cgroup.subtree_control is empty. This means that no services have any enabled controllers.
To enable a controller simply do:
root #
echo "+cpu +memory" > /sys/fs/cgroup/cgroup.subtree_control
To enable them by default set the following line in rc.conf.
rc_cgroup_controllers="cpu memory io pids"